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
@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.
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