createsuperuser and how it relates to email-based addresses: document

chaning actual createsuperuser behavior is usually done using the USERNAME_FIELD
but that field has other repurcussions (that we don't want) too
This commit is contained in:
Klaas van Schelven
2024-06-10 16:28:31 +02:00
parent 93b8c892b1
commit 0660701287
2 changed files with 7 additions and 1 deletions

View File

@@ -146,7 +146,8 @@ ls *.sqlite3
You can create a superuser account to access the Bugsink admin interface.
Run the following command and follow the prompts:
Run the following command and follow the prompts (to stay consistent with usernames in the rest of the system, you may
want to use your email-address as a username):
```bash
bugsink-manage createsuperuser

View File

@@ -21,6 +21,11 @@ UserModel = get_user_model()
class UserCreationForm(BaseUserCreationForm):
# Our UserCreationForm is the place where the "use email for usernames" logic is implemented.
# We could instead push such logic in the model, and do it more thoroughly (i.e. remove either field, and point the
# USERNAME_FIELD to the other). But I'm not sure that this is the most future-proof way forward. In particular,
# external systems (AD, OAuth, etc.) may have 2 fields rather than 1.
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['username'].validators = [EmailValidator()]