7
You most likely do not have question_text
field in your Question model. You may have deleted it when you added the __str__
method definition.
Check that you have this:
class Question(models.Model):
question_text = models.CharField(max_length=200) # <--- Double check you have this
def __str__(self):
return self.question_text
0
If you are following the Django documentation, then it is some typo at your end. Just redo the model part and run the makemigration and migrate cmd. It should work.
I faced the same issue and then I just copied and pasted the code from Django documentation and it worked.
- [Django]-Django.core.exceptions.FieldError: Unknown field(s) (y, b, d, o)
- [Django]-Internationalizing images in django
- [Django]-Django message once logged in
- [Django]-Django admin model add_view: how to remove "save and add another" buttons?
- [Django]-Python PIL β background displayed opaque instead of transparent
- [Django]-DRF β ModelSerializer with a non-model write_only field
- [Django]-Django not working with supervisor, getting [Errno 88] Socket operation on non-socket
- [Django]-Free CDN to store my images and css files for django on heroku
0
I was also getting the same problem but then I checked I forget to adddouble inverted comma instead of single _
in __str__
- [Django]-DjangoQ run manage.py qcluster results in PermissionError: [WinError5] Access is denied
- [Django]-Django REST Framework validation error: 'Enter a valid URL.'
- [Django]-Django Humanize naturaltime templatetag only partly translating
- [Django]-Check existing password and reset password
0
Maybe you are getting the error because you donβt have proper indentation. I got the same error when I didnβt have proper indentation. Now itβs correct. Inside the class you should declare the function as following:
class Position(models.Model):
title = models.CharField(max_length=50)
def __str__(self):
return self.title
- [Django]-Django-haystack elasticsearch as backend and searchengine
- [Django]-TypeError: f0() takes 1 positional argument but 9 were given
- [Django]-Queryset for current logged in user Django