运行命令后,./manage.py runserver
我收到以下错误。我知道这肯定与 Urls.py 有关(r'^$',views.main_page),
,但似乎无法弄清楚需要更改什么......有什么建议吗?
网址.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
from content import views
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'crosstalk.views.home', name='home'),
# url(r'^crosstalk/', include('crosstalk.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^$',views.main_page),
(r'^admin/', include(admin.site.urls)),
(r'^js/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'templates/js'}),
(r"^(\d+)/$", "post"),
)
模型.py
from django.db import models
from datetime import datetime
class Cover(models.Model):
title = models.CharField(max_length=200)
slug = models.SlugField(unique=True)
text = models.TextField()
posts = models.ManyToManyField('Post')
def __unicode__(self):
return self.title
class Post(models.Model):
title = models.CharField(max_length=200)
slug = models.SlugField(unique=True)
date = models.DateTimeField(default=datetime.now)
text = models.TextField()
def __unicode__(self):
return self.title