为什么我死的简单Django应用程序会在我的mac 10.6.4上崩溃python?

时间:2010-09-07 13:07:19

标签: django

views.py

from django.shortcuts import render_to_response
from django.shortcuts import get_object_or_404
from django.shortcuts import get_list_or_404
from django.template.context import RequestContext

from articles.models import Article

def index(request):
    articles = get_list_or_404(Article)
    return render_to_response(
        'articles/index.html',
        {"articles": articles},
        context_instance=RequestContext(request),
        mimetype="application/xhtml+xml")

def article(request, article_id):
    article = get_object_or_404(Article, pk=article_id)
    return render_to_response(
        'articles/article.html',
        {"article": article},
        context_instance=RequestContext(request),
        mimetype="application/xhtml+xml")

模型

from django.db import models
from django.contrib.auth.models import User

import datetime

class Article(models.Model):
    """
    Article model
    """

    title = models.CharField(blank=True, max_length=200)
    slug = models.SlugField()
    body = models.TextField(blank=True)

    created = models.DateTimeField(blank=True, default=datetime.datetime.now)

    author = models.ForeignKey(User)

    def __unicode__(self):
            return "%s" % (self.title)

    @property
    def handle(self):
        return self.slug

网址

from django.conf.urls.defaults import *

urlpatterns = patterns('',
    url(
        r'^$', 
        'articles.views.index',
        name="articles_index"
    ),
    url(
        r'^article/(?P<article_id>\d*)$',
        'articles.views.article',   
        name="article_view",
    ),
)

root urls

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

from settings import PROJECT_ROOT

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

urlpatterns += patterns('',
    (r'^articles/', include('articles.urls')),
)

urlpatterns += patterns('',
    (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': PROJECT_ROOT + "/media"}),
)

你需要看更多吗?

我有一个理论认为“文章”这个词可能与某些东西发生了冲突,我试图将其重命名为无效。

这应该只是我正在学习的一个“玩app”。但是现在我很困惑。

正在运行:python manage.py runserver_plus

http://127.0.0.1:8000/admin(观看效果​​正常) http://127.0.0.1:8000/articles(每次都崩溃python)

相当拔毛练习...非常感谢

修改

错误报告:

http://dpaste.org/8Fzx/

谢谢!

1 个答案:

答案 0 :(得分:1)

答案:自我引用模板!