tagging - why does admin UI not add tags section for some models using django-taggit? -
i new django , using django-taggit 0.10a1 tagging functionality in django 1.4.2 application. tried django-tagging app project not maintained , django-taggit had lot of positive reviews developers, opted that.
i wondering if of can me problem seeing. after following documentation, added :
tags = taggablemanager()
to models need tagging. of models automatically added tags section in django admin documentation specified, of models, tags section doesn't show on admin ui. not able figure out why. here couple of models have tags line declared after fields. if see wrong in placement of statement in model, , if can let me know if see issue, appreciate it. sample non-working models taggablemanager follows:
digitalobject model
class digitalobject(models.model): title = models.charfield(max_length=255, verbose_name=_("title")) ascii_title = models.charfield(max_length=255, verbose_name=_("ascii title")) title_variants = models.charfield(max_length=300, null=true, blank=true, verbose_name=_("title variants")) collection = models.foreignkey(collection, related_name="collection_objects", verbose_name=_("collection")) object_creator = models.foreignkey(creator, null=true, blank=true, related_name="objects_created", verbose_name=_("object creator")) language = models.manytomanyfield("language", null=true, blank=true, verbose_name=_("language"), related_name="language_objects") subject = models.manytomanyfield(subjectheading, null=true, blank=true, related_name="collection_objects", verbose_name=_("subject")) object_id = models.charfield(max_length=6, null=true, blank=true, verbose_name=_("object id")) digital_id = models.charfield(max_length=100, null=true, blank=true, verbose_name=_("digital id")) rights_holders = models.charfield(max_length=255, null=true, blank=true, verbose_name=_("rights holder(s)")) license_type = models.foreignkey("license", default=1, verbose_name=_("license type")) permission_form = models.filefield(upload_to='permissionforms', verbose_name=_("permission form"), null=true, blank=true) # physical object info identifier = models.charfield(max_length=60, help_text=_("e.g. isbn, issn, doi"), null=true, blank=true, verbose_name=_("identifier")) marks = models.charfield(max_length=255, null=true, blank=true, verbose_name=_("marks/inscriptions")) measurements = models.charfield(max_length=255, null=true, blank=true, verbose_name=_("physical description")) phys_object_type = models.foreignkey("physicalobjecttype", verbose_name=_("physical object type"), related_name="digital_objects", null=true, blank=true) donor = models.charfield(max_length=255, null=true, blank=true, verbose_name=_("donor")) sponsor_note = models.charfield(max_length=255, null=true, blank=true, verbose_name=_("sponsor note")) phys_obj_date = models.datefield(null=true, blank=true, verbose_name=_("physical object date")) phys_obj_precision = models.charfield(max_length=1, choices=constants.date_precision_choices, default=u'f', null=true, blank=true, verbose_name=_("precision")) phys_obj_bc = models.booleanfield(default=false, verbose_name=_("is b.c. date")) phys_obj_location = models.foreignkey("location", null=true, blank=true, verbose_name=_("physical object location")) # digital object info digi_object_format = models.foreignkey("digitalobjecttype", verbose_name=_("digital object format"), null=true, blank=true) # container info series_num = models.charfield(max_length=12, null=true, blank=true, verbose_name=_("series #")) series_name = models.charfield(max_length=255, null=true, blank=true, verbose_name=_("series name")) subseries_num = models.charfield(max_length=12, null=true, blank=true, verbose_name=_("subseries #")) subseries_name = models.charfield(max_length=255, null=true, blank=true, verbose_name=_("subseries name")) box_num = models.charfield(max_length=12, null=true, blank=true, verbose_name=_("box #")) folder_num = models.charfield(max_length=12, null=true, blank=true, verbose_name=_("folder #")) drawer_num = models.charfield(max_length=12, null=true, blank=true, verbose_name=_("drawer #")) folder_name = models.charfield(max_length=255, null=true, blank=true, verbose_name=_("folder name")) folder_date = models.charfield(max_length=255, null=true, blank=true, verbose_name=_("folder date")) # relationships related_production = models.manytomanyfield(production, related_name="related_objects", null=true, blank=true, verbose_name=_("related production")) related_festival = models.manytomanyfield(festivaloccurrence, related_name="related_objects", null=true, blank=true, verbose_name=_("related festival")) related_venue = models.manytomanyfield(location, related_name="related_objects", null=true, blank=true, verbose_name=_("related venue")) related_creator = models.manytomanyfield(creator, related_name="related_objects", null=true, blank=true, verbose_name=_("related creator")) related_work = models.manytomanyfield(workrecord, related_name="related_objects", null=true, blank=true, verbose_name=_("related work")) # details summary = models.textfield(null=true, blank=true, verbose_name=_("summary")) notes = models.textfield(null=true, blank=true, verbose_name=_("notes")) creation_date = models.datefield(null=true, blank=true, help_text="click 'today' see today's date in proper date format.", verbose_name=_("creation date")) creation_date_precision = models.charfield(max_length=1, null=true, blank=true, choices=constants.date_precision_choices, default=u'y', verbose_name=_("precision")) creation_date_bc = models.booleanfield(default=false, verbose_name=_("is b.c. date")) restricted = models.booleanfield(default=false, verbose_name=_("restricted?")) restricted_description = models.charfield(max_length=255, null=true, blank=true, verbose_name=_("details of restrictions")) ready_to_stream = models.booleanfield(default=false, verbose_name=_("uploaded streaming server")) hi_def_video = models.booleanfield(default=false, verbose_name=_("hi-def video")) poster_image = models.filefield(upload_to='digitalobjects/poster_images', storage=overwritestorage(), verbose_name=_("poster image (for videos)"), null=true, blank=true) attention = models.textfield(null=true, blank=true, verbose_name=_("attention")) has_attention = models.booleanfield(default=false) needs_editing = models.booleanfield(default=true, verbose_name=_("needs editing")) published = models.booleanfield(default=true, verbose_name=_("published")) tags = taggablemanager() def phys_obj_date_display(self): return display_date(self.phys_obj_date, self.phys_obj_precision, self.phys_obj_bc) def creation_date_display(self): return display_date(self.creation_date, self.creation_date_precision, self.creation_date_bc) def has_related_things(self): if self.related_production.exists(): return true if self.related_festival.exists(): return true if self.related_venue.exists(): return true if self.related_creator.exists(): return true if self.related_work.exists(): return true return false def object_number(self): num = '' num += self.collection.repository.repository_id num += self.collection.collection_id num += self.object_id return num def first_file(self): if self.files: df = self.files.order_by('seq_id')[0] return df else: return false def __unicode__(self): return "%s (%s)" % (self.title, str(self.object_number())) def update_digital_object_title(sender, **kwargs): obj = kwargs['instance'] obj.ascii_title = unidecode(obj.title) pre_save.connect(update_digital_object_title, sender=digitalobject)
workrecord model
class workrecord(models.model): title = models.charfield(max_length=255, verbose_name=_("title")) title_variants = models.charfield(max_length=300, null=true, blank=true, verbose_name=_("title variants")) ascii_title = models.charfield(max_length=255, verbose_name=_("ascii title")) creators = models.manytomanyfield(creator, through="workrecordcreator", verbose_name=_("creators")) creators_display = models.charfield(max_length=255, verbose_name=_("creators")) work_type = models.foreignkey("workrecordtype", verbose_name=_("work type")) subject = models.manytomanyfield(subjectheading, null=true, blank=true, related_name="works", verbose_name=_("subject")) genre = models.foreignkey("workgenre", null=true, blank=true, help_text=_("the work's genre - e.g. drama, comedy"), verbose_name=_("genre")) culture = models.foreignkey("workculture", null=true, blank=true, help_text=_("the culture work part of"), verbose_name=_("culture")) style = models.foreignkey("workstyle", null=true, blank=true, help_text=_("a movement or period work belongs to"), verbose_name=_("style")) lang = models.manytomanyfield("language", null=true, blank=true, verbose_name=_("language")) creation_date = models.datefield(null=true, blank=true, help_text="click 'today' see today's date in proper date format.", verbose_name=_("creation date")) creation_date_precision = models.charfield(max_length=1, choices=constants.date_precision_choices, default=u'y', null=true, blank=true, verbose_name=_("precision")) creation_date_bc = models.booleanfield(default=false, verbose_name=_("is b.c. date")) publication_date = models.datefield(null=true, blank=true, help_text="click 'today' see today's date in proper date format.", verbose_name=_("publication date")) publication_date_precision = models.charfield(max_length=1, choices=constants.date_precision_choices, default=u'y', null=true, blank=true, verbose_name=_("precision")) publication_date_bc = models.booleanfield(default=false, verbose_name=_("is b.c. date")) publication_rights = models.charfield(max_length=30, null=true, blank=true, verbose_name=_("publication rights")) performance_rights = models.charfield(max_length=30, null=true, blank=true, verbose_name=_("performance rights")) website = models.urlfield(null=true, blank=true, help_text=_("a site users can find text of work"), verbose_name=_("website")) digital_copy = models.foreignkey("digitalobject", null=true, blank=true, verbose_name=_("digital copy")) summary = models.textfield(null=true, blank=true, verbose_name=_("summary")) notes = models.textfield(null=true, blank=true, verbose_name=_("notes")) related_works = models.manytomanyfield("self", through="relatedwork", symmetrical=false, null=true, blank=true, related_name="related_to", verbose_name=_("related works")) attention = models.textfield(null=true, blank=true, verbose_name=_("attention")) has_attention = models.booleanfield(default=false) needs_editing = models.booleanfield(default=true, verbose_name=_("needs editing")) published = models.booleanfield(default=true, verbose_name=_("published")) awards_text = models.textfield(null=true, blank=true, verbose_name=_("awards (plain text)")) biblio_text = models.textfield(null=true, blank=true, verbose_name=_("bibliography (plain text)")) biblio_text_es = models.textfield(null=true, blank=true, verbose_name=_("bibliography (plain text, spanish)")) secondary_biblio_text = models.textfield(null=true, blank=true, verbose_name=_("secondary bibliography (plain text)")) secondary_biblio_text_es = models.textfield(null=true, blank=true, verbose_name=_("secondary bibliography (plain text, spanish)")) tags = taggablemanager() def creation_date_display(self): return display_date(self.creation_date, self.creation_date_precision, self.creation_date_bc) creation_date_display.short_description = _("creation date") def publication_date_display(self): return display_date(self.publication_date, self.publication_date_precision, self.publication_date_bc) publication_date_display.short_description = _("publication date") def creators_display_links(self): cs = "" wrc in workrecordcreator.objects.filter(work_record=self): cs += "<a href='/creator/" + str(wrc.creator.id) + "'>" cs += wrc.creator.display_name() cs += "</a>, " cs = cs.rstrip(', ') return cs def has_system_links(self): if awardcandidate.objects.filter(work_record=self).exists(): return true elif relatedwork.objects.filter(first_work=self).exists(): return true elif relatedwork.objects.filter(second_work=self).exists(): return true elif workrecordcreator.objects.filter(work_record=self).exists(): return true elif role.objects.filter(source_text=self).exists(): return true elif production.objects.filter(source_work=self).exists(): return true elif digitalobject.objects.filter(related_work=self).exists(): return true elif bibliographicrecord.objects.filter(work_record=self).exists(): return true else: return false def __unicode__(self): return "%s (%s)" % (self.title, self.work_type.name) def update_wr_title(sender, **kwargs): obj = kwargs['instance'] obj.ascii_title = unidecode(obj.title) pre_save.connect(update_wr_title, sender=workrecord)
i sincerely appreciate if of please take @ , let me know if see might have missed or if need more information understand issue.
thanks in advance.
turns out models tags column wasn't appearing had field sets in admin.py. models not arranged field sets, taggit automatically adds "tags" column admin ui. ones arranged fieldsets, "tags" column model should included in 1 of the field sets.
admin.py workrecord model
class workrecordadmin(translationadmin): form = arcforms.workrecordadminform inlines = (workrecordcreatorinline, roleinline, relatedworkinline,) list_display = ('title', 'creators_display', 'work_type', 'genre', 'culture', 'style', 'has_system_links') list_filter = ('work_type', 'lang', 'genre', 'culture', 'style', 'has_attention',) search_fields = ['title', 'ascii_title', 'title_variants'] filter_horizontal = ['subject', 'lang'] fieldsets = ( ('titles', { 'fields': ('title', 'title_variants') }), ('description', { 'fields': ('work_type', 'subject', 'genre', 'culture', 'style', 'lang') }), ('creation / publication', { 'fields': (('creation_date', 'creation_date_precision', 'creation_date_bc'), ('publication_date', 'publication_date_precision', 'publication_date_bc'), 'publication_rights', 'performance_rights') }), ('access', { 'fields': ('website', 'digital_copy') }), ('standard fields', { 'fields': ('summary', 'notes', 'attention', 'needs_editing', 'published', 'tags') }) )
tags column included in standard fields fieldset above.
Comments
Post a Comment