我正在开发一个django教程,创建一个博客,我在django管理面板中看到新应用时遇到了问题。 http://tutorial.djangogirls.org/en/django_models/index.html
我来回看了看,我似乎无法找到我做错的事。任何帮助将不胜感激。以下是我到目前为止的情况。
from django.db import models
from django.utils import timezone
class Post(models.Model):
author = models.ForeignKey('auth.User')
title = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(
default=timezone.now)
published_date = models.DateTimeField(
blank=True, null=True)
def publish(self):
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title
from django.apps import AppConfig
class BlogConfig(AppConfig):
name = 'blog'
from django.contrib import admin
from .models import Post
admin.site.register(Post)
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
]
然后这就是我在终端中所拥有的。
Migrations for 'blog':
0001_initial.py:
- Create model Post
(project1) michaels-mbp-2:project1 michaelp$ python manage.py migrate blog
Operations to perform:
Apply all migrations: blog
Running migrations:
Rendering model states... DONE
Applying blog.0001_initial... OK