Reputation: 11363
How can I configure Django url resolution to have all other URLs other than somedomain.com/admin
point to the application without any sort of prefix?
In my project's urls.py, I have
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
url(r'^$', include("photoapp.urls", namespace="photoapp")),
url(r'^admin/', include(admin.site.urls)),
)
and in photoapp/urls.py
, I have
from django.conf.urls import patterns, url
from . import views
urlpatterns = patterns('',
url(r'^$',views.index),
url(r'^fileUpload/?$', views.file_upload)
)
Now, both these URLs have associated views within photoapp/views.py
. somedomain.com
loads the template specified by views.index
, but somedomain.com/fileUpload
returns a 404. Specifically, the error message states
Using the URLconf defined in project.urls, Django tried these URL
patterns, in this order:
^$
^admin/
My goal is to have
somedomain.com/admin
resolve to the admin app, and
somedomain.com
somedomain.com/fileUpload
somedomain.com/search?q=query
be handled by photoapp/urls.py
. How can I configure the app urls.py to do so?
Upvotes: 0
Views: 46
Reputation: 45555
Remove the $
sign from the first url:
url(r'^', include("photoapp.urls", namespace="photoapp")),
Upvotes: 2