# evennia.web.admin.tags

Tag admin

class `evennia.web.admin.tags.``TagForm`(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)

  Bases: `django.forms.models.ModelForm`

  Form to display fields in the stand-alone Tag display.

  class `Meta`

    Bases: `object`

    `fields` = ('tag_key', 'tag_category', 'tag_data', 'tag_type')
  `base_fields` = {'db_category': <django.forms.fields.CharField object>, 'db_data': <django.forms.fields.CharField object>, 'db_key': <django.forms.fields.CharField object>, 'db_model': <django.forms.fields.ChoiceField object>, 'db_tagtype': <django.forms.fields.ChoiceField object>}
  `declared_fields` = {'db_category': <django.forms.fields.CharField object>, 'db_data': <django.forms.fields.CharField object>, 'db_key': <django.forms.fields.CharField object>, 'db_model': <django.forms.fields.ChoiceField object>, 'db_tagtype': <django.forms.fields.ChoiceField object>}
  property `media`

    Return all media required to render the widgets on this form.

class `evennia.web.admin.tags.``InlineTagForm`(*args, **kwargs)

  Bases: `django.forms.models.ModelForm`

  Form for displaying tags inline together with other entities.

  This form overrides the base behavior of the ModelForm that would be used for a Tag-through-model. Since the through-models only have access to the foreignkeys of the Tag and the Object that they’re attached to, we need to spoof the behavior of it being a form that would correspond to its tag, or the creation of a tag. Instead of being saved, we’ll call to the Object’s handler, which will handle the creation, change, or deletion of a tag for us, as well as updating the handler’s cache so that all changes are instantly updated in-game.

  class `Meta`

    Bases: `object`

    `fields` = ('tag_key', 'tag_category', 'tag_data', 'tag_type')
  `__init__`(*args, **kwargs)

    If we have a tag, then we’ll prepopulate our instance with the fields we’d expect it to have based on the tag. tag_key, tag_category, tag_type, and tag_data all refer to the corresponding tag fields. The initial data of the form fields will similarly be populated.

  `save`(commit=True)

    One thing we want to do here is the or None checks, because forms are saved with an empty string rather than null from forms, usually, and the Handlers may handle empty strings differently than None objects. So for consistency with how things are handled in game, we’ll try to make sure that empty form fields will be None, rather than ‘’.

  `base_fields` = {'tag_category': <django.forms.fields.CharField object>, 'tag_data': <django.forms.fields.CharField object>, 'tag_key': <django.forms.fields.CharField object>, 'tag_type': <django.forms.fields.ChoiceField object>}
  `declared_fields` = {'tag_category': <django.forms.fields.CharField object>, 'tag_data': <django.forms.fields.CharField object>, 'tag_key': <django.forms.fields.CharField object>, 'tag_type': <django.forms.fields.ChoiceField object>}
  property `media`

    Return all media required to render the widgets on this form.

class `evennia.web.admin.tags.``TagFormSet`(data=None, files=None, instance=None, save_as_new=False, prefix=None, queryset=None, **kwargs)

  Bases: `django.forms.models.BaseInlineFormSet`

  The Formset handles all the inline forms that are grouped together on the change page of the corresponding object. All the tags will appear here, and we’ll save them by overriding the formset’s save method. The forms will similarly spoof their save methods to return an instance which hasn’t been saved to the database, but have the relevant fields filled out based on the contents of the cleaned form. We’ll then use that to call to the handler of the corresponding Object, where the handler is an AliasHandler, PermissionsHandler, or TagHandler, based on the type of tag.

  `verbose_name` = 'Tag'
  `verbose_name_plural` = 'Tags'
  `save`(commit=True)

    Save model instances for every form, adding and changing instances as necessary, and return the list of instances.

class `evennia.web.admin.tags.``TagInline`(parent_model, admin_site)

  Bases: `django.contrib.admin.options.TabularInline`

  A handler for inline Tags. This class should be subclassed in the admin of your models, and the ‘model’ and ‘related_field’ class attributes must be set. model should be the through model (ObjectDB_db_tag’, for example), while related field should be the name of the field on that through model which points to the model being used: ‘objectdb’, ‘msg’, ‘accountdb’, etc.

  `model` = None
  `verbose_name` = 'Tag'
  `verbose_name_plural` = 'Tags'
  `form`

    alias of `InlineTagForm`

  `formset`

    alias of `TagFormSet`

  `related_field` = None
  `extra` = 0
  `get_formset`(request, obj=None, **kwargs)

    get_formset has to return a class, but we need to make the class that we return know about the related_field that we’ll use. Returning the class itself rather than a proxy isn’t threadsafe, since it’d be the base class and would change if multiple people used the admin at the same time

  property `media`

class `evennia.web.admin.tags.``TagAdmin`(model, admin_site)

  Bases: `django.contrib.admin.options.ModelAdmin`

  A django Admin wrapper for Tags.

  `search_fields` = ('db_key', 'db_category', 'db_tagtype')
  `list_display` = ('db_key', 'db_category', 'db_tagtype', 'db_model', 'db_data')
  `list_filter` = ('db_tagtype', 'db_category', 'db_model')
  `form`

    alias of `TagForm`

  `view_on_site` = False
  `fieldsets` = ((None, {'fields': (('db_key', 'db_category'), ('db_tagtype', 'db_model'), 'db_data')}),)
  property `media`