Django create and register model backed by mongo - django

I am using Django with pymongo and there are reasons within the team to not use Djongo for MongoDb.
Currently I am stuck at registering a model and set that in AUTH_USER_MODEL.
I have created a custom user to handle auth via Mongo but I am not sure how to register it as AUTH_USER_MODEL as Django needs a real model there.
What is the workaround if any on this?

Related

How to map flask and Django to same database model?

I want to have a database model which is written in Django ORM and the same database is used to read data by flask using SQLAlchemy for microservices.
What is the right way to do this so that I don't have to write model in both django ORM and flask separately?
The django model is required as there is a need of admin functionality and flask will be used to serve data to UI which is written in Angular.

Is there an app for Django to manage fields of models?

Like in phpmyadmin, we have an visual interface to manage fields. Can we do the same thing in Django?
If your Django connected database is e.g. PostgreSQL, you could use pgAdmin4 (https://www.pgadmin.org/). So it is actually not about managing the tables in Django but in a database tool (visually). To manipulate your database schema you will have to use Models in your Django application (https://docs.djangoproject.com/en/2.2/topics/db/models/).

How to make DRF with aliready exists Django app?

I would like to create DRF api.
In my case, I have already existing Django app.
I would like to add api to this existing app.
But I don't know how can I define DRF's models.
There is a using table in the existing app.
So, I run following command
python3 manage.py inspectdb
I think that I'll reuse those models, but I have a complicated custom user model.
How to create DRF app with already existing Django app ?

Authy/Twilio OTP in Django without custom user model

I'm trying to learn how to use Authy/Twilio in a new Django app. I found this helpful demo application https://github.com/TwilioDevEd/account-security-quickstart-django which I was reading through to see how it all worked. I noticed in the settings.py file they referenced a custom user model, which I found here. The custom model looks very basic and doesn't have much of the info stored in the regular user model.
My questions are:
Is it required to use this custom model or can you somehow add the
required info into the existing/default user model?
How would this integrate with Django apps using something else (like
ldap) as the backend instead of the django db user model?

Connecting and importing models from multiple database connections Django

In a django app, I have two postgresql databases connected through settings.py: one is default and other is AppDb. AppDb is placed on a remote machine.
I want to query from a 'Courses' model from AppDb using 'using()' and 'Courses' model is not available in default database.
So my query goes like this:
courseInfo = Courses.objects.using('AppDb').filter(cuser_id = 12)
But I am getting NameError for 'Courses'
Can I have a solution for such queries without using routers
If you have an existing database, you still need to create an app and models for that database in order to use the ORM.
To help you create the model classes, you can use the inspectdb management command which will try to guess the models from an existing database and create the models.py for you. Its not perfect, but it will save you some time.
You will still have to make sure the models have a primary key and are written in the correct order (so that foreign keys will work correctly).