I am writing a website in Django and I want to have two blogs.
For each blog, I need three variables: the name (which I choose when I write my message in the admin part β do I understand that this is the choice?), The title (for presentation), blog_url (for the URL).
There must be a finite number of blogs, so I can choose my choice from the drop-down menu when I write a message. I can do this with only one heading and URL after the example in the Django link - with the heading would be:
class Post(models.Model): BLOG_TITLE = ( ("Title 1", "first"), ("Title 2", "second"), ) blog_title = models.CharField( max_length=20, choices=BLOG_TITLE, blank=True)
I think I need something like
(["Title", "url"], "blog"),
instead
("Title", "blog"),
Should I define a Blog class and reference it via ForeignKey in Post? How?
Any idea? Thanks!
source share