I\'m going to deploy my django application on DigitalOcean. Everything gone well, except following error, and my question is: where can I find source of this error, actually in
Please Delete your recentally created migrations file then run python manage.py makemigrations and python manage.py migrate. I think your problem going to solve.Please try it now.
I also face this problem many times, i Just simply delete all the migration files in my project except the init.py file. Then run 'python manage.py makemigrations' and then 'python manage.py migrate' thats it...
I had the same problem with simple CBV like TemplateView or ListView which does not require mandatory parameter. I'm pretty sure the issue comes from the url interpretation. For a simple ListView like
class ProfileList(generic.ListView):
model = get_user_model()
The url
path('profile_list/dummy', ProfileList.as_view(), name='profile_lv'),
works, whereas the one below, doesn't, the error: Field 'id' expected a number but got 'profile_lv' is thrown. Where profile_lv is the name of the url...
path('profile_list', ProfileList.as_view(), name='profile_lv'),
The addition of anything with a slash(/) after the path works?!...
Just to share the solution that worked with my similar error that been received: In my case, this same error was received because I was creating the model instant with the fields values directly, without specifying the field name, so always the ID was taking the first one as default (ID=field1). The problem solved by adding the attributes name as well to the Instant creation.
Was:
model_instant = YourModel(field1, field2,...etc)
Solved by:
model_instant = YourModel(field1 = field1, field2 = field2,...etc)
Do this then follow what been recommended above of 1) deleting the dB file, and 2) delete the migrations then 3) do the makemigrations your_app_name then 4) migrations, then 5) run the server and you should be good to go.
Just delete all the migration files except the init python file the run python manage.py makemigrations then python manage.py migrate
The problem was in migration files. I just opened and changed default value from string type to integer.