Skip to content

Using user foreign key to settings.AUTH_USER_MODEL instead of "username" in User_Keys #77

@oussjarrousse

Description

@oussjarrousse

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions