Django : 404 (main.urls Not Included In Myproject/urls.py?)
I have the following problem : I've made a little django (1.7.8) project (named djangocmstest) to test django-cms (but it could be related with just django, I'm not sure about this
Solution 1:
In the project's urls.py
you use the i18n_patterns
instead of simple patterns
so url for your page should be:
/en/one/
UPDATE: Remove the trailing slashes from the regexes in the project's urls.py
. So regex should be r'^'
but not the r'^/'
:
urlpatterns = i18n_patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('main.urls')),
url(r'^', include('cms.urls')),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Solution 2:
Your regular expressions for main.urls
and cms.urls
should not include a forwards slash:
urlpatterns = i18n_patterns('',
url(r'^admin/', include(admin.site.urls)),
# Please note that I'm not sure how to handle# the order of the two following lines.
url(r'^', include('main.urls')),
url(r'^', include('cms.urls')),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Also, when you perform your query, make sure it is for
http://127.0.0.1:8000/en/one/
since you do have a trailing slash in your main.urls
file.
Solution 3:
You are using two includes with the same regex. This way the include won't work. Try this:
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static
urlpatterns = i18n_patterns('',
url(r'^admin/', include(admin.site.urls)),
# Please note that I'm not sure how to handle# the order of the two following lines.
url(r'^cms/', include('cms.urls')),
url(r'^/', include('main.urls')),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Post a Comment for "Django : 404 (main.urls Not Included In Myproject/urls.py?)"