Allows for a quick startup loading commonly used classes, installed apps, and console utils.
To use: After manage.py shell, enter from somepath.startup import *.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | '''
Allows for a quick startup loading commonly used classes, installed apps, and console utils.
To use: After manage.py shell, enter from utils.management.startup import *
'''
from django.conf import settings
from django.db import connection, models
# Load each installed app and put models into the global namespace.
for app in models.get_apps():
exec("from %s import *" % app.__name__)
def last_query():
"Show the last query performed."
return connection.queries[-1]
#===================================================
# Add commonly used modules, classes, functions here
#===================================================
from django import forms
import os
from datetime import datetime
|
More like this
- Form field with fixed value by roam 3 days, 3 hours ago
- New Snippet! by Antoliny0919 1 week, 2 days ago
- Add Toggle Switch Widget to Django Forms by OgliariNatan 2 months, 4 weeks ago
- get_object_or_none by azwdevops 6 months, 3 weeks ago
- Mask sensitive data from logger by agusmakmun 8 months, 2 weeks ago
Comments
Please login first before commenting.