Code Monkey home page Code Monkey logo

django-admin-generator's Introduction

Readme

Introduction

Build status:

django-admin-generator test status

Coverage:

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

django-admin-generator's People

Contributors

requires avatar wolph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

django-admin-generator's Issues

TypeError: requires_system_checks must be a list or tuple. | django 4.1

Details

As mentioned here for a similar error, this should come from version compatibility of django 4.1

Support for boolean values was deprecated in Django 3.2 and removed in Django 4.1

Error

python manage.py admin_generator <APP NAME>

Traceback (most recent call last):
File "I:\Dev\PFE_CGI\django-backend\VFVDjangoBackend\manage.py", line 22, in
main()
File "I:\Dev\PFE_CGI\django-backend\VFVDjangoBackend\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "I:\Dev\PFE_CGI\django-backend\venv-backend\Lib\site-packages\django\core\management_init_.py", line 446, in execute_from_command_line
utility.execute()
File "I:\Dev\PFE_CGI\django-backend\venv-backend\Lib\site-packages\django\core\management_init_.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\Dev\PFE_CGI\django-backend\venv-backend\Lib\site-packages\django\core\management_init_.py", line 279, in fetch_command
klass = load_command_class(app_name, subcommand)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\Dev\PFE_CGI\django-backend\venv-backend\Lib\site-packages\django\core\management_init_.py", line 49, in load_command_class
return module.Command()
^^^^^^^^^^^^^^^^
File "I:\Dev\PFE_CGI\django-backend\venv-backend\Lib\site-packages\django_utils\management\commands\base_command.py", line 20, in init
base.BaseCommand.init(self)
File "I:\Dev\PFE_CGI\django-backend\venv-backend\Lib\site-packages\django\core\management\base.py", line 274, in init
raise TypeError("requires_system_checks must be a list or tuple.")
TypeError: requires_system_checks must be a list or tuple.

Cannot install django-admin-generator because these package versions have conflicting dependencies.

ERROR: Command errored out with exit status 1:
command: /home/sayed/Desktop/elham/env3/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-y66_fu7_/anyjson_4b6a6ca36439448696c59be8b2ddd8a2/setup.py'"'"'; file='"'"'/tmp/pip-install-y66_fu7_/anyjson_4b6a6ca36439448696c59be8b2ddd8a2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-cq46gy2d
cwd: /tmp/pip-install-y66_fu7_/anyjson_4b6a6ca36439448696c59be8b2ddd8a2/

The conflict is caused by: django-utils2 2.12.0 depends on anyjson>=0.3.0 django-utils2 2.11.3 depends on anyjson>=0.3.0 django-utils2 2.11.2 depends on anyjson>=0.3.0 django-utils2 2.11.1 depends on anyjson>=0.3.0 django-utils2 2.11.0 depends on anyjson>=0.3.0 django-utils2 2.9.0 depends on anyjson>=0.3.0 django-utils2 2.8.0 depends on anyjson>=0.3.0 django-utils2 2.7.0 depends on anyjson>=0.3.0 django-utils2 2.6.0 depends on anyjson>=0.3.0 django-utils2 2.5.4 depends on anyjson>=0.3.0 django-utils2 2.5.3 depends on anyjson>=0.3.0 django-utils2 2.5.2 depends on anyjson>=0.3.0 django-utils2 2.5.1 depends on anyjson>=0.3.0 django-utils2 2.5.0 depends on anyjson>=0.3.0six django-utils2 2.4.0 depends on anyjson>=0.3.0six django-utils2 2.3.0 depends on anyjson>=0.3.0six django-utils2 2.2.1 depends on anyjson>=0.3.0six django-utils2 2.2.0 depends on anyjson>=0.3.0six django-utils2 2.1.0 depends on anyjson>=0.3.0six django-utils2 2.0.1 depends on anyjson>=0.3.0six django-utils2 2.0.0 depends on anyjson>=0.3.0six django-utils2 1.8.1 depends on anyjson>=0.3.0 django-utils2 1.8.0 depends on anyjson>=0.3.0 django-utils2 1.7.1 depends on anyjson>=0.3.0 django-utils2 1.7.0 depends on anyjson>=0.3.0 django-utils2 1.6.1 depends on anyjson>=0.3.0 django-utils2 1.6.0 depends on anyjson>=0.3.0 django-utils2 1.5.1 depends on anyjson>=0.3.0

Handling models in sub folders

Great package, has helped me greatly.

Have you considered how to handle models within subfolders of an app? I'm needing to go through and manually correct imports within admin.py, for any apps which I have models organized by subfolders.

Note that these models are discoverable through app.get_models().

List filter options being repeated when using mixins

I'm not sure if this is intended behavior, but I noticed this morning that the generated admin.py is repeating list_filter options. And seems to be related to whether those fields are related fields, or included via a model mixin.

An example output for model 'ProfileLocation' below:

class ProfileLocationAdmin(admin.ModelAdmin):

    list_display = ('id', 'created_at', 'modified_at', 'profile', 'location')
    list_filter = (
        'created_at',
        'modified_at',
        'profile',
        'location',
        'id',
        'created_at',
        'modified_at',
        'profile',
        'location',
    )
    date_hierarchy = 'created_at'

created_at and modified_at are both datetimefields which are included via a modelmixin. While profile is a onetoone and location is a fk field.

Error because of file encoding

I get this error when starting a server after generating the admin.py file with admin generator:

SyntaxError: source code string cannot contain null bytes

It is caused by the encoding of the admin.py file. The file is encoded as UTF-16 LE, which seems to cause the error. The line at the top of the admin file doesn't seem to work:

vim: set fileencoding=utf-8 :

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.