Using Profiles in iPython and Django

I have a Django product that I use iPython to interact with.

I try to automatically load modules when the shell starts:

python manage.py shell

I copied .ipython / ipythonrc to the project root directory and added to the file:

import_some module_name model1 model2

However, when I run the shell, these names do not load.

What am I doing wrong?

+3
source share
3 answers

ipythonrc, , django-extensions. , shell_plus, ipython :

python manage.py shell_plus
+5

BryanWheelock , . , , , , .

( python manage.py shell) ipythonrc. :

include ~/.ipython/ipythonrc

execute from django.contrib.auth.models import User
# .
# .
# .
execute import_some module_name model1 model2

, ..

# Setup Logging
execute import sys
execute import logging
execute loglevel = logging.DEBUG
execute logging.basicConfig(format="%(levelname)-8s %(asctime)s %(name)s %(message)s", datefmt='%m/%d/%y %H:%M:%S', stream=sys.stdout )
execute log = logging.getLogger("")
execute log.setLevel(loglevel)
execute log.debug("Logging has been initialized from ipythonrc")
execute log.debug("Root Logger has been established - use \"log.LEVEL(MSG)\"")
execute log.setLevel(loglevel)
execute log.debug("log.setlevel(logging.DEBUG)")
execute print ""

. , .

+1

shell_plus django-extensions , , , ipython. - , .

use start_ipythonipython instead to run the shell embedand pass some arguments to it.

I also wrote a blog post, you can find the detail here

0
source

Source: https://habr.com/ru/post/1711675/


All Articles