Skip to content

alexandre-petitjean/django-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Playground

Caution

This app is not meant to be used in production, it's just a playground to test Django feature or create POC.

Built with Cookiecutter Django Ruff python Django

License: MIT

Introduction

Features

  • User Authentication with allauth
  • Bootstrap 5
  • Docker
  • Sphinx
  • Sample App: Stock
  • Asynchronous tasks with Celery and RabbitMQ

Technologies and tools used in this project

Dependencies

Asynchronous tasks

Monitoring

  • Flower to monitor celery tasks.
  • Prometheus to monitor the application. To be implemented
  • Grafana to visualize prometheus metrics. To be implemented

Build and run

Code quality

  • pre-commit to run linters and formatters before commiting.

Documentation

  • sphinx to generate documentation.

Usage

This project is intended to be used with Docker and Docker Compose.

docker compose -f compose.local.yaml up

Development

1. Install OS dependencies

Ubuntu

sudo apt-get install -y build-essential curl graphviz graphviz-dev libpq-dev

MacOS

// TODO

2. Create a virtual environment and install dependencies

It's recommended to use a virtual environment to avoid conflicts with other projects.

pyenv install 3.12.5
pyenv virtualenv 3.12.5 django-playground
pyenv local django-playground-3.12.5
poetry install

3. Setting Up Your Users (Optional)

A default superuser is created with the following credentials

Email : admin@admin.local

Password : admin

  • To create a normal user account, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go.

  • To create a superuser account, use this command:

    $ docker compose -f compose.local.yaml run --rm django python manage.py createsuperuser
    

For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.

4. Start the development server

docker compose -f compose.local.yaml up

5. Import data

docker compose -f compose.local.yaml run --rm django python manage.py manage.py loaddata --app=stocks products

6. Access the application

Service URL
Django http://localhost:8000
Flower http://localhost:5555
RabbitMQ http://localhost:15672

Development

Settings

Moved to settings.

See detailed cookiecutter-django Docker documentation.

Import and dump data:

The initial dataset is from https://dummyjson.com/products?

To import the data:

docker compose -f compose.local.yaml run --rm django python manage.py loaddata --app=stocks products```

To dump the data:
```bash
docker compose -f compose.local.yaml run --rm django python manage.py dumpdata stocks.Product -o "django_playground/stocks/fixtures/products.json" --indent 4

Type checks

Running type checks with mypy:

$ mypy django_playground

Test coverage

To run the tests, check your test coverage, and generate an HTML coverage report:

$ coverage run -m pytest
$ coverage html
$ open htmlcov/index.html

Running tests with pytest

$ pytest

See migrations

$ docker compose -f compose.local.yaml run --rm django python manage.py visualizemigrations .graphs/migration.gv

Live reloading and Sass CSS compilation

Moved to Live reloading and SASS compilation.

About

A Playground to test new thing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors