Django with MongoDB can't get django admin panel? - python

Is it true that it's a bad choice python with non-relational database like MongoDB ?
I heard if i use mongoDB as my database in my djanog project i can't use default admin panel of django in my projects as it's designed with Relational database m ethology ?

Sure you can use mongoDB with all Django features. Checkout Django non-rel documentation and decide yourself. http://django-mongodb-engine.readthedocs.io/en/latest/

Related

Does the django-rest-framework provide an admin site to manage models?

I'm looking to setup a REST API server with django, and googling suggests this is best done using the django-rest-framework.
The API will return objects stored in a database, and I would also like to be able to add/modify the objects in the database using the django admin site. However, looking at the django-rest-framework documentaion, I see no reference to the admin site (I did find things about "AdminRenderer", but it looked like this isn't what I want).
Simply, does the django admin site exist for a django-rest-framework project?
Simply use the django admin panel provided by django:
Step 1: create superuser
python manage.py createsuperuser
Step 2: run server
python manage.py runserver
Setp 3: Enter the admin site with the newly created credientials
127.0.0.1:8000/admin
Learn more form official documentation:
https://docs.djangoproject.com/en/3.1/intro/tutorial02/#creating-an-admin-user
you can also use the AdminRenderer of django-rest-framework for CRUD operations for using in this purpose as well.
https://www.django-rest-framework.org/api-guide/renderers/#adminrenderer

Call Postgresql procedure from Django

I am using Postgresql in Django and Python,and I do all the CRUD operation successfully but I don't know how can I call Postgresql procedure from Django and show the result in my web application!!
This should be completed using Django's ORM (Object Relational Mapper) querysets which is a Django wrapper that adds a layer of abstraction above an SQL query that retreives a given dataset from PostgreSQL (or another supported database).
Indeed, the existence of this layer is in place for security reasons in addition to enabling a developer to use any of the supported underlying databases (SQLite3, PostgreSQl, MySQL, Oracle or Maria DB (Django 3.0+)) by simply switching out the database credentials and settings.
The rendering of the datasets will be completed with either Django's templating system if you're usind Django across the entire stack. It could also be completed by creating APIs and using a front-end framework to render from them.
You should Google Django ORM and Datasets for further information, documentation and tutorials to achieve this.

How to use custom Django backend?

I'm developing an app in Django which uses an existing database with created users.
I set my database configuration parameters to a PostgreSQL server and I perform my custom queries through "connections" library.
The problem comes when I want to use my own table to authenticate users. I saw many tutorials and blog posts and I rewritten my authentication backend. But when I want to use my own table to authenticate users and set sessions, Django's Framework only allows me to use User object.
I think these object is linked to Django tables in database and when I want to authenticate an user shows me a message saying the relation "auth_user" doesn't exists. This means that User object is linked to this table.
Does there, exist some method to use my own table with Django Authentication Backend or should I use it?
To use custom Django model with existing Django login backend
AUTH_USER_MODEL = 'myapp.MyUser'
Django docs
To use custom Django authentication backend
AUTHENTICATION_BACKENDS = 'myBackend'
Django docs

Python restful API tools selection when DB tables already created

I used Django REST framework to write API, the Django ORM is really conveinent like DB migrate or relation field's query.
But now we have a case, there is a DB with about 30 tables with data in it. And we have to query the DB and write some API. So I think I can't use Django this time.
What develop tools do you recommand to write restful API in Python if your case have the database that already created tables in it?
You can use inspectdb command to create django models from existing database.
python manage.py inspectdb > models.py
Here is the docs: Integrating Django with a legacy database

Modifying django admin site to accommodate mongodb

I have read some posts such as
Django admin site with mongodb
. However, most posts are extremely outdated (like using django 1.3) and links fail to open. So I decided to repost.
I am using django 1.8 and I am trying to make the django admin site display my collections in mongodb just as it would for relational databases. I use mongoengine for ORM so I have classes in models.py to correspond to mongo collections. My mongo collections all have a predefined structure and doesn't contain Listfields that would confuse the django admin site. How should I go about modifying the django admin site to make it accommodate mongodb?

Categories

Resources