Column catalog
- Django dynamically calls model ORM classes
- The Django-request parameter object cannot be modified
- Add a Django project environment to your script
Column details
Django dynamically calls model ORM classes
From django.apps import apps as django_apps # Return all ORMModel information under the specified APP orm = dict([(x._meta.db_table, X) for x in django_apps.get_config(appName).get_models()]) Orm. Get ('table_name')Copy the code
The Django-request parameter object cannot be modified
If you need to change the request json parameter object, you need to change the request json parameter object. If you need to change the request json object, you need to change the request json parameter object. Request.data. _mutable = TrueCopy the code
Add a Django project environment to your script
Import OS import Django os.environ. Setdefault ("DJANGO_SETTINGS_MODULE") "Djangoobjname.settings ") django.setup() # Loading scripts outside of a Django project can use this path to load import sys sys.path.append("Django-Object-Path") os.environ['DJANGO_SETTINGS_MODULE'] = 'DjangoOBJName.settings'Copy the code