django-code-generator
Generate code from Django models for faster development. This project can generate a Django Rest Framework API or an admin for your app. You can also create your own templates so you can generate code for whatever you want.
To install django-code-generator, run this command in your terminal:
$ sudo pip install django-code-generator
This is the preferred method to install django-code-generator, as it will always install the most recent stable release. More info in the documentation
Then add it to your INSTALLED_APPS:
INSTALLED_APPS = [
# ...
'django_code_generator',
]
Usage
Generating code is as easy as:
$ python manage.py generator <template> <project app>
This project includes two default templates: admin and api. For example:
$ python manage.py generator admin myapp
Read the documentation for more info.
Create templates
A template is a directory with files that will be copied to the final path in your app. Template files can use Django Templates Syntax. When templates are generated, the app models are available to be used with the django template syntax.
For example if you create the template mytemplate you can use it for your app myapp with the command:
$ python manage.py generate mytemplate myapp
A template file example:
{% load code_generator_tags %}from django.contrib import admin
{% from_module_import app.name|add:'.models' models %}{% comment %}
{% endcomment %}
{% for model in models %}
@admin.register({{ model.name }})
class {{ model.name }}Admin(admin.ModelAdmin):
"""
"""
list_display = (
{% indent_items model.filter_field_names 8 quote='simple' %}
)
search_fields = (
{% indent_items model.char_field_names 8 quote='simple' %}
)
{% if model.foreign_field_names %}autocomplete_fields = (
{% indent_items model.foreign_field_names 8 quote='simple' %}
){% endif %}{% endfor %}
For more information see the docs.
Metadata
Release files for django-code-generator 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-code-generator-0.2.2.tar.gz | 42.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_code_generator-0.2.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 55.2 kB
Release files / django-code-generator-0.2.2.tar.gz
| Download URL | django-code-generator-0.2.2.tar.gz |
|---|---|
| Size | 42.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff3bdada07fe5f8eec39ebd20d4da4055bfb49fee357c0e77b8b1664cfaec3fe
|
|
BLAKE2b-256 checksum How to use checksums |
0b1215c48c6913f3843230a08be91cbf046a87992bb46b64e8fc59551a9d2338
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5
|
Release files / django_code_generator-0.2.2-py2.py3-none-any.whl
| Download URL | django_code_generator-0.2.2-py2.py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
fdd97aed84c463265bf1a9734732be9eedefe92442c0bc0b4e08f49c554ae63e
|
|
BLAKE2b-256 checksum How to use checksums |
ae531bffd4aef497c8db267f48552e554e9f820baf0b48dfe619cb6f4dc99c43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5
|
Security for django-code-generator 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.