Django Design Reusable Apps?

Django Design Reusable Apps?



I am developing Django application, but still have confusion over apps design pattern, let say my application has models like follow.


Django


apps


class Department(models.Model):
name = models.CharField(max_length=255)

class Student(models.Model):
name = models.CharField(max_length=255)

department = models.ForeignKey(Department)



As u see student model has relation of department = models.ForeignKey(Department)


department = models.ForeignKey(Department)



In This case should i need to create separate apps for department and student or is it good enough to create custom_app with both department and student models ?


department


student


custom_app


department


student




1 Answer
1



You don't have to create app for each model. App is more high level thing. You can logically think of app name which contains both models: for example, 'university' or 'practice' or even 'students' that will contain all the business logic of interaction with this models. Below you can create another app that could have any other models. Just try to link each model to only one app if you can





ok, since student model requires a department model, we can group into single app, if there no relation with other apps we can make it single app right?
– N.HariHaraSudhan
Aug 29 at 12:30





@N.HariHaraSudhan yeah, for sure
– py_dude
Aug 30 at 7:45






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)