I'm working on a mobile application where the backend is done by Dango but all the authentication and real-time database are in firebase
is there any way to integrate a Django admin with firebase instead of using firebase admin?
if not, can firebase admin be used with python to create an admin role and has the same permissions which Django gives to admin? and how to introduce the created role if possible to Django?
One of the many beauties of Django is the admin interface, which I use all the time. Django relies on certain types of databases - namely relational databases. With NoSQL databases, you lose Django admin. If you want to Firebase with Python, I would recommend Flask.
Related
I have one django project that serves as an API and contains a database and multiple apps with models, database migrations and so on.
I want to have a custom admin interface as well as django-admin which are only accessible via the intranet. Is this possible within the same django project while the other apps are accessible from outside the intranet? And if not, is it possible to have two django projects. One which serves as the API containing the database, models and migrations. And another one that contains just the django-admin and my custom admin interface app that can access the databse and models from the other project?
Your question consists of two parts.
How to share a database between Django Projects? You just need to pass the same database credentials (HOST, DB_NAME, USERNAME, and PASSWORD) to connect to a same database
How to share models? I'll describe two options here.
Creating a Django App to contain your models(Recommended)
You can create a Django app to contain your shared models. This tutorial will explain how to do that.
https://realpython.com/installable-django-app/
Then, you just need to install your app in your Django projects.
Copy Pasting your model code.
You can easily copy and paste your model codes into different projects, but syncing between them would be a problem and is not recommended.
I am going to develop django rest framework apis using postgres legacy database in which apart from the existing tables no other default django tables should be created. I would like to know without creating any django default tables or doing migrations,
can i able to access records from tables using ORM?
Can i able to access admin page without creating django auth table (i.e superuser)?
If no for both questions, only way to connect to db is using any db adapter like psycopg2?
can i able to access records from tables using ORM?
If the schema is same in your models and DB tables, then yes.
Can i able to access admin page without creating django auth table
(i.e superuser)?
As far as I can tell, no, you can't get that, unless your existing 'tables' already have that, and you have all the necessary credentials.
For question in #3, I'd use something less constraining like Flask if you have these problems.
I'm looking at building a django app specifically designed for G-Suite domains. It requires users to be logged in to G-Suite, and would get permissions from groups in G-Suite. I know I could achieve this using django-allauth or similar, but that would involve the django app duplicating the user information in it's own database. In the interests of preventing unnecessary replication, is it feasible to have django directly use Google APIs to handle user logins, but still program the rest of the app in a django kind of a way? Are there any libraries that implement this? If not in django, are there other (python) frameworks that can do this?
After digging many solutions and tutorials, I have confused what is the right way to proceed for my problem, since most of them written in older version of Django. I want a simple user management
Default Django User model + few added fields is fine
Angular front-end will be used for login, logout and to display user specific content, a dashboard and their profile
Next thing to follow is to integrate Mongo db backend replacing default db
I also found out substitution, tweaking user management broke things. I want clean and minimal approach so that it is flexible for code maintenance. I appreciate all sort of suggestions out of experience or otherwise.
First: Extending the user model - django doc link
You can set your own user model using the AUTH_USER_MODEL variable in your setitngs. Your new user model needs to inherit from AbstractBaseUser.
Second: To interact with angular and django - rest api - tastypie
Tastypie is a module in django to create a REST API from your modules. Thi essentially converts models to json formats - which can be used in Angular JS (and can be imported into an angular JS model)
Third: Mongo in django - django-mongodb-engine
Django doesnt support mongodb (or any NoSQL) db by default. So,this has to be done by an extension or a django variant. I went on a spree to find the best NoSQL client for django a year back and could not find any which could be used for a production environment.
If you want NoSQL - I suggest don't use django. Ruby or NodeJS may be more preferrable
In a typical database, admin can assign users and can create tables which can be accessed by only a particular set of users or groups. One can also create queries that can be made by certain users in a database like MySQL.
Does Django provide any such functionality or is is it only the Django ADMIN Interface that does this?
I am aware that the admin can create users and provide them with permissions for working with app models.
Django by itself doesn't provide access to the database-level users / groups / permissions, because it doesn't make much sense for a typical web application where all connections will be made with the same database user (the one defined in settings.DATABASES). Note that it's not a shortcoming be really the standard for web applications.
What Django provides is application-level users / groups / permissions (cf https://docs.djangoproject.com/en/1.8/topics/auth/). You have access to this application-level layer thru the admin but also - of course - programmatically thru the django.contrib.auth package.
Yes, you can do that.
Django defined these models in module django.contrib.auth.models
You can import all models from there like Group, Permission and all.
from django.contrib.auth.models import *
If you want to list all django auth models you can see them in mysql/or other database too by prefix auth_* e.g, in mysql
show tables like "%auth%";
Over these models you can use django ORM.