python - App as foreign key -


so , have django project 2 apps

├───blog     post     comment  └───user     profile 
  • user (basic authentification , profile dashboards)

  • blog (having basic blog models : post,comment)

i need give users possbility create 1 or more blogs within same project, don't see how can treat app model.

the solution figured out , add foreign key user id every model withn blog app.but there better way ?

i think should that:

# blog/models.py  class blog(model):     owner = foreignkey(user, related_name="blogs")     name = charfield()  class post(model):     blog = foreignkey(blog, related_name="posts")     #other fields ...  class comment(model):     post = foreignkey(post, related_name="comments")     #other fields ... 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -