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

Creating Superuser fails on a fresh install #2204

Open
Keridos opened this issue May 29, 2024 · 5 comments
Open

Creating Superuser fails on a fresh install #2204

Keridos opened this issue May 29, 2024 · 5 comments
Labels
[C] Backend Focuses on backend implementation [P] Medium Medium priority [T] Refactoring Existing parts should become faster, more readable, or in any other way better.

Comments

@Keridos
Copy link

Keridos commented May 29, 2024

Using docker provider. Start up a fresh docker instance via Vagrant. Try the create superuser command.
It asks for login email and password. Enter credentials. It then crashes due to the postgresql having a constraint that first name of a user must not be null.

@janno42
Copy link
Member

janno42 commented May 29, 2024

Will look into that. Please use the "evap" user as described in step 3 of the installation section in the readme for now: https://github.com/e-valuation/EvaP?tab=readme-ov-file#installation-for-development

@Kakadus
Copy link
Collaborator

Kakadus commented May 30, 2024

I also noticed the problem after loading custom data which did not have a superuser.

@richardebeling pointed out that REQUIRED_FIELDS should fix it 👍

@richardebeling
Copy link
Member

@Keridos do you want to open a pull request that adds the first_name and last_name fields to the REQUIRED_FIELDS class attribute? I would appreciate it! :)

The relevant lines should be

def create_superuser(self, *, email, password=None, first_name=None, last_name=None):

and
REQUIRED_FIELDS = []

@Keridos
Copy link
Author

Keridos commented May 30, 2024

As I got no experience with django projects I have a question there: I can add the fields first_name_given and last_name to the required fields. But does django know that when calling create_superuser that first_name is actually passed from first_name_given?. The variable names in there are a bit confusing.

@richardebeling
Copy link
Member

Ah, good point, I think we didn't handle that the way django intends in #1903 (see the change here).

My understanding of the django docs on custom user profile managers is that the argument for create_user and create_superuser probably should also be renamed from first_name to first_name_given. Then, I'd expect that having first_name_given in the REQUIRED_FIELDS works.

(background information regarding the variable naming: Since #1903, we distinguish between first_name_given, the first name that the person legally has and may not have control over, and first_name_chosen, the preferred first name that the person would like to be addressed by)

@janno42 janno42 added [C] Backend Focuses on backend implementation [P] Medium Medium priority [T] Refactoring Existing parts should become faster, more readable, or in any other way better. labels Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Backend Focuses on backend implementation [P] Medium Medium priority [T] Refactoring Existing parts should become faster, more readable, or in any other way better.
Development

No branches or pull requests

4 participants