基本上,我使用Django/Python編寫博客軟件。目前,我有以下文件關於Django的問題urls.py
urls.py:
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^sovietware/', include('sovietware.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^', include('sovietware.blog.urls')),
(r'^comments/', include('django.contrib.comments.urls')),
(r'^admin/', include(admin.site.urls)),
)
博客/ urls.py:
from django.conf.urls.defaults import *
from models import Post
queryset = {'queryset': Post.objects.order_by('-pub_date')}
urlpatterns = patterns('django.views.generic.list_detail',
url('^$', 'object_list', queryset, name='posts'),
url('^(?P<object_id>\d+)/$', 'object_detail', queryset, name='post'),
)
我的問題是......目前,這意味着當我在/和我點擊一個博客條目的標題鏈接,我被重定向到/ 1/...我希望它重定向到/ blog/1 /而 - 這是我需要在urls.py中編輯的東西嗎?如果是這樣,我需要添加什麼?
這取決於很多不僅僅是'urls.py'。 –