Django: Making model with undefined number of fields -


I am trying to create a model for paragraph site. I want to link each article with 3-5 related articles, so I'm thinking about the code being made like this:

  class.model : # Small url url = Model CharField (max_length = 30, unique = true) is_published = models.BooleanField () author = models.CharField (max_length = 150) title = models.CharField (max_length = 200) short_description = models.TextField ( Max_length = 600) body = tinymce_models .HTMLField () related1 = models.ForeignKey (Article) Related 2 = models.ForeignKey (Article) Related 3 = Model. ForeignKey (Article)  

But sure no that Or it is possible to make a foreign key, for example, in relation to the same model, if I decide to force 6, 7 articles for example, how will this work, related to me 4, 5, 6. ... to write in the model? I have more general solutions, so if I am binding more articles, then I do not need to redefine the code again and again

What I am thinking, from related areas The paragraph model is not to be expanded .. (It looks ugly) Maybe it's worth making another model? For example: Article Asset

but without defining any restricted content (without the limit of item). Can you suggest a way?

Thank you in advance

You have to use for this connection.

For example:

  class.es (models.Model): # Rest areas and models = lots for areas related to the body. Model ("self")  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -