我在堆栈溢出上发现了很多关于这些的问题。但检查一下。我想我对这些没有错但是,它不工作。。。。。在
树。根是我的博客
|____airticle
| |______init__.py
| |______init__.pyc
| |____admin.py
| |____admin.pyc
| |____migrations
| | |____0001_initial.py
| | |____0001_initial.pyc
| | |______init__.py
| | |______init__.pyc
| |____models.py
| |____models.pyc
| |____tests.py
| |____views.py
|____db.sqlite3
|____manage.py
|____my_blog
| |______init__.py
| |______init__.pyc
| |____settings.py
| |____settings.pyc
| |____urls.py
| |____urls.pyc
| |____wsgi.py
| |____wsgi.pyc
上面的每个目录
和设置安装应用程序
模型
# -*- coding: utf-8 -*-
from django.db import models
# Create your models here.
class Article(models.Model):
title = models.CharField(max_length=100) ##博客题目
category = models.CharField(max_length=50,blank=True)#博客标签
date_time = models.DateTimeField(blank=True,null=True)#博客正文
def __unicode__(self):
return selft.title
class Meta:#按时间下降排序
ordering = ['-data_time']
模型可以创建数据库和表 但当我进入pythonshell,并输入 从文章模型导入文章。我只是得到一个错误“没有模块命名文章.模型““
我使用django1.8和python2.7
您只是拼错了python模块名。尝试
from airticle import models
。在相关问题 更多 >
编程相关推荐