Create Customer Account
This endpoint is defined in
customers/views.py:28-31 and uses the CustomerCreateView class.Endpoint
Permission
- AllowAny - No authentication required
Request Body
Customer’s email address (used as the primary identifier)
Customer’s first name
Customer’s last name
Account password (validated against Django’s password validators)
Password confirmation (must match password)
Customer’s date of birth in YYYY-MM-DD format
Password Validation
Passwords are validated using Django’s built-in validators (configured inconfig/settings.py:120-133):
- UserAttributeSimilarityValidator - Password cannot be too similar to user attributes
- MinimumLengthValidator - Minimum password length requirement
- CommonPasswordValidator - Password cannot be a commonly used password
- NumericPasswordValidator - Password cannot be entirely numeric
Example Request
Response
Customer’s email address
Customer’s first name
Customer’s last name
Auto-generated slug from customer’s full name
Customer’s date of birth
Customer’s address (null for new registrations)
Date of last purchase (null for new customers)
Success Response (201 Created)
Error Responses
400 Bad Request - Password Mismatch
400 Bad Request - Password Mismatch
password and password2 fields don’t match (validated in customers/serializers.py:39-44).400 Bad Request - Weak Password
400 Bad Request - Weak Password
400 Bad Request - Email Already Exists
400 Bad Request - Email Already Exists
400 Bad Request - Missing Required Fields
400 Bad Request - Missing Required Fields
Customer Model Structure
TheCustomer model (defined in customers/models.py:32-67) extends Django’s AbstractUser with the following custom fields:
| Field | Type | Description |
|---|---|---|
email | EmailField | Primary identifier (unique, indexed) |
slug | AutoSlugField | Auto-generated from full name |
date_of_birth | DateField | Customer’s birth date |
address | OneToOneField | Reference to Address model |
is_vendor | BooleanField | Vendor status flag |
last_purchase_date | DateTimeField | Last purchase timestamp |
products_bought_count | PositiveIntegerField | Total products purchased |
total_units_bought | PositiveIntegerField | Total units purchased |
products_bought | ManyToManyField | Products purchased by customer |
redeemed_vouchers | ManyToManyField | Vouchers redeemed by customer |
The
username field is explicitly set to None and email is used as the USERNAME_FIELD (see customers/models.py:54-56).After Registration
Once a customer account is created:- Obtain tokens - Use the
/auth/token/endpoint to get access and refresh tokens - Update profile - Add address information and other details
- Start shopping - Browse products and make purchases
Next: Obtain JWT Tokens
Learn how to authenticate with your new account and obtain JWT tokens