Skip to content

The Django Admin Generator automatically generates (scaffolds) a fully functioning Django admin by introspecting and querying your models

Notifications You must be signed in to change notification settings

blok-z/django-admin-generator

 
 

Repository files navigation

Readme

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

Links

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/*

About

The Django Admin Generator automatically generates (scaffolds) a fully functioning Django admin by introspecting and querying your models

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%