Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Help: AttributeError: 'module' object has no attribute 'Charfield'

Tags:

python

django

I have seen several similar posts of other attributes found but not this. New to Python and Django- I've done the first part of the several tutorials including Django's "Polls" tutorial and when it gets to the point where I syncdb for my app I invariably get 'AttributeError: 'module' object has no attribute CharField.

In models I have copied exactly as the tutorial says:

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 = models.CharField(max_length=200)
    votes = models.IntegerField()
# Create your models here.

'polls' is also added to installed apps and I'm using sqlite3, windows 7, python 2.7.

Any help very appreciated! (I'm trying very hard to learn!)

like image 386
user1475955 Avatar asked Jun 22 '12 21:06

user1475955


2 Answers

That is CharField, with uppercase 'f', and not Charfield as in your code.

like image 52
kosii Avatar answered Nov 02 '22 23:11

kosii


I think in forms.py you are using

from django.forms import forms

Please use this

from django import forms
like image 11
Nids Barthwal Avatar answered Nov 02 '22 21:11

Nids Barthwal