OpenClassrooms Python Developer Project #12: Develop a Secure Back-End Architecture Using Django ORM
Tested on Windows 10 - Python 3.9.5 - Django 4.1 - DRF 3.13.1
API-EpicEvents is a Customer Relationship Management (CRM) API designed for Epic Events, an events management company.
Epic Events users can:
- Create and update a client database
- Create and manage contracts and organise related events
The RESTful API is implemented with a secured database built with Django ORM and PostgreSQL.
Note: Postman docs are currently only available in French , English version coming soon.
This project has been optimised after the end of the OpenClassrooms course. To view the previously delivered version, please check this commit.
Improvements made to this project include:
- Adding a Team model
- Providing custom management commands to create dummy data
- Optimising test coverage
- Improving the admin site interface with Jazzmin
- Implementing a CI workflow for automating tests
- General project refactoring
git clone https://github.com/hmignon/P12_mignon_helene.git
cd P12_mignon_helene
python -m venv env
env\Scripts\activate
pip install -r requirements.txt
git clone https://github.com/hmignon/P12_mignon_helene.git
cd P12_mignon_helene
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
Install PostgreSQL. Follow the documentation to run the server.
Create a new PostgreSQL database with SQL shell (psql) : CREATE DATABASE your_db_name;
To generate a .env file, run python create_dot_env.py
and input the info required.
Example of a generated .env file:
SECRET_KEY=j%yuc7l_wwz5t8d=g)zxh6ol@$7*lwx6n0p)(k$dewlr0hf2u-
DATABASE_NAME=your_db_name
DATABASE_USER=your_db_user
DATABASE_PASS=your_db_password
The Django secret key is randomly generated.
To migrate, run python manage.py migrate
. The 3 user teams (manager, sales, support) are
automatically created; to learn more about user teams and their permissions,
check the API docs.
Run python manage.py create superuser
. Superusers are automatically added to the management team,
and have access to the admin site.
Run the following commands prefixed with python manage.py
to create some dummy data:
Command | Description |
---|---|
create_data |
Create a set of all objects (15 users, 50 clients, 20 contracts, 10 events). No extra args. |
create_users |
Create a set of users. Args: -n or --number (default: 15). |
create_clients |
Create a set of clients. Args: -n or --number (default: 50). |
create_contracts |
Create a set of contracts. Args: -n or --number (default: 20). |
create_events |
Create a set of clients. Args: -n or --number (default: 10). Note: Events are exclusively related to one signed contract (one to one rel); the command will create as many events as possible if the amount provided is higher than available contracts. |
Run the server with python manage.py runserver
. The CRM is browsable via:
Note : CRM access to managers and admins is read-only. Creating, updating and deleting elements is available in the admin site.
Tha admin site is available at http://127.0.0.1:8000/admin/. Admin site access is granted to managers and superusers.
For a better user experience, the admin interface is customized and jazzed up with Jazzmin.
Run tests locally with python manage.py test
.
Check test coverage with coverage run --source='.' manage.py test
and coverage report
.
Latest coverage report:
All app errors are logged in to errors.log
.