This repository demonstrates how to limit content types in Django model (ORM).
For more information check out the post.
-
Fork/Clone
-
Create and activate a virtual environment:
$ python3 -m venv venv && source venv/bin/activate
-
Install the requirements:
(venv)$ pip install -r requirements.txt
-
Apply the migrations:
(venv)$ python manage.py migrate
-
Create a superuser and populate the database by loading the fixture:
(venv)$ python manage.py createsuperuser (venv)$ python manage.py loaddata ./dealership/fixtures/initial_data.json
-
Run the server:
(venv)$ python manage.py runserver
-
Navigate to http://localhost:8000/admin in your favorite browser. The content type in
Sale
model should be limited toCar
,ElectricCar
, andMotorcycle
.