Skip to main content

Django Pick material Icon Widget

Project description

Django Pick material Icon Widget

Install

pip install django-npick

Usage

add templates path admin/change_form.html extra the default admin template to use js css

# project/settings.py
from django-npick import TEMPLATE_PATH   # 1

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_PATH],  # add templates path # 2
        'APP_DIRS': True,
        'OPTIONS': {)
    },
]

start an app

python manage.py startapp app

define your model

from django.db import models


class Icon(models.Model):
    name = models.CharField(max_length=30)

Add IconWidget to form then add form to Admin.

# app/admin.py
django.contrib import admin
from django import forms
from django_npick import IconWidget  # 3

from .models import Bingo


class BingoForm(forms.ModelForm):
    name = forms.CharField(widget=IconWidget)  # 4


class BingoAdmin(admin.ModelAdmin):
    form = BingoForm
    fields = ['name']

admin.site.register(Bingo, BingoAdmin)

runserver

python manage.py migrate
python manage.py createsuperuser
python manage.py runserver

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-npick-0.0.1.tar.gz (14.9 kB view hashes)

Uploaded source

Built Distribution

django_npick-0.0.1-py3.6.egg (21.6 kB view hashes)

Uploaded 3 6

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