35👍
This is because the django rest framework’s Serializer doesn’t have a TextField. Where your model has a TextField you need to use a CharField in the serializer.
CharField A text representation. Optionally validates the text to be
shorter than max_length and longer than min_length.Corresponds to
django.db.models.fields.CharField
or
django.db.models.fields.TextField
.
The documentation isn’t as clear about BigIntegerFields
from models, but this line for the source code shows that IntegerField is again what you have to use in the serializer.
5👍
For text field you can follow the following convention
your_variable_name = serializers.CharField(style={'base_template': 'textarea.html'})
Suggested in rest framework documentation.
1👍
Replace TextField
with CharField
. Both have basically the same functionality, but serializers understand only the later.
- Django 1.6: How to access static files in view
- How to import my django app's models from command-line?
- Django queryset __contains case sensitive?
- Django 'resolve' : get the url name instead of the view_function