title: Django testing named URLs with additional GET parameters
body: <p>I am trying to write some tests for a Django application I'm working on but I haven't yet decided on the exact urls I want to use for each view.  Therefore, I'm using named urls in the tests. </p>
  
  <p>For example, I have a url named dashboard:</p>
  
  <pre><code>c = Client()
  resp = c.get(reverse('dashboard'))
  </code></pre>
  
  <p>This view should only be available to logged in users.  If the current user is anonymous, it should redirect them to the login page, which is also a named url.  However, when it does this, it uses an additional GET parameter to keep track of the url it just came from, which results in the following:</p>
  
  <pre><code>/login?next=dashboard
  </code></pre>
  
  <p>When I then try to test this redirect, it fails because of these additional parameters:</p>
  
  <pre><code># It's expecting '/login' but gets '/login?next=dashboard'
  self.assertRedirects(resp, reverse('login'))
  </code></pre>
  
  <p>Obviously, it works if I hard code them into the test:</p>
  
  <pre><code>self.assertRedirects(resp, '/login?next=dashboard')
  </code></pre>
  
  <p>But then, if I ever decide to change the URL for my dashboard view, I'd have to update every test that uses it.</p>
  
  <p>Is there something I can do to make it easier to handle these extra parameters?</p>
  
  <p>Any advice appreciated.</p>
  
  <p>Thanks.</p>