0

This is a Django site, migrated to Dotcloud through this documentation. I have an issue with my URLs: I cannot access my admin part, and the root URL that is not supposed to be matched matches ! Let me explain in detail:

root/
|- settings.py
|- urls.py
|- champis/
   |- urls.py

File root/urls.py:

urlpatterns = patterns('',
    (r'^champis/', include('champis.urls')),
    (r'^admin/$', include(admin.site.urls)),
)

File root/champis/urls.py:

urlpatterns = patterns('champis.views',
    url(r'^$', 'index'),
    url(r'^recherche/$', 'search'),
    url(r'^glossaire/$', 'glossary'),
    url(r'^glossaire/(?P<letter>\w)/$', 'glossary'),
    url(r'^(?P<champi_name>\w+)/$', 'detail'),
    url(r'^(?P<champi_name>\w+)/(?P<photo_nb>\d+)/$', 'detail'),
)

So I should find my admin site at http://server.com/admin, and my application at http://server.com/champis, but this is not the case:

  • http://server.com/admin and http://server.com/champis trigger a 404
  • but my applications is served at http://server.com !

It looks like as if the champis part of the URL was automatically and magically added to the root URL... Do you have an explanation ? Thanks !

EDIT: extract of my settings.py:

ROOT_URLCONF = 'urls'

Django version is 1.4, and actually DEBUG is set to True.

Emmanuel
  • 13,935
  • 12
  • 50
  • 72
  • Restarted server? You sure your application urls are not referred to via `ROOT_URLCONF`? – Yuji 'Tomita' Tomita Dec 09 '12 at 19:09
  • What does your directory structure look like? – Daniel Roseman Dec 09 '12 at 19:21
  • If you have DEBUG=True what does the django output tell you? Also what version of Django are you using? – Ken Cochrane Dec 09 '12 at 19:39
  • Edit added to clarify these points. – Emmanuel Dec 09 '12 at 19:50
  • @Emmanuel when you have DEBUG=True your 404 page should give you a list of available URL patterns that django looked at. Can you post that list? Also, have you tried ROOT_URLCONF='root.urls' ? https://docs.djangoproject.com/en/1.4/ref/settings/#root-urlconf – Ken Cochrane Dec 09 '12 at 21:00
  • Well, with dotcloud push you lose the `root` folder hierarchy, so you have to specify `'urls'` directly. I don't have anything exploitable in the logs: Page not found (404) Request Method: GET Request URL: http://server.com/admin/ – Emmanuel Dec 09 '12 at 21:17

1 Answers1

0

Remove the $ from '^admin/$':

urlpatterns = patterns('',
    (r'^champis/', include('champis.urls')),
    (r'^admin/', include(admin.site.urls)),
)
borges
  • 3,627
  • 5
  • 29
  • 44
  • I just tried, but that does not remove the error. Moreover this is the standard Django configuration for the admin site. – Emmanuel Dec 09 '12 at 20:11