我在名为post和gallery的项目中使用了2个应用程序。在url localhost:8000 / en中,我特意使用post.urls"主页"。在主页上,当我想要转到{% url "gallery:gallery_detail" "photos" %}
时,它会给我一个错误。因为即使它需要关键字"照片"它找不到具体的模式" gallery_detail"。
我的问题是如何才能联系到这个anathor应用的网址?
我的主要urls.py:
from django.conf.urls import url,include
from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^ckeditor/', include("ckeditor_uploader.urls")),
]
urlpatterns += i18n_patterns(
url(r'^gallery/', include("gallery.urls",namespace="gallery")),
url(r'^', include("post.urls", namespace="post")),
)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
我的post.urls:
from django.conf.urls import url
from post.views import HomePageDetailView, AboutDetailView, \
CategoryDetailView, SponsorshipDetailView, CommonDetailView, NewsEntryDetailView
urlpatterns = [
url(r'^$', HomePageDetailView.as_view(), name="homepage"),
url(r'^about/(?P<slug>[-_\w]+)/$', AboutDetailView.as_view(),
name="about_detail"),
url(r'^category/(?P<slug>[-_\w]+)/$', CategoryDetailView.as_view(),
name="category_detail"),
url(r'^sponsorship/(?P<slug>[-_\w]+)/$', SponsorshipDetailView.as_view(),
name="sponsorship_detail"),
url(r'^news/(?P<slug>[-_\w]+)/$', NewsEntryDetailView.as_view(),
name="news_detail"),
url(r'^(?P<slug>[-_\w]+)/$', CommonDetailView.as_view(),
name="common_detail"),
]
我的gallery.urls:
from django.conf.urls import url
from gallery.views import GalleryDetailView
urlpatterns = [
url(r'^(?P<slug>[-_\w]+)/$', GalleryDetailView.as_view(),
name="galery_detail"),
]