Skip to main content

Run Django models and views from a single file, and convert it to a full project.

Project description

nanodjango

PyPI Documentation Tests Coverage

Write a Django site in a single file, using views, models and admin, then automatically convert it to a full Django project when you're ready for it to grow.

Perfect for experiments, prototypes, tutorials, and small applications.

Quickstart

Install nanodjango:

pip install nanodjango

Create a file counter.py using Django's standard features, and the @app.route and @app.admin decorators to tell nanodjango where your URLs, views and model admin are:

from django.db import models
from nanodjango import Django

app = Django(ADMIN_URL="admin/")

@app.admin
class CountLog(models.Model):
    timestamp = models.DateTimeField(auto_now_add=True)

@app.route("/")
def count(request):
    CountLog.objects.create()
    return f"<p>Number of page loads: {CountLog.objects.count()}</p>"

Save that as counter.py, then set up your database and run it locally with:

nanodjango counter.py run makemigrations counter
nanodjango counter.py run migrate
nanodjango counter.py run createsuperuser
nanodjango counter.py run

It will create your database in a db.sqlite3 file next to your counter.py, with the appropriate migrations in migrations/.

Run it in production using WSGI:

gunicorn -w 4 counter:app

or convert it to a full Django project:

nanodjango counter.py convert /path/to/project --name=myproject

For more details, see

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nanodjango-0.3.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

nanodjango-0.3.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file nanodjango-0.3.0.tar.gz.

File metadata

  • Download URL: nanodjango-0.3.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.3

File hashes

Hashes for nanodjango-0.3.0.tar.gz
Algorithm Hash digest
SHA256 75f9d0f3ca67fc57bc9c7c83808428322a365689db488bfa6050e3981d3b65da
MD5 99aa8e832a48d301f4f6c3b35b28818a
BLAKE2b-256 e39321dae32c05e9e4c6d19fd785cc3f855ff9808e0f6579c91137aec9c3be4d

See more details on using hashes here.

File details

Details for the file nanodjango-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nanodjango-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.3

File hashes

Hashes for nanodjango-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de3b271fe253e5530a165890fc40ef95bb6f32ec374ff5ccae7bff877b22b472
MD5 02853e1a418d0d6c34660c7da700a1aa
BLAKE2b-256 5fb3df1154265ef027a39f26a75a24a47305356e858f4dfea277ae529a734406

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page