nanodjango


Namenanodjango JSON
Version 0.4.0 PyPI version JSON
download
home_pageNone
SummaryRun Django models and views from a single file, and convert it to a full project.
upload_time2024-04-21 09:50:44
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # nanodjango

[![PyPI](https://img.shields.io/pypi/v/nanodjango.svg)](https://pypi.org/project/nanodjango/)
[![Documentation](https://readthedocs.org/projects/nanodjango/badge/?version=latest)](https://nanodjango.readthedocs.io/en/latest/)
[![Tests](https://github.com/radiac/nanodjango/actions/workflows/ci.yml/badge.svg)](https://github.com/radiac/nanodjango/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/radiac/nanodjango/branch/main/graph/badge.svg?token=BCNM45T6GI)](https://codecov.io/gh/radiac/nanodjango)

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:

```sh
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:

```python

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:

```sh
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:

```sh
gunicorn -w 4 counter:app
```

or automatically convert it to a full Django project:

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

and with a [couple of extra
lines](https://nanodjango.readthedocs.io/en/latest/management.html#run-script), run the
development server as a standalone script using ``python``, or use ``pipx run`` to run
it and automatically install dependencies to a temporary virtual environment:

```sh
# Either
python script.py
# or
pipx run ./script.py
```

For more details, see

* [Getting started](https://nanodjango.readthedocs.io/en/latest/get_started.html)
* [Tutorial](https://nanodjango.readthedocs.io/en/latest/tutorial.html)
* [Full Documentation](https://nanodjango.readthedocs.io/en/latest/index.html)
* [Changelog](https://nanodjango.readthedocs.io/en/latest/changelog.html)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "nanodjango",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "django",
    "author": null,
    "author_email": "Richard Terry <code@radiac.net>",
    "download_url": "https://files.pythonhosted.org/packages/cb/4d/5acedfe1c8b1dce4623a6fa9714b8effe9ca269a819d8b7be180403337bf/nanodjango-0.4.0.tar.gz",
    "platform": null,
    "description": "# nanodjango\n\n[![PyPI](https://img.shields.io/pypi/v/nanodjango.svg)](https://pypi.org/project/nanodjango/)\n[![Documentation](https://readthedocs.org/projects/nanodjango/badge/?version=latest)](https://nanodjango.readthedocs.io/en/latest/)\n[![Tests](https://github.com/radiac/nanodjango/actions/workflows/ci.yml/badge.svg)](https://github.com/radiac/nanodjango/actions/workflows/ci.yml)\n[![Coverage](https://codecov.io/gh/radiac/nanodjango/branch/main/graph/badge.svg?token=BCNM45T6GI)](https://codecov.io/gh/radiac/nanodjango)\n\nWrite a Django site in a single file, using views, models and admin, then automatically\nconvert it to a full Django project when you're ready for it to grow.\n\nPerfect for experiments, prototypes, tutorials, and small applications.\n\n\n## Quickstart\n\n\nInstall nanodjango:\n\n```sh\npip install nanodjango\n```\n\nCreate a file ``counter.py`` using Django's standard features, and the ``@app.route``\nand ``@app.admin`` decorators to tell nanodjango where your URLs, views and model admin\nare:\n\n```python\n\nfrom django.db import models\nfrom nanodjango import Django\n\napp = Django(ADMIN_URL=\"admin/\")\n\n@app.admin\nclass CountLog(models.Model):\n    timestamp = models.DateTimeField(auto_now_add=True)\n\n@app.route(\"/\")\ndef count(request):\n    CountLog.objects.create()\n    return f\"<p>Number of page loads: {CountLog.objects.count()}</p>\"\n```\n\nSave that as ``counter.py``, then set up your database and run it locally with:\n\n```sh\nnanodjango counter.py run makemigrations counter\nnanodjango counter.py run migrate\nnanodjango counter.py run createsuperuser\nnanodjango counter.py run\n```\n\nIt will create your database in a ``db.sqlite3`` file next to your ``counter.py``, with\nthe appropriate migrations in ``migrations/``.\n\nRun it in production using WSGI:\n\n```sh\ngunicorn -w 4 counter:app\n```\n\nor automatically convert it to a full Django project:\n\n```sh\nnanodjango counter.py convert /path/to/project --name=myproject\n```\n\nand with a [couple of extra\nlines](https://nanodjango.readthedocs.io/en/latest/management.html#run-script), run the\ndevelopment server as a standalone script using ``python``, or use ``pipx run`` to run\nit and automatically install dependencies to a temporary virtual environment:\n\n```sh\n# Either\npython script.py\n# or\npipx run ./script.py\n```\n\nFor more details, see\n\n* [Getting started](https://nanodjango.readthedocs.io/en/latest/get_started.html)\n* [Tutorial](https://nanodjango.readthedocs.io/en/latest/tutorial.html)\n* [Full Documentation](https://nanodjango.readthedocs.io/en/latest/index.html)\n* [Changelog](https://nanodjango.readthedocs.io/en/latest/changelog.html)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Run Django models and views from a single file, and convert it to a full project.",
    "version": "0.4.0",
    "project_urls": {
        "Changelog": "https://nanodjango.readthedocs.io/en/latest/changelog.html",
        "Documentation": "https://nanodjango.readthedocs.io/en/latest/",
        "Homepage": "https://radiac.net/projects/nanodjango/",
        "Issues": "https://github.com/radiac/nanodjango/issues",
        "Repository": "https://github.com/radiac/nanodjango"
    },
    "split_keywords": [
        "django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1117522e64017f2300f9a3c2d1d2821ce80540cd48bf7ff005bac7b124c397eb",
                "md5": "39ff0a9a724c28ab898215a5ebf2bedc",
                "sha256": "73f7c68ae1f48d89207e01a5a1b231558a3c5c9ae1ca0c204ecdb173beb4ee87"
            },
            "downloads": -1,
            "filename": "nanodjango-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "39ff0a9a724c28ab898215a5ebf2bedc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 19973,
            "upload_time": "2024-04-21T09:50:42",
            "upload_time_iso_8601": "2024-04-21T09:50:42.988668Z",
            "url": "https://files.pythonhosted.org/packages/11/17/522e64017f2300f9a3c2d1d2821ce80540cd48bf7ff005bac7b124c397eb/nanodjango-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cb4d5acedfe1c8b1dce4623a6fa9714b8effe9ca269a819d8b7be180403337bf",
                "md5": "457a6d99932acfd646ec37a4837a9950",
                "sha256": "62f43eff4c8005842c0a08933a82e1621362676863fce3a871de05bf3bf1af0d"
            },
            "downloads": -1,
            "filename": "nanodjango-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "457a6d99932acfd646ec37a4837a9950",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 17677,
            "upload_time": "2024-04-21T09:50:44",
            "upload_time_iso_8601": "2024-04-21T09:50:44.593499Z",
            "url": "https://files.pythonhosted.org/packages/cb/4d/5acedfe1c8b1dce4623a6fa9714b8effe9ca269a819d8b7be180403337bf/nanodjango-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-21 09:50:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "radiac",
    "github_project": "nanodjango",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "nanodjango"
}
        
Elapsed time: 0.24599s