Reputation: 75
i found so many question about these on stack overflow. but check it all .i think i have no fault about these but.its't work.....
tree .root is my_blog
|____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
every catalogs above __ init__.py
and settting install_app
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'airticle',
)
models
# -*- 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']
and models can create the database and table but when i into python shell , and input from article models import Article .i just get a error "No module named article.models"
and i use django1.8 and python 2.7
Upvotes: 1
Views: 1176
Reputation: 9584
You simply misspelled the python module name. Try from airticle import models
.
Upvotes: 1