I am configuring django on CentOS. i have made a project using command
django-admin.py startproject mysite
then i made an app using commad
python manage.py startapp polls
in models i have two classes the code is given below which i have taken form dajgo’s official site
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField()
i have django.wsgi placed in /var/www folder. its code is
import os, sys
sys.path.append('/var/www/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
i have also placed the mysite directory in /var/www/ folder but to no avail
Now when i try to import models in python
from polls import Poll, Choice
it give errors such as
File "<stdin>", line 1, in <module>
File "polls/models.py", line 1, in <module>
from django.db import models
Does anybody know whats the issue???
1.edit your import statement to look like this:
2.be happy.