20đź‘Ť
What I would do,
-
Define the schema in Django orm, let it write the db via syncdb. You get the admin interface.
-
In view1 you need a complex join
def view1(request):
import sqlalchemy
data = sqlalchemy.complex_join_magic(...)
...
payload = {'data': data, ...}
return render_to_response('template', payload, ...)
8đź‘Ť
I don’t think it’s good practice to use both. You should either:
- Use Django’s ORM and use custom SQL where Django’s built-in SQL generation doesn’t meet your needs, or
- Use SQLAlchemy (which gives you finer control at the price of added complexity).
Of course, if you need Django’s admin, then the first of these approaches is recommended.
- [Django]-How do I perform a batch insert in Django?
- [Django]-How to setup SSL on a local django server to test a facebook app?
- [Django]-Python Django Gmail SMTP setup
8đź‘Ť
I’ve done it before and it’s fine. Use the SQLAlchemy feature where it can read in the schema so you don’t need to declare your fields twice.
You can grab the connection settings from the settings, the only problem is stuff like the different flavours of postgres driver (e.g. with psyco and without).
It’s worth it as the SQLAlchemy stuff is just so much nicer for stuff like joins.
- [Django]-How can I unit test django messages?
- [Django]-Nginx and supervisor setup in Ubuntu
- [Django]-How to run celery as a daemon in production?
5đź‘Ť
Jacob Kaplan-Moss admitted to typing “import sqlalchemy” from time to time. I may write a queryset adapter for sqlalchemy results in the not too distant future.
- [Django]-Django Calendar Widget?
- [Django]-Necessity of explicit cursor.close()
- [Django]-Django_debug_toolbar and Docker
- [Django]-Building a list in Django templates
- [Django]-Reporting yielded results of long-running Celery task
- [Django]-Access fields in Django intermediate model