Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django-taggit - display existing tags on the django-admin add record page

I have created a test vlog application using django/python and django-taggit.

The vlog and tags are working as they should.

However, I want to list all the existing tags in the django-admin interface for new and updated vlog entries - similar to displaying the tags as a filter on the django-admin list page.

This will make the selection of new or existing tags for each new or updating vlog entry that much easier.

Here is what I mean by adding the tags as help-text on the tags input field:

My models.py code:

class VlogDetails(models.Model):
    ....
    vlog_video_image_url = models.URLField(null=False, blank=False, max_length=250, unique=True, help_text='http://img.youtube.com/vi/You_Tube_URL/0.jpg')
    ....
    tags = TaggableManager(help_text='List all the available tags here.')

Here is the django-admin input form interface:

enter image description here

Is it possible to display the existing tags in another manner on the new / edit django-admin page?

I have already listed the existing / existing tags on the django-admin list page as a filter as shown below. This filter display does not display on the new / update input forms.

django-admin filter code:

class VlogDetailsAdmin(BaseDetailsAdmin):
....
    list_filter = [
        'vlog_date_published',
        'tags',
        'vlog_timestamp_added',
        'vlog_timestamp_updated'
    ]

![enter image description here

I have tried several things but none work and I cannot find any related ideas in the docs. Any suggestion would be appreciated. Thanks.

like image 377
user1261774 Avatar asked Dec 23 '22 11:12

user1261774


1 Answers

I will answer my own question.

I don't think that adding the tags to the new vlog page is possible - that is not possible for my level of coding experience.

However, after more investigation, I stumbled to an obscure post about django-taggit-autosuggest.

Follow the docs to install and set up the django-taggit-autosuggest.

Instead of listing all the existing tags in the help. The autosuggest option displays all the existing tags with the related letters, as shown below:

enter image description here

And again:

enter image description here

I hope that this helps someone.

like image 146
user1261774 Avatar answered Dec 28 '22 05:12

user1261774