Skip to content

law23sum/python_tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Tutorial

The less boilerplate the better.

Quickstart

Prerequisites

To run the app in the recommended configuration, you will need the following installed:

On Windows, you will also need to install make, which you can do by following these instructions.

Initial setup

Run the following command to initialize your application:

make init

This will:

  • Build and run your Postgres database
  • Build and run your Redis database
  • Run your database migrations
  • Install front end dependencies

Then you can start the app:

make dev

This will run your Django server and build and run your front end (JavaScript and CSS) pipeline.

Your app should now be running! You can open it at localhost:8000.

If you're just getting started, try these steps next.

Using the Makefile

You can run make to see other helper functions, and you can view the source of the file in case you need to run any specific commands.

Installation - Native

You can also install/run the app directly on your OS using the instructions below.

You can setup a virtual environment and install dependencies in a single command with:

uv sync

This will create your virtual environment in the .venv directory of your project root.

Set up database

If you are using Docker you can skip these steps.

Create a database named python_tutorial.

createdb python_tutorial

Create database migrations:

uv run manage.py makemigrations

Create database tables:

uv run manage.py migrate

Running server

uv run manage.py runserver

Building front-end

To build JavaScript and CSS files, first install npm packages:

npm install

Then build (and watch for changes locally):

npm run dev

Running Celery

Celery can be used to run background tasks.

Celery requires Redis as a message broker, so make sure it is installed and running.

You can run it using:

celery -A python_tutorial worker -l INFO --pool=solo

Or with celery beat (for scheduled tasks):

celery -A python_tutorial worker -l INFO -B --pool=solo

Note: Using the solo pool is recommended for development but not for production.

Updating translations

Using make:

make translations

Native:

uv run manage.py makemessages --all --ignore node_modules --ignore .venv
uv run manage.py makemessages -d djangojs --all --ignore node_modules --ignore .venv
uv run manage.py compilemessages --ignore .venv

Google Authentication Setup

To setup Google Authentication, follow the instructions here.

Github Authentication Setup

To setup Github Authentication, follow the instructions here.

Installing Git commit hooks

To install the Git commit hooks run the following:

uv run pre-commit install --install-hooks

Once these are installed they will be run on every commit.

For more information see the docs.

Running Tests

To run tests:

Using make:

make test

Native:

uv run manage.py test

Or to test a specific app/module:

Using make:

make test ARGS='apps.web.tests.test_basic_views --keepdb'

Native:

uv run manage.py test apps.web.tests.test_basic_views --keepdb

On Linux-based systems you can watch for changes using the following:

find . -name '*.py' | entr uv run manage.py test apps.web.tests.test_basic_views

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •