target
You need to change the original mandatory field to non mandatory
realization
First, update the fields in models, and add null = true, default = none, blank = true
1 2 |
name = CharField(max_length=64, verbose_name='name', null=True, default=None, blank=True) account = CharField(max_length=64, verbose_name='account', null=True, default=None, blank=True) |
serializers update
1 2 |
name = CharField(required=False) account = CharField(required=False) |
execute python manage.py makemigrations
execute python manage.py migrate
Error:
May appear this error:
1 |
This field may not be null. |
or
1 |
This field cannot be blank. |
Solution:
You need to change serializers to this
1 2 |
name = CharField(required=False, allow_blank=True, allow_null=True) account = CharField(required=False, allow_blank=True, allow_null=True) |
allow_blank=True
to solve This field cannot be blank.
allow_null=True
to solve This field may not be null.
Similar Posts:
- How to Solve Django Error: No such column: xxx
- python Warning: OverflowError: Python int too large to convert to C long
- Python TypeError: __init__() missing 1 required positional argument: ‘on_delete’
- Linux Implement Django Error: nohup: ignoring input and appending output to ‘nohup.out’
- SQL Error: 1064, SQLState: 42000 [Three Methods to Solve]
- Error in importing excel file from SQL Server
- Leet code 44 wildcard matching – wildcard matching – Java
- How to Solve Error: [Errno 11001] getaddrinfo failed
- [Solved] You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for…
- Solution of data truncated for column ‘xxx’ in MySQL