So you’re working through creating some models and you attempt to make migrations when you’re done but you get the following error or something similar:
File "/home/dan/Documents/djlab/mysite/polls/models.py", line 5, in <module> class Question(models.Model): File "/home/dan/Documents/djlab/mysite/polls/models.py", line 6, in Question question_text = models.Charfield(max_length=200) AttributeError: 'module' object has no attribute 'Charfield'
This error can happen with any number of attributes. You’ll get this error when the attribute you are trying to use is not spelled correctly. Keep in mind the attributes are Case Sensitive! In my case, I forgot to update the F in CharField. I ran the migrations again with the following code and it worked just fine:
from django.db import models # Create your models here. class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): question = models.ForeignKey(Question) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0)
Hope this helps. Cheers.
Recent Activity