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

1

6

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.

Obsolete answered 3/1, 2018 at 23:17 Comment(1)
Your best bet is to override the form initial values take a look at docs.djangoproject.com/en/2.0/ref/forms/api/…Hako
O
11

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.

Obsolete answered 6/1, 2018 at 3:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.