Code Monkey home page Code Monkey logo

djadmin's Introduction

Djadmin

Djadmin is a django admin theme

image

image

image

Overview

"NEW UPDATES"

  • Added Django Admin documentation templates
  • Fixed Bugs

    "IN VERSION 1.1.5"

  • Added Sortable in admin change list page.
  • Added Language dropdown.
  • Added Configuration Page in admin (In Development).
  • Added Some fields in DjadminModelSettings Model.
  • Fixed Bugs

    "FEATURES ADDED IN VERSION 1.1.3"

  • Dynamic Django Admin - Admin options like : list_display, list_display_link etc will work dynamic.
  • Material Design - Djadmin is based on material design.
  • Djadmin Cards - It will show html design card on "Change list" or "Change form" page according to model.
  • Visior - Add visitor model for administrator location on each time login and show graph of login device
  • Forget Password Option - Admin can enable or disable forget password option on admin login page
  • Theme Color - Change theme color of admin
  • Admin Header Title - Change django admin header title
  • Image preview or File information on change form if form has Image field or File field
  • Added "Next" and "Prev" for change form. It will display when model have 2 or more rows data and model has default django primary key field "id"

Documentation

  • Installation - * Run :

    pip install djadmin
    • Add 'djadmin' to your INSTALLED_APPS just before 'django.contrib.admin' :

      'djadmin',
    • Add middleware in MIDDLEWARE_CLASSES list :

      'djadmin.middleware.DJMiddleware',
    • Please make sure you already have 'django.template.context_processors.request' in context_processors of settings. If you don't have, please add it
    • Add in urls.py :

      url(r'^admin/', include('djadmin.urls')),
    • Run 'python manage.py migrate' for make visitor model :

      python manage.py migrate
    • Run 'python manage.py collectstatic' :

      python manage.py collectstatic
    • Now you have successfully install djadmin in your project
  • Customization - * Add 'DJADMIN_DYNAMIC_FIELD_DISPLAY' for Enable Django admin dynamic options for models, After enable this option it's need to "migrate" model. default: False :

    DJADMIN_DYNAMIC_FIELD_DISPLAY = True
    • Inherit DjadminMixin in your admin class of model, No need of inherit 'admin.ModelAdmin':

      from djadmin.mixins import DjadminMixin
      from main.models import Book
      @admin.register(Book)
      class BookAdmin(DjadminMixin):
          pass
    • Another way for register DjadminMixin to Model :

      from djadmin.mixins import DjadminMixin
      from main.models import Book
      admin.site.register(Book, DjadminMixin)

    After that you will see DjadminMixin Inherit model name in "DjadmiModelSetting" of admin like below snapshot then change field values with given field.You will get field to show

    Note: If any field already define in your admin class of model then that field value in DjadmiModelSetting will not work for field.

    • Add 'DJADMIN_FIELD_DEPTH' for define field depth.When any model has ForeignKey relation with another model and next model also has Foreignkey relation with another that define relation depth.default = 1 :

      DJADMIN_FIELD_DEPTH = 2
      
      Ex:
      class Publisher(models.Model):
          name = models.CharField(max_length=30)
      
      class Book(models.Model):
          pub = models.ForeignKey(Publisher)
      
      class Author(models.Model):
          book = models.ForeignKey(Book)

    So, If we have Author model then depth 2 will create field in Author model: "book__pub__name" for access Publisher name from Author model instance.

    • Add 'ALLOW_FORGET_PASSWORD_ADMIN' for Enable Forget password option in login page, default: Disable :

      ALLOW_FORGET_PASSWORD_ADMIN = True
      EMAIL_USE_TLS = True
      DEFAULT_FROM_EMAIL = '<Email ID>'
      SERVER_EMAIL = '<Email ID>'
      EMAIL_HOST = '<smtp.example.com>'  #Ex: Gmail : smtp.gmail.com
      EMAIL_PORT = <Port Number>    #Ex: Gmail : 587
      EMAIL_HOST_USER = '<Email ID>'
      EMAIL_HOST_PASSWORD = '<Password>'
      EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    • Add 'ADMIN_COLOR_THEME' for change admin color. you can write directly name of color. default: cyan :

      ADMIN_COLOR_THEME = 'red'
    • Add 'ADMIN_HEADER_TITLE' for change admin header title :

      ADMIN_HEADER_TITLE  = 'Djadmin Administrator'

Demo

Screenshot

image

image

image

image

image

License

Djadmin is an Open Source project licensed under the terms of the MIT license

djadmin's People

Contributors

sainipray 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

djadmin's Issues

Not supporting in Django 2

It is not supporting in Django 2,I have fixed this issue on my local.
If possible add me as a contributor so that i can make those changes, Or
You need to fix few changes i am attaching a file for this fixes please update.

Error if ImageField or FileField is optional

I think on the function get_file_detail must be checking file is None when class name ImageField or FileField.

If you can implement my code as below.


@register.simple_tag
def get_file_detail(adminform, field):
    field_data = adminform.form.initial[field]
    field_name = type(field_data).__name__
    try:
       if field_name == 'ImageFieldFile':
            if not bool(field_data):
                return {'type': 'image', 'width': 0, 'height': 0, 'url': '', 'size': 0, 'extension': ''}
            filename, file_extension = os.path.splitext(field_data.url)
            return {'type': 'image', 'width': field_data.width, 'height': field_data.height, 'url': field_data.url, 'size': field_data.size, 'extension': file_extension}
       if field_name == 'FieldFile':
           if not bool(field_data):
               return {'type': 'file', 'url': '', 'size': 0, 'extension': ''}
           filename, file_extension = os.path.splitext(field_data.url)
           return {'type': 'file', 'url': field_data.url, 'size': field_data.size, 'extension': file_extension}
       return field
    except IOError:
        pass

Thank You.

its giving error

name = models.ForeignKey(AUTH_USER_MODEL, verbose_name=_('User'), null=True) TypeError: __init__() missing 1 required positional argument: 'on_delete'
i am getting this error

Delete row solution

If you get this error : invalid literal for int() with base 10: '1" class="action-select'

Solution :
add this function to : /usr/local/lib/python2.7/dist-packages/djadmin/templatetags/custom.py

@register.filter def get_value(result_checkbox_html): value = result_checkbox_html.split( ) for x in value: if x.startswith("value"): val = x.split("=") return val[1].replace('"','') return None

and go to this file : /usr/local/lib/python2.7/dist-packages/djadmin/templates/admin/change_list_results.html

replace this "admin_change_list_value" with "get_value"

TypeError: __init__() missing 1 required positional argument: 'on_delete'

python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 21, in
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/Users/shaikaf/PycharmProjects/demonaren/venvnew/lib/python3.8/site-packages/django/core/management/init.py", line 401, in execute_from_command_line
utility.execute()
File "/Users/shaikaf/PycharmProjects/demonaren/venvnew/lib/python3.8/site-packages/django/core/management/init.py", line 377, in execute
django.setup()
File "/Users/shaikaf/PycharmProjects/demonaren/venvnew/lib/python3.8/site-packages/django/init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/shaikaf/PycharmProjects/demonaren/venvnew/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/Users/shaikaf/PycharmProjects/demonaren/venvnew/lib/python3.8/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/Cellar/[email protected]/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 783, in exec_module
File "", line 219, in call_with_frames_removed
File "/Users/shaikaf/PycharmProjects/demonaren/venvnew/lib/python3.8/site-packages/djadmin/models.py", line 19, in
class Visitor(models.Model):
File "/Users/shaikaf/PycharmProjects/demonaren/venvnew/lib/python3.8/site-packages/djadmin/models.py", line 23, in Visitor
name = models.ForeignKey(AUTH_USER_MODEL, verbose_name=
('User'), null=True)
TypeError: init() missing 1 required positional argument: 'on_delete'

Initial Update

Hi ๐Ÿ‘Š

This is my first visit to this fine repo, but it seems you have been working hard to keep all dependencies updated so far.

Once you have closed this issue, I'll create seperate pull requests for every update as soon as I find one.

That's it for now!

Happy merging! ๐Ÿค–

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.