Repository URL to install this package:
|
Version:
0.1.9 ▾
|
from django.db import models
from django.db.models import BLANK_CHOICE_DASH
from branding.models import FeatureAccess
class FeatureAccessField(models.CharField):
def __init__(self, *args, **kwargs):
kwargs["max_length"] = 20
kwargs["default"] = ""
kwargs["null"] = True
kwargs["blank"] = True
kwargs["choices"] = [("", "-")] + [(access.keyword, access.keyword) for access in FeatureAccess.objects.all()]
super(FeatureAccessField, self).__init__(*args, **kwargs)
def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH,
limit_choices_to=None):
from branding.models import FeatureAccess
return [("", "-")] + [(access.keyword, access.keyword) for access in FeatureAccess.objects.all()]