django-manage.py

How do I preload imports into Django's manage.py shell command?

寵の児 提交于 2019-12-05 00:50:22
When I run manage.py shell on my Django project to take a peek at something there are common imports that I always want to run at the start of the shell (e.g. I always want to import my model files.) How can I have these run automatically everytime I run the shell command? 2nd related question, when I hit the up arrow I get the "^A" character instead of the previously run command in the manage.py shell (and in my regular python shell), how can I fix this so it loads the previous command like on the Linux/Unix command line? For the first question, look at the manage.py shell_plus command

How does one use Django custom management command option?

主宰稳场 提交于 2019-12-03 04:46:19
问题 The Django doc tell me how to add an option to my django custom management command, via an example: from optparse import make_option class Command(BaseCommand): option_list = BaseCommand.option_list + ( make_option('--delete', action='store_true', dest='delete', default=False, help='Delete poll instead of closing it'), ) Then the docs just stop. How would one write the handle method for this class to check whether the user has supplied a --delete option? At times Django makes the easy things

Django's manage.py shell won't indent

狂风中的少年 提交于 2019-12-02 02:20:33
问题 I seem to have run into a strange bug or more likely some setting I am unfamiliar with on my system that is not allowing me to tab when I am in Django's shell ( python manage.py shell is how I run it). For obvious reasons this is proving to be annoying since I can't do any loops or conditonals in the shell. If I hit tab it completes all functions that are available to me, like bash does in a terminal. I've tried just using spaces for my indents but I always get an indentation error. Does

Django's manage.py shell won't indent

不羁岁月 提交于 2019-12-01 21:47:50
I seem to have run into a strange bug or more likely some setting I am unfamiliar with on my system that is not allowing me to tab when I am in Django's shell ( python manage.py shell is how I run it). For obvious reasons this is proving to be annoying since I can't do any loops or conditonals in the shell. If I hit tab it completes all functions that are available to me, like bash does in a terminal. I've tried just using spaces for my indents but I always get an indentation error. Does anyone know why this is happening and what I can do to get tab to work in my shell again? (It may be

ImportError: No module named django.core.management when using manage.py

那年仲夏 提交于 2019-11-30 11:53:04
问题 I'm trying to run python manage.py runserver on a Django application I have and I get this error: Traceback (most recent call last): File "manage.py", line 8, in <module> from django.core.management import execute_from_command_line ImportError: No module named django.core.management Here is the output of pip freeze | grep -i django to show I do in fact have Django installed: Django==1.6.5 django-cached-authentication-middleware==0.2.0 django-cors-headers==1.1.0 django-htmlmin==0.7.0 django

ImportError: No module named django.core.management when using manage.py

两盒软妹~` 提交于 2019-11-30 02:02:23
I'm trying to run python manage.py runserver on a Django application I have and I get this error: Traceback (most recent call last): File "manage.py", line 8, in <module> from django.core.management import execute_from_command_line ImportError: No module named django.core.management Here is the output of pip freeze | grep -i django to show I do in fact have Django installed: Django==1.6.5 django-cached-authentication-middleware==0.2.0 django-cors-headers==1.1.0 django-htmlmin==0.7.0 django-static-precompiler==0.9 djangorestframework==2.3.14 Also, trying to run /usr/local/bin/python2.7 manage

Why is run called twice in the Django dev server?

余生长醉 提交于 2019-11-27 22:21:34
I want to make the Django development server do something before it starts running. To do this, I created a new app, added it to the top of INSTALLED_APPS , and then created a management/commands/runserver.py file in the app with the following code: from django.contrib.staticfiles.management.commands.runserver import Command as RunserverCommand class Command(RunserverCommand): def run(self, *args, **options): self.stdout.write('About to start running on ' + self.addr) super(Command, self).run(*args, **options) (The thing I actually want to do is more complicated than writing one line to stdout

Why is run called twice in the Django dev server?

心不动则不痛 提交于 2019-11-27 02:24:31
问题 I want to make the Django development server do something before it starts running. To do this, I created a new app, added it to the top of INSTALLED_APPS , and then created a management/commands/runserver.py file in the app with the following code: from django.contrib.staticfiles.management.commands.runserver import Command as RunserverCommand class Command(RunserverCommand): def run(self, *args, **options): self.stdout.write('About to start running on ' + self.addr) super(Command, self).run