Skip to content

Error and Warning on Django V3.2 on Custom User Model Migrations #54

@ibnshayed

Description

@ibnshayed

According to github's REAEME.md

On Custom User Model

created_by = CurrentUserField()
updated_by = CurrentUserField(on_update=True)

it gives me this error

$ py manage.py makemigrations
SystemCheckError: System check identified some issues:

ERRORS:
authentication.User.created_by: (fields.E304) Reverse accessor for 'authentication.User.created_by' clashes with reverse accessor for 'authentication.User.updated_by'.
        HINT: Add or change a related_name argument to the definition for 'authentication.User.created_by' or 'authentication.User.updated_by'.
authentication.User.updated_by: (fields.E304) Reverse accessor for 'authentication.User.updated_by' clashes with reverse accessor for 'authentication.User.created_by'.
        HINT: Add or change a related_name argument to the definition for 'authentication.User.updated_by' or 'authentication.User.created_by'.

Then I Try to Solve like the following

created_by = CurrentUserField(related_name="+")
updated_by = CurrentUserField(on_update=True, related_name="+")

Then it gives me following warning

$ py manage.py makemigrations
E:\django\venv\lib\site-packages\django_currentuser\db\models\fields.py:57: UserWarning: You passed 
an argument to CurrentUserField that will be ignored. Avoid args and following kwargs: default, null, to.       
  warnings.warn(self.warning)
Migrations for 'authentication':
  authentication\migrations\0001_initial.py
    - Create model User
    - Create model Permission
    - Create model Role
    - Add field role to user
    - Add field updated_by to user

Please help me to fix this warning and errors

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