Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ibnshayed opened this issue Jun 24, 2021 · 1 comment
Open

Comments

@ibnshayed
Copy link

ibnshayed commented Jun 24, 2021

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

@ShmuelTreiger
Copy link

Same issue. Can safely ignore for now, since it's just a warning. Commenting to Follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants