29đź‘Ť
If you’re building an internal app that has no chance of ever being released to the public, sure, do whatever you want.
If you’re building an internal app that has little chance of ever being released to the public, but will possibly be used by future/current developers, sure, but be sure to document what the app needs to work properly.
If you’re building an app for public release, try to keep it self-dependent (and django-internals dependent, ie, use what django provides, when possible). If you really need a third-party app to work, or if a third party app would make your code more manageable, then sure, include dependencies, but be doubly sure to document all requirements and necessary setup.
In most cases, you can do almost whatever you want so long as you have sufficient documentation.
I do, however, have to question the sanity of making your own User
model that has the same name as django’s builtin auth.User
.
42đź‘Ť
The answer is yes. It’s perfectly okay for one application inside your django project to import models from another application. The power of a django project lies in the apps and their interactions.
Also make sure that you have utility applications importing models from more generic applications and not the other way. So “userstatistics” app should import models from the “users” app but “users” app should not rely on the “userstatistics”.
If your app is importing models from a 3rd party application (lets say django-piston), be sure to specify that in a requirements file.
- [Django]-What is the Simplest Possible Payment Gateway to Implement? (using Django)
- [Django]-How to fix " AttributeError at /api/doc 'AutoSchema' object has no attribute 'get_link' " error in Django
- [Django]-Django not sending emails to admins
2đź‘Ť
You cand try better extending the Django User model with inheritance. You will use the django user with custom field added, so you will have the same user for all the apps.
- [Django]-Fastest way to get the first object from a queryset in django?
- [Django]-Authenticate by IP address in Django
- [Django]-How to stop celery worker process
1đź‘Ť
You can directly import models in app2/models.py. Usually you might need a foreign key, which looks like
models.ForeignKey('app1.ModelClass1', on_delete=models.CASCADE, related_name='modelclass2')
- [Django]-Django setting environment variables in unittest tests
- [Django]-Alternate Row Coloring in Django Template with More Than One Set of Rows
- [Django]-Django: best practice way to get model from an instance of that model
-4đź‘Ť
Don’t do this. They will have the same app name and the ORM will be confused. Use an abstract model instead, and have both derive from it.
- [Django]-What is PyMySQL and how does it differ from MySQLdb? Can it affect Django deployment?
- [Django]-Should I avoid multi-table (concrete) inheritance in Django by any means?
- [Django]-Altering one query parameter in a url (Django)