Django: invalid literal for int() with base 10

后端 未结 6 738
时光说笑
时光说笑 2020-12-15 03:14

I am new to Django and trying to pass an author\'s name to a view and filter out quote objects based on the author\'s name. here are the codes:

models.py

<         


        
6条回答
  •  醉梦人生
    2020-12-15 03:27

    I faced this issue and I figured out that I made records in the DB table that in your case is (Quote) before making the foreign key relationship with (Author) then after making the foreign key relationship Django doesn't know what to do to handle the old data in Quote model (to which records in Author should old records be assigned to)

    --> The simplest solution is to:

    delete your old Quote records: Quote.objects.all().delete inside your shell

    recreate and reassign its new records correctly

    makemigrations, migrate and runserver ... done

提交回复
热议问题