Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django URLs not matching with GET variables

Tags:

django

I have the following django URL:

url(r'^companies/$', 'companies', name='companies'),

If I go to http://localhost:8000/companies/ it works perfectly. However, if I try adding any GET variables to the URL django raises a 404. For example, if I go to http://localhost:8000/companies/?c=1 django raises a 404. What's strange, is that on the 404 it says:

The current URL, companies/, didn't match any of these.

Why am I not able to pass GET variables to my URLs?

I am using django 1.4.

The companies view is defined like:

def companies(request):

It shouldn't have to accept any additional parameters because they are GET variables, not URL parameters- correct? I swear I've done this hundreds of times and it always just works...

like image 603
dgel Avatar asked Apr 09 '12 21:04

dgel


1 Answers

Okay. Figured out what was causing this very strange behavior. I have a custom context processor that is calling resolve(request.get_full_path()). Apparently that causes a 404 if there are any GET variables in the URL. Very strange.

like image 78
dgel Avatar answered Oct 18 '22 11:10

dgel