【发布时间】:2011-12-15 13:19:07
【问题描述】:
我有一个应用程序名称 blogspot,当我将与此应用程序相关的 url 添加到项目 urls.py 文件中时,我会收到上述错误。 blogspot 应用程序的 urls.py 文件的代码是
from django.conf.urls.defaults import *
from blogspot.models import UserBlog
from tagging.views import tagged_object_list
from hitcount.views import update_hit_count_ajax
info_dict =
{
'queryset': UserBlog.objects.filter(status=1),
'date_field': 'pub_date',
}
urlpatterns = patterns('',
url(r'^new/$', 'blogspot.views.blog_form' , name = 'blog_new'),
url(r'^edit/(?P<blog_id>\d+)/$', 'blogspot.views.blog_form', name = 'blog_edit'),
url(r'^delete/(?P<blog_id>\d+)/$', 'blogspot.views.blog_delete', name = 'blog_delete'),
url(r'^all/$', 'blogspot.views.all_blogs', name = 'blog_all'),
url(r'^view/(?P<blog_id>\d+)/$', 'blogspot.views.blog_view', name = 'blog_view'),
url(r'^ajax/hit/$',update_hit_count_ajax,name='hitcount_update_ajax'),
)
urlpatterns += patterns('django.views.generic.date_based',
url(r'(?P<year>d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/(?P<slug>[-w]+)/$', 'object_detail', dict(info_dict, slug_field='slug',template_name='blogspot/detail.html')),
url(r'^(?P<year>d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/(?P<slug>[-w]+)/$', 'object_detail', dict(info_dict, template_name='blogspot/list.html')),
url(r'^(?P<year>d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/$','archive_day',dict(info_dict,template_name='blogspot/list.html')),
url(r'^(?P<year>d{4})/(?P<month>[a-z]{3})/$','archive_month', dict(info_dict, template_name='blogspot/list.html')),
url(r'^(?P<year>d{4})/$','archive_year', dict(info_dict, template_name='blogspot/list.html')),
url(r'^$','archive_index', dict(info_dict, template_name='blogspot/list.html')),
)
我不明白,添加这个 url 文件怎么会弄乱管理 url。
更新
当我从 urls.py 文件中删除所有行时,一切正常。但是,即使我添加一行,整个事情都会变得流氓。我不明白没有语法错误,即使它不起作用。
更多更新
我认为这个问题可能是因为应用程序的 views.py 文件,因为每个其他 py 文件都有它的 .pyc 文件而不是 views.py 文件。从语法上讲,urls.py 文件中没有错误。
【问题讨论】:
标签: django django-admin django-urls