d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Working With Django -- Need Some Help.
Add Reply New Topic New Poll
Member
Posts: 6,544
Joined: Jan 17 2010
Gold: 3.33
Feb 3 2018 11:03pm
At what point do you create a new model or app?

For example, if you are creating a profile system where users can review profiles, would you create both a profile app and a review app with separate models?

Or would it be better to make a Profile app with a review column in the model and just call the review app in the html when you need to retrieve it?


Wouldn't it get challenging dealing with the multitude of applications called on every page?

This post was edited by WeAwait on Feb 3 2018 11:03pm
Member
Posts: 36,123
Joined: Jul 18 2008
Gold: 2,407.00
Feb 4 2018 07:34am
My take on it is that since the models for profiles and reviews are related, they should go in one app. Everything I've read about django best practices is that apps should be self-contained and re-usable.
Member
Posts: 6,544
Joined: Jan 17 2010
Gold: 3.33
Feb 4 2018 10:12am
Quote (Mastersam93 @ Feb 4 2018 07:34am)
My take on it is that since the models for profiles and reviews are related, they should go in one app. Everything I've read about django best practices is that apps should be self-contained and re-usable.



But the user account system should be separated from the profile system despite being related correct?


So like..

App1: User Accounts & Registration
App2: Profiles
- SubApp1: Reviews
App3: Billing
App4: Etc
Member
Posts: 36,123
Joined: Jul 18 2008
Gold: 2,407.00
Feb 4 2018 12:24pm
Quote (WeAwait @ Feb 4 2018 11:12am)
But the user account system should be separated from the profile system despite being related correct?


So like..

App1: User Accounts & Registration
App2: Profiles
- SubApp1: Reviews
App3: Billing
App4: Etc



What I think you should do is have your apps use the AUTH_USER_MODEL field in the settings file instead of the default django.contrib.auth.users model that way they can always relate to the user model if you don't use the default.

https://docs.djangoproject.com/en/2.0/ref/settings/#std:setting-AUTH_USER_MODEL

Because the users model is kind of special and is probably going to relate to every app. But other than that I'm guessing reviews should be in the profile app as a many-to-many field.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll