Questions tagged [django-commands]

django-commands refers to Django's django-admin.py and manage.py management commands used for common administrative tasks.

django-commands refers to Django's django-admin.py and manage.py management commands used for common administrative tasks.

See also:

77 questions
28
votes
2 answers

Why is run called twice in the Django dev server?

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…
Taymon
  • 24,950
  • 9
  • 62
  • 84
26
votes
5 answers

How to make db dumpfile in django

I want to make a dump in django irrespective of database I am using and can be loaded later. The command 'dumpdata' is perfect for this, but it is printing output on console. More over I am calling it using call_command function so I cannot store…
Paritosh Singh
  • 6,288
  • 5
  • 37
  • 56
25
votes
1 answer

Can Django manage.py custom commands return a value? How, or why not?

Following the documentation: https://docs.djangoproject.com/en/dev/howto/custom-management-commands/ I created my own custom command (called something else but example shown below): from django.core.management.base import BaseCommand,…
Alf
  • 832
  • 1
  • 8
  • 17
12
votes
2 answers

Django: AttributeError: 'NoneType' object has no attribute 'split'

I'm trying to build a static site generator using Django (because its resourceful that way), and right now my problems are dealing with the Django command that is supposed to build my static site content into a directory. Apparently my 'NoneType'…
JellisHeRo
  • 537
  • 1
  • 7
  • 17
9
votes
1 answer

call_command argument is required

I'm trying to use Django's call_command in a manner very similar to this question without an answer. The way I'm calling it is: args = [] kwargs = { 'solr_url': 'http://127.0.0.1:8983/solr/collection1', 'type': 'opinions', …
mlissner
  • 17,359
  • 18
  • 106
  • 169
9
votes
1 answer

Celery-Django: Celery vs django management commands

I work for a travel company where we need to send periodic mails to our teams . Since now I have been using django management commands and running them using crontabs. I was reading about what celery can do, but I am finding it really hard to…
Deepankar Bajpeyi
  • 5,661
  • 11
  • 44
  • 64
7
votes
2 answers

How to specify a parameter of type Array into a Django Command?

It is straight forward creating a string parameter such as --test_email_address below. class Command(BaseCommand): option_list = BaseCommand.option_list + ( make_option('--test_email_address', …
Houman
  • 64,245
  • 87
  • 278
  • 460
4
votes
4 answers

Group Django commands to a folder inside the same app

Is it allowed to group custom Django commands to separate folders inside the same Django app? I have a lot of them and wanted to group them logically by purpose. Created folders but Django can't find them. Maybe I'm trying to run them wrong.…
wowkin2
  • 5,895
  • 5
  • 23
  • 66
4
votes
0 answers

Extending django's `runserver` command adding arguments

In an attempt to try to generalize a django app, so it can be run with different configurations defined in yaml files, I wanted to extend the runserver command to take the locations of these configuration files as arguments. I followed a guide by…
ryanjdillon
  • 17,658
  • 9
  • 85
  • 110
4
votes
1 answer

Redirection in Django command called from another command results in extraneous newlines. How can I fix this?

The Setup For the purpose of illustrating the problem, I have created these commands in my project: foo.py: from django.core.management.base import BaseCommand from django.core.management import call_command class Command(BaseCommand): def…
Louis
  • 146,715
  • 28
  • 274
  • 320
3
votes
2 answers

Django override startapp | startproject commands

I need to create a Django Project with a different files and folder structure. In particular I need to add 2 folders: qqapp and qqproject when creating a new app through the startapp command, each containing some base files. How can I override the…
3
votes
2 answers

How to get a list of all custom Django commands in a project?

I want to find a custom command in a project with many apps, how to get a list of all commands from all apps?
Sashko Lykhenko
  • 1,554
  • 4
  • 20
  • 36
3
votes
3 answers

Django management command does not show logs of my library

This question is a simpler version of this 4 years old question without answer Django management command doesn't show logging output from python library: I have a command: class Command(BaseCommand): def handle(self, *args, **options): ... …
Benjamin
  • 3,350
  • 4
  • 24
  • 49
3
votes
1 answer

How to filter using an expression in Django

I'd like to filter that implements this "pseudocode": Post.objects.filter(Post.timestamp + Post.duration > datetime.datetime.now()) I also would like to wrap this in a Django management command. Any help would be great!
Kaesekante
  • 109
  • 1
  • 9
3
votes
1 answer

Django manage.py do not show commands of an app

I'm using Django 1.4 and have a project similar to the following: project/ __init__.py app1/ __init__.py models.py views.py management/ __init__.py commands/ …
se7entyse7en
  • 4,310
  • 7
  • 33
  • 50
1
2 3 4 5 6