GastroMóvil replaces Django’s built-inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/lffiesco-svg/gastromovil/llms.txt
Use this file to discover all available pages before exploring further.
User model with a custom Usuario model that adds a rol field, a unique email field used for authentication, and an optional telefono field. Every registered account belongs to one of three roles — cliente, restaurante, or repartidor — and the application automatically enforces different permissions, redirects, and side-effects based on that role.
The Usuario Model
The Usuario model extends AbstractUser and lives in usuarios/models.py. The key fields added on top of Django’s defaults are:
AUTH_USER_MODEL = 'usuarios.Usuario' is set in settings.py, so all Django internals (admin, request.user, foreign keys) reference this model throughout the project.Automatic is_staff Promotion
Every time a Usuario instance is saved, the save() method checks the rol value and adjusts is_staff automatically:
Auto-Creating a Restaurante on Registration
When a Usuario with rol='restaurante' is saved for the first time, a post_save signal creates a linked Restaurante object so the owner already has a panel to manage:
Authentication
Email-Based Login
Users authenticate with their email address, not their username. A customEmailBackend (referenced in AUTHENTICATION_BACKENDS) looks up the Usuario by email and delegates to Django’s standard password check. The login view itself performs the same lookup:
Role-Based Redirects After Login
After a successful login the view routes each role to its dedicated dashboard:Superuser
Full Django admin at
/admin/ — powered by Jazzmin.Restaurant Owner
JS-powered management panel at
/panel-restaurante/ to handle menus, orders, and restaurant settings.Delivery Driver
Driver dashboard at
/panel-repartidor/ showing pending pickups, in-transit orders, and deliveries completed today.Google OAuth (django-allauth)
Social login is handled bydjango-allauth with the Google provider. A CustomSocialAccountAdapter in gastromovil/adapters.py ensures every OAuth user is always created with rol='cliente':
The adapter also derives
username from the email prefix when the OAuth provider does not supply one.Registration Flow
New clients register through a two-step process that verifies their email before creating the account.Fill the Registration Form
The user submits their first name, last name, email, phone, and password via
POST /registro/. The view validates the form, stores the data in the session, and generates a random 6-digit verification code.Receive the Verification Email
The code is emailed via the Resend API from
noreply@gastromovil.online. The email is built with custom HTML helpers (codigo_box, parrafo, nota) and notes that the code expires in 10 minutes.Password Recovery
Request a Code
The user visits
/recuperar/ and submits their registered email address. The server creates a CodigoRecuperacion record (valid for 10 minutes) and emails the 6-digit code via Resend.Verify the Code
On
POST /verificar-codigo/, the view checks the code against the stored record and calls is_expired() to enforce the 10-minute window.CodigoRecuperacion model:
Session Configuration
Sessions are configured to be short-lived and automatically expired when the browser closes:Delivery Addresses (Direccion)
Authenticated users can maintain multiple saved addresses. When an order is placed, the selected address is geocoded via the Google Maps Geocoding API and the resulting coordinates are written back to the Direccion record.
Order Ratings (Calificacion)
After an order reaches the entregado state, the customer can leave a 1–5 star rating with an optional comment:
OneToOneField).