This is the sample code used in the Real Python article How to Write an Installable Django App. The article describes how to take an app from an existing Django project and make it a stand-alone installable package available on PyPI.
Installable App
This app models a list of items on a receipt. Each item has a description and a cost. A receipt may reference multiple items.
This app can be installed and used in your Django project with:
$ pip install realpython-django-receipts
Edit your settings.py file to include ‘receipts’ in the INSTALLED_APPS listing.
INSTALLED_APPS = [
...
'receipts',
]
Edit your project urls.py file to import the URLs:
url_patterns = [
...
path('receipts/', include('receipts.urls')),
]
Finally, add the models to your database:
$ ./manage.py makemigrations receipts
The “before” project
The before folder shows the “before” case – the Django project before the app was made installable.
Docs & Source
Metadata
Release files for realpython-django-receipts 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| realpython_django_receipts-1.1.0.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| realpython_django_receipts-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.8 kB
Release files / realpython_django_receipts-1.1.0.tar.gz
| Download URL | realpython_django_receipts-1.1.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
40bd8e99b1261b523c5bf87e21626acefd030adc4d23d3238e8c863ebdfe3ca3
|
|
BLAKE2b-256 checksum How to use checksums |
95eb3dc56f90b6cf5a144f5916dc5caf29e8e06c17f2e752d2c0d8dfd5618c7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / realpython_django_receipts-1.1.0-py3-none-any.whl
| Download URL | realpython_django_receipts-1.1.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
734a31abc5a99f472be07a7d759596a41c7a2e7e538aa887156cc121d4639a1f
|
|
BLAKE2b-256 checksum How to use checksums |
732aff20388e9546c5f1a99b63dcafacf67a0c7af433bc145c2e6d3276fa04a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|