Skip to content

Commit

Permalink
add superuser
Browse files Browse the repository at this point in the history
  • Loading branch information
michelebswm committed Oct 10, 2023
1 parent 20db8df commit 4c13890
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions filme/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,15 @@
class FilmeConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'filme'

def ready(self):
from .models import Usuario
import os

email = os.getenv('EMAIL_ADMIN')
senha = os.getenv('SENHA_ADMIN')

usuarios = Usuario.objects.filter(email=email)
if not usuarios:
Usuario.objects.create_superuser(
username="admin", email=email, password=senha, is_active=True, is_staff=True)

0 comments on commit 4c13890

Please sign in to comment.