-
Notifications
You must be signed in to change notification settings - Fork 26
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
How to configure Auth, compains about INSTALLED_APPS
#34
Comments
I think this is related to the import order issue mentioned in troubleshooting - I should update that to be clearer. Django doesn't like us putting everything in one file, so nanodjango has to use some trickery to get models to work. This is applied when you do However, in this specific case you could probably remove the |
hey not the same error but related i'm trying to configure a nanodjango app with custom user so i can use django login/logout/auth stuff with my custom model, but cant make it work here is the code: import uuid
from pathlib import Path
from nanodjango import Django
from django.shortcuts import render
from django.db import models
from django.utils import timezone
from decouple import config
from dotenv import load_dotenv
load_dotenv()
BASE_DIR = Path(__file__).resolve().parent
DB_DIR = BASE_DIR / "db"
DEBUG = config("DEBUG", cast=bool)
SECRET_KEY = config("SECRET_KEY")
app = Django(
SECRET_KEY=SECRET_KEY,
DEBUG=DEBUG,
ADMIN_URL="admin/",
AUTH_USER_MODEL="???.User",
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": DB_DIR / "db.sqlite3",
"OPTIONS": {
"init_command": "PRAGMA journal_mode=WAL;PRAGMA synchronous=NORMAL;",
"transaction_mode": "IMMEDIATE",
},
}
},
STATICFILES_DIRS=[
BASE_DIR / "static",
],
AUTH_PASSWORD_VALIDATORS=[],
)
# This needs to be imported after the Django app is created
from django.contrib.auth.models import (
AbstractBaseUser,
PermissionsMixin,
)
class User(AbstractBaseUser, PermissionsMixin):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
email = models.EmailField(unique=True)
password = models.CharField(max_length=128)
datetime_joined = models.DateTimeField(default=timezone.now)
last_login = models.DateTimeField(blank=True, null=True)
is_active = models.BooleanField(default=True)
is_superuser = models.BooleanField(default=False)
is_staff = models.BooleanField(default=False)
verified_email = models.BooleanField(default=False)
full_name = models.CharField(max_length=255, blank=True, null=True)
birth_date = models.DateField(blank=True, null=True)
USERNAME_FIELD = "email"
REQUIRED_FIELDS = []
class Meta:
db_table = "users"
@app.route("/")
def home_view(request):
return render(request, "home.html")
if __name__ == "__main__":
app.run() i wrote ???.User because i dont know what to write for the app |
Nanodjango uses the filename as the name of the app, so if your file is Hope that helps! |
hey! my file is app.py so i wrote AUTH_USER_MODEL="app.User" getting this error: |
I am trying to run the following app.
However, when I run it I stumble on this issue:
When I remove the
user
key on theAPIKey
object and also remove the associated import then it does seem to work though.The text was updated successfully, but these errors were encountered: