torchbox / wagtail-template

A Django template for starting new Wagtail projects with Vagrant. NO LONGER MAINTANED
19 stars 8 forks source link

Url problemes #20

Closed SalahAdDin closed 9 years ago

SalahAdDin commented 9 years ago

Hi guys, i have the next urls.py file:

import os

from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.conf import settings
from django.contrib import admin

from django.views.generic.base import RedirectView

from wagtail.wagtailadmin import urls as wagtailadmin_urls
from wagtail.wagtailsearch import urls as wagtailsearch_urls
from wagtail.wagtaildocs import urls as wagtaildocs_urls
from wagtail.wagtailcore import urls as wagtail_urls

from wagtail.wagtailimages import urls as wagtailimages_urls
from wagtail.wagtailembeds import urls as wagtailembeds_urls
from wagtail.wagtailsnippets import urls as wagtailsnippets_urls
from wagtail.wagtailredirects import urls as wagtailredirects_urls

urlpatterns = patterns('',
    url(r'^django-admin/', include(admin.site.urls)),

    url(r'^admin/', include(wagtailadmin_urls)),
    url(r'^search/', include(wagtailsearch_urls)),
    url(r'^documents/', include(wagtaildocs_urls)),

    url(r'^embeds/', include(wagtailembeds_urls)),
    url(r'^images/', include(wagtailimages_urls)),
    url(r'^redirects/', include(wagtailredirects_urls)),    
    url(r'^snippets/', include(wagtailsnippets_urls)),
    #url(r'^users/', include(wagtailusers_urls)),

    url(r'', include(wagtail_urls)),
)

if settings.DEBUG:
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns

    urlpatterns += staticfiles_urlpatterns()
    urlpatterns += static(settings.MEDIA_URL + 'images/', document_root=os.path.join(settings.MEDIA_ROOT, 'images'))
    #urlpatterns += patterns('',
    #    (r'^favicon\.ico$', RedirectView.as_view(url=settings.STATIC_URL + 'myapp/images/favicon.ico'))
    #)

I have a problem with the next urls: /documents/, /embeds/, /images/, when i try go in this page the server say me that this page don't exists, documents and images is possible using /admin/, i don't know if this is normal, i belive not because i believed had seen the urls working, but, embeds don't works using /admin/ yet.

I try do this with users but i have a url improperly configured issue.

Thank you very much.

gasman commented 9 years ago

Hi @SalahAdDin,

You're using a very outdated version of urls.py there. Since Wagtail 0.3, all of the sub-apps of Wagtail (embeds, images, redirects etc) are automatically registered under /admin (or whatever path you chose for wagtailadmin_urls), so there's no need to include them in your urls.py. (Also, the paths given here are only URL prefixes - there's no guarantee of an actual usable page at that location. For example, the 'embeds' app only adds views within '/admin/embeds/chooser/' - normally there would be no reason for a user to visit these directly.)

Please see https://github.com/torchbox/wagtail-template/blob/master/project_name/project_name/urls.py (or the file you get when running wagtail start projectname on newer versions of Wagtail) for the correct format of urls.py.