django-components/sampleproject
Juro Oravec ccf02fa316
chore: util to manage URLs in the codebase (#1179)
* chore: util to manage URLs in the codebase

* docs: mentiion validate_links and supported_versions in docs

* refactor: fix linter errors
2025-05-11 14:59:34 +02:00
..
calendarapp Replace all instances of component_block with component. Remove duplicate tests. 2024-02-21 22:38:06 +01:00
components refactor: Update docs and tests to use get_template_data() (#1161) 2025-05-03 12:04:10 +02:00
sampleproject chore: util to manage URLs in the codebase (#1179) 2025-05-11 14:59:34 +02:00
.gitignore refactor: usage notes + tests for safer_staticfiles (#538) 2024-07-08 07:25:03 +02:00
manage.py Introduce a sample project to illustrate setup. 2022-07-17 09:29:15 +02:00
README.md refactor: Remove safer_staticfiles, replace STATICFILES_DIRS with COMPONENTS.dirs, support [app]/components (#652) 2024-09-11 08:45:55 +02:00
requirements.txt refactor: usage notes + tests for safer_staticfiles (#538) 2024-07-08 07:25:03 +02:00

Sample Django project with django_components

Installation

  1. Prepare virtual environment:

    python -m venv .venv
    source .venv/bin/activate
    
  2. Install dependencies:

    pip install -r requirements.txt
    

Development server

python manage.py runserver

The app will be available at http://localhost:8000/.

Serving static files

Assuming that you're running the dev server with DEBUG=True setting, ALL static files (JS/CSS/HTML/PY) will be accessible under the /static/ URL path.

Production server

  1. Prepare static files

    python manage.py collectstatic
    
  2. Set DEBUG = False in settings.py.

  3. Start server with gunicorn

    gunicorn sampleproject.wsgi:application
    

The app will be available at http://localhost:8000/.

Serving static files

This project uses WhiteNoise to configure Django to serve static files even for production environment.

Assuming that you're running the prod server with:

  1. DEBUG = False setting
  2. "django.contrib.staticfiles" in the INSTALLED_APPS

Then Django will server only JS and CSS files under the /static/ URL path.

You can verify that this is true by starting the prod server and then navigating to: