You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the User_Keys model in models.py, uses username=models.CharField(max_length = 50).
This could be problematic in case the django app allows for changing the username for example. Also deleting a user will not result in deleting entries for that user in the User_Keys model in the database.
The mainstream approach is to use:
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
The request in django view functions already have request.user variable that can be used directly when CRUD an entry in the User_Keys table.
Nonetheless, changing the data model will require a lot of refactoring.
The text was updated successfully, but these errors were encountered:
Currently the User_Keys model in models.py, uses
username=models.CharField(max_length = 50)
.This could be problematic in case the django app allows for changing the
username
for example. Also deleting a user will not result in deleting entries for that user in the User_Keys model in the database.The mainstream approach is to use:
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
The
request
in django view functions already haverequest.user
variable that can be used directly when CRUD an entry in the User_Keys table.Nonetheless, changing the data model will require a lot of refactoring.
The text was updated successfully, but these errors were encountered: