django - ForeignKey relation a better understanding -
If there is anyone from the world who can learn best practice about field lookup, and how it works. I tried that they are documenting but I found this specially in particular to confuse the relationship between the model and the idea about the database.
For example, suppose we have the following structure: What is the best way to look at these types of situations and what should be?
Model:
class articles (models.Model): author = model.carfield (max_long = 255) title = model.readfield (max_length = 255) content = model (. Models) Def page (request, URL_Title): URL setup article = Article.objects.get (title = URL_Title) Comments = # # What is the default way to get comments for the specified article? Return: render_to_response ('base.html', {'Article': Article, 'Comments': Comments}) Demo:
{% if article %} ..... Print all articles related areas ..... {% if comment%} {% for comments in comment%} Print ..... {% endfor%} {% Endif%} {% endif%} And if you have the time, an example will also help on many many relationships.
Any help is highly appreciated.
As stated, by doing so, this can be done through manager It is possible to see the article model example for tampering related area. article = Article.objects.get (title = URL_Title) Comments = article.comments_set.all ()
Comments
Post a Comment