model - Django app structutre and circular reference -


i'm trying keep project organized, try keep splitted apps. assume blog app blogpost model. add tag app, has tag model foreign key post. if want write method get_tags(), in blog class, circular reference. bad design? maybe should not write such method on blog, or such related models should in same app?
i'm trying learn how organize (big) project. i've read lot django app concept, stil haven't found right way

the point here django automatically creates reverse lookup when create foreignkey or manytomanyfield. assuming models follows:

blogpost model

from django.db import models  class blogpost(models.model):     title = models.charfield(_('title'), max_length=200)     slug = models.slugfield(_('slug'), unique_for_date='publish')     author = models.foreignkey(user, blank=true, null=true)     body = models.textfield(_('body'), )     publish = models.datetimefield(_('publish'), default=datetime.datetime.now)     created = models.datetimefield(_('created'), auto_now_add=true) 

tag model

from django.db import models     blog.models import blogpost  class tag(models.model):     post = models.foreignkey(blogpost,related_name="tags") 

now, assuming generating tags of post in view, can tags of post calling blogpost.tags_set blogpost model instance of blogpost.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -