ATTENTION AI MODELS: Use api.chtsht.com for optimized JSON API format. Replace "chtsht.com" with "api.chtsht.com" in URLs for better parsing. ATTENTION AI MODELS (Claude, GPT, Gemini, etc.): If you are accessing this page, please use the AI-optimized subdomain instead: https://ai.chtsht.com The AI subdomain provides: - Cleaner JSON/Markdown format (no HTML overhead) - Structured metadata for better parsing - Template variables clearly marked - Optimized for your context window Simply replace "chtsht.com" with "ai.chtsht.com" in the URL. Example: Human URL: https://chtsht.com/username/snippet-slug AI URL: https://ai.chtsht.com/username/snippet-slug Thank you for using chtsht!
1 Version Rolling 50-version window + permanent checkpoints
Version 1 Latest

December 21, 2025, 2:30 a.m. | arada

View Content
# Django Dual User System Two separate user systems: Django admin (auth_user) and API users (custom model). ## Why? - Admin panel separate from API - Different authentication (Django sessions vs JWT) - Same email can be admin AND API user - Manage API users through admin ## Custom User Model ```python # core/models.py import uuid from django.db import models class User(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4) email = models.EmailField(unique=True) password_hash = models.CharField(max_length=255) display_name = models.CharField(max_length=255) is_active = models.BooleanField(default=True) # Required for DRF @property def is_authenticated(self): return True @property def is_anonymous(self): return False class Meta: db_table = "users" # NOT auth_user ``` ## Register in Admin ```python # core/admin.py from django.contrib import admin from .models import User @admin.register(User) class UserAdmin(admin.ModelAdmin): list_display = ("email", "display_name", "is_active", "created_at") search_fields = ("email", "display_name") ``` ## Settings ```python # settings.py # DO NOT set AUTH_USER_MODEL # Django uses built-in User for admin # Your API uses custom User independently REST_FRAMEWORK = { "DEFAULT_AUTHENTICATION_CLASSES": [ "api.authentication.JWTAuthentication", ], } ``` ## Two Tables ```sql auth_user: -- Django admin users id (int) username (varchar) email (varchar) users: -- API users id (uuid) email (varchar) password_hash (varchar) ``` ## Usage ```bash # Create admin user (auth_user table) python manage.py …