Skip to main content

Django Admin Generator is a management command to automatically generate a Django `admin.py` file for given apps/models.

Project description

Introduction

Test Status Coverage Status

The Django Admin Generator is a project which can automatically generate (scaffold) a Django Admin for you. By doing this it will introspect your models and automatically generate an Admin with properties like:

  • list_display for all local fields

  • list_filter for foreign keys with few items

  • raw_id_fields for foreign keys with a lot of items

  • search_fields for name and slug fields

  • prepopulated_fields for slug fields

  • date_hierarchy for created_at, updated_at or joined_at fields

Install

To install:

  1. Run pip install django-admin-generator-blokz or execute python setup.py install in the source directory

  2. Add django_admin_generator to your INSTALLED_APPS

If you want to run the tests, run py.test (requires pytest)

Usage

To generate an admin for a given app:

./manage.py admin_generator APP_NAME >> APP_NAME/admin.py

To generate an admin for a given app with all models starting with user:

./manage.py admin_generator APP_NAME ‘^user’ >> APP_NAME/admin.py

Publish to pypi

Now that the code for the python package is almost complete, you can start building the distribution archives.

First delete previous distributions:

rm -rf dist

Archives are compressed files that help your package to be deployed across multiple platforms and also make it platform independent.

In order to generate the distribution archives, run the following command from your terminal.

python3 -m pip install –user –upgrade setuptools wheel

This will upgrade your setuptools library on your machine to use the latest version. After this, you need to run the following command from the root directory of your package to generate the distribution files.

python3 setup.py sdist bdist_wheel

Once you run the above command, you can see that the distribution packages will be delivered under the directories — build and dist, that are newly created.

In addition to that, you can also see that the egg file information has been updated in the project source code as well.

Now that we have our distribution files ready, we can go ahead and try installing and importing the package to test if it works fine.

In order to install the package on your local machine, run the following command from the root directory.

python3 -m pip install –user -e .

Once the package is installed on local and works fine, it is now ready to be shipped to the PyPi repository.

Install a package called “twine” on your machine that will help ship the python package to the repositories.

python3 -m pip install –user –upgrade twine

Upload the package to PyPi. You can login with the project token set in PyPi. You can set the username to __token__ and the password to the access code saved earlier. You can also generate a new token.

python3 -m twine upload dist/*

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

django-admin-generator-blokz-1.1.3.tar.gz (12.1 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page