How to integrate Fast API and Django - django

I wanna to write e-commerce website on django.
My project will have two DBs:
PostgreSQL (For storing users data, django tables, orders handling etc)
MongoDB (For storing Products and their categories)
Django works well with Relational DBs, but working with NoSQL DBs in Django it's so painfully.
FastAPI has good NoSQL DBs support.
And I wanna to use Django and FAST API in one project.
If you have solution of my problem, please drop me a link to solution.
Maybe will be better if I'll use them separately (1 django server and 1 Fast API server) and
frontend will request data from 2 different servers?

Related

Where do I keep ORM in a distributed app?

I am designing a scalable web app. I have APIs (Django Rest Framework) in one container instance, Web App (Django) in another, Database (Postgreql) in another and finally CDN in another (Azurite). I wanted to decouple API since mobile apps will use the same - eventually.
Question:
Where do I keep ORM in this scenario?
If I keep it part of Web apps, then how do the APIs recognize and use
the objects?
Or, if I keep them part of the API services, how do the front end
(web apps) understand the objects?
I'd suggest you keep your DRF code with the rest of Django and containerize them together.
As for the ORM, what matters is the container for Postgres. You cannot tear apart, say, models into a separate container.
To summarize, you can have the following containers:
One for DRF and Django
One for your Database layer (Postgres) for instance.
And one for your CDN.
Needless to say, you could containerize your webserver separately as well.

back-end architecture to integrate with Cube.js

I'm looking for advice choosing a back-end architecture for a web app. In the app, users upload tabular data from multiple files. Their data is then processed, aggregated and visualized. Data is private and each user has their own dashboard.
I believe Cube.js is an excellent choice for the dashboard, but I am wondering what back-end web framework I should integrate it with. I have experience of Django, but would use Express if it had significant advantages.
Thanks for any advice!
Cube.js is designed to run as a microservice. It means there's no requirement for you to use Node.js or Express as a stack for the rest of your backend implementation. However usually you'd need to have separate backend for storing data about users, reports and dashboards if those are dynamic. Cube.js server handles only analytic queries.
Cube.js dashboard templates are designed to work with GraphQL. So any backend web framework where there's a solid support of GraphQL will be a good choice. Most notable ones in Node.js world are apollo-server, Prisma, Hasura. Seems like Python has it's own champion as well: https://github.com/graphql-python/graphene.

Django REST api offline synchronization with PouchDB

I am developing an application which is used by multiple clients and the main goal of the app is to be used online. But a specific requirement is, it should be able to work offline too (only for a single client(s) in an emergency situation and for short time - 24 hours maximum). now I am using Django REST framework for backend and Jquery/AJAX frontend for GET and PUT etc. requests which update PostgreSQL DB on the backend. Now little research on the internet suggests the I should use PouchDB on the frontend and/or CouchDB on the backend. But my questions are:
Is it really possible?
If yes, then which DB should be used for the backend database?
When the offline client become available online, how we can synchronize the data generated online?
Can we cache some data on clients machine for offline availability purpose?
Is it still possible to use PostgreSQL for the backend? (I really want to use it !)

Django: Using a Relational and Nosql database in same project

Can we use relational and nosql database in same django project.
As django package for relational and no-sql(django-nonrel) are different. Is there a way we can use both kind of databases in same project ?
Yes, although it depends on the backend for the NoSQL database. Django-nonrel is not necessarily required for a NoSQL database backend. From my experience, it is possible to use SQLite and Cassandra in the same project. We don't use django-nonrel because the Cassandra backend for Django works fine on vanilla Django.

How to build RESTful Webservice API for PhoneGap application using Django and Mongodb?

I want to build a RESTful webservice api handle phonegap application request.
I am familiar with Python and Django.
Restful webservice is a social network like Twitter, required to use Mongodb. Everyone can post status photo from mobile app to server and can follow anyone. I have read about django-tastypie to build restful api but I want to use mongodb. About mongodb driver for django I have read mongoengein.
What about commbo django + django-tastypie + mongoengien? Is is suitable for me?
There is this https://github.com/mitar/django-tastypie-mongoengine . Weather the tastypie model is the right choice depends on many factors, but it's ability to create a standards compliant REST that works with backbone.js will continue to encourage use. It's pretty nice to extend as well - taking alot of inspiration from the way you define ModelAdmins in django. Not having to come up with your own authentication system or integrate oauth by hand is appealing (but sometimes an existing authentication is required if you are building this into an old application).
I have tried to implement basic API endpoints with plain mongoengine and ran into many serialization issues (ObjectIDs and many other fields) and inability to get relations or easily or control the inclusion and detail of embedded documents, so it is worth at least putting some time into evaluation and tinkering with Tastypie. Like the mongoengine django admin - you wont find 100% seamless recreation of the SQL version but rolling your own solution here is a high level of effort.