Questions tagged [django-management-command]

51 questions
17
votes
3 answers

Spurious newlines added in Django management commands

Running Django v1.10 on Python 3.5.0: from django.core.management.base import BaseCommand class Command(BaseCommand): def handle(self, *args, **options): print('hello ', end='', file=self.stdout) print('world',…
wim
  • 338,267
  • 99
  • 616
  • 750
15
votes
1 answer

Add confirmation step to custom Django management/manage.py command

I created the following custom management command following this tutorial. from django.core.management.base import BaseCommand, CommandError from django.contrib.auth.models import User from topspots.models import Notification class…
elethan
  • 16,408
  • 8
  • 64
  • 87
8
votes
1 answer

Testing django custom management command

I'm struggling with an issue related to a django custom management-command. Here's the custom management-command code to load data from json file: import time import json import sys from cycu.models import hfModel from django.db import…
grillazz
  • 527
  • 6
  • 15
6
votes
1 answer

How to call pytest-django from python manage.py test?

I have made my custom management command called pytest_wrp So when I call python manage.py test This bit of code is called: class Command(test.Command): def handle(self, *args, **options): super(Command, self).handle(*args, **options)…
6
votes
3 answers

django-admin makemessages --no-obsolete doesn't seem to be working

First of all, I am expecting --no-obsolete would comment out msgid and msgstr if gettext is deleted, right? How I am testing is: I wrote gettext("some string here") in view I ran makemessages command It wrote a .po file as expected Then I…
6
votes
2 answers

What is the purpose of default=False in django management command

I'm trying to write a management command in django. According to the documentation default is set to False. I would assume that the default is the default value of the argument that is being passed. Make django custom management command argument…
acquayefrank
  • 474
  • 5
  • 21
5
votes
1 answer

Multiple arguments with values to custom management command

How do I pass multiple arguments with values, from command line, to a custom django management command? def add_arguments(self, parser): parser.add_argument('str_arg1', nargs='+') parser.add_argument('int_arg2', nargs='+', type=int) When I…
Ovidiu
  • 131
  • 1
  • 11
4
votes
1 answer

How to run migrations on specific database using call_command() in Django?

I'm just wondering what the correct syntax is for calling $ python manage.py migrate app_name --database db_name with the management.call_command() function at runtime. So far, I have the following: from django.core import management from…
3
votes
1 answer

Passing in date string to Django management argument

I have a Django management command, which I pass like this: python manage.py tenant_command generate_weekly_invoice --start_date 2020-11-30 00:00:00 --end_date 2020-12-06 23:59:00 --schema=schema_name This doesn't work and I get an error saying…
Rutnet
  • 1,533
  • 5
  • 26
  • 48
3
votes
1 answer

Why is Idle Python Thread Consuming upto 90% of CPU?

This is my first threading program. I'm facing a strange issue here. I'm building a simple scheduler like application in Django, where function names (to be executed periodically) will be stored in Django Model along with their next execution time.…
3
votes
1 answer

Django management command without working db connection

I have a number of projects that use the following configuration model: settings.py includes default configuration and config specifications, mainly used for development purposes. The default settings (including db settings) can be overridden by…
dgeorgiev
  • 919
  • 7
  • 22
2
votes
1 answer

Is it possible to create a django_tenant_superuser via management.call_command?

I'm building a multi-tenant project with django-tenant. The issue I'm encountering is that "password" is not a valid flag option. management.call_command( 'create_tenant_superuser', interactive = False, username =…
2
votes
1 answer

Nested management commands in Django

Is there anyway to create nested management commands in Django, similar to what the docker and kubectl have? For example, let's say I need to have the following structure: |-->manage.py |-->restaurant |-->list |-->get …
Johnny Metz
  • 5,977
  • 18
  • 82
  • 146
2
votes
0 answers

Turn off redundant output in manage.py in PyCharm

I see lots of redundant output from libraries like Pillow or requests when using them in management command in PyCharm 2017.2.4: I did not configure any additional logging for this libraries. Is it possible to turn it off?
artem
  • 16,382
  • 34
  • 113
  • 189
1
vote
1 answer

Django Management Command not workingcif i run for loop

I write this management command but not working from django.core.management.base import BaseCommand from name.models import ProductName class Command(BaseCommand): def handle(self, *args, **options): ids=id[2704, 2709, 2711, 2824, 2825, 2826,…
1
2 3 4