7👍
✅
The problem was ForeignKey in Django 1.9 required 1 positional argument in Django 2.0 ForeignKey 2 required positional argument
topic = models.ForeignKey("Topic", on_delete=models.PROTECT)
0👍
The reason of second issue is you missed the command after the command python manage.py makemigrations [appname]
, the missing command is python manage.py migrate
.
- [Django]-Problem rendering a Django form field with different representation
- [Django]-Custom logo in django jet
- [Django]-Django admin raw_id_fields table display
- [Django]-Django Elastic Search: AttributeError: type object 'PostDocument' has no attribute 'Django'
- [Django]-Django-social-auth redirect after login
0👍
To prevent this, we should use on_delete=models.PROTECT
.
By default Django uses on_delete=models.CASCADE
but this is not secure if object deleted accidentally.
In that case there would be no notification of deleted objects so it would be ideal to use models.PROTECT.
- [Django]-Django connect mysql problem, NameError: name '_mysql' is not defined
- [Django]-How to allow others to connect to my Django website?
Source:stackexchange.com