Amin Ba
Amin Ba

Reputation: 2436

How to store a list of string (tags or keywords) in a django model field?

I have these models:

class Author(model):
    user = OneToOneField(CustomUser)
    other_filed = CharField(...)


class Post(Model):
    author = ForeignKey(Author, on_del..)
    title = CharField(...)
    # keywords field to be inserted in a form and stored

As already described, I need to field for the keyword related to each post written by an author. While I need something simple to avoid complexities, I prefer to be able to restrict the length of each keyword and the number of keywords. I have read Keywords Field in Django Model and What is the most efficient way to store a list in the Django models? and a few other articles but do not seem to be able to decide what should I do

suppose I will find a way to store it. Why do I need it? At this stage, I only need to populate the keywords meta tag in the head part of the html of the page related to the article. I may, in the future, use these keywords to search and find an article.

Upvotes: 3

Views: 1297

Answers (0)

Related Questions