80 questions
2
votes
1
answer
51
views
Django manage.py Command KeyboardInterrupt cleanup code execution
do you have an idea how to use signals in custom management commands in Django?
My Command's handle method processes continious stuff which needs to be cleaned up, when Command is interrupted.
Without ...
0
votes
1
answer
45
views
Django-Extensions: how to add local variables to shell_plus
I have multiple dictionaries, and I want each key/value pair to be defined in the local scope of a django-extensions shell_plus session.
My current management command looks something like this:
import ...
0
votes
2
answers
144
views
Unknown command: 'collectstatic' after overriding StaticFIlesConfig
I followed the instructions on https://docs.djangoproject.com/en/5.0/ref/contrib/staticfiles/#s-customizing-the-ignored-pattern-list to override the ignore_patterns in my static files. Here are my ...
0
votes
0
answers
54
views
Confusing Django settings content using manage.py vs call_command
I have a Django command which I can run using manage.py. The command imports django.conf.settings, then I grab Songs from the database to update bits of the settings:
from django.conf import settings
...
1
vote
0
answers
281
views
Kafka and Django management command
Hello everyone hope I find you well!
So I'm trying to setup a new project with Django and a Kafka consumer. I'm using confluent-python package to create my consumer. So I'm facing a very odd situation....
0
votes
1
answer
688
views
How to combine multiple custom management commands in Django?
I wrote a set of commands for my Django project in the usual way. Is it possible to combine multiple commands into one command?
class Command(BaseCommand):
""" import all files in ...
1
vote
0
answers
131
views
How to programatically run custom command for specific schema using django-tenants?
I am new with django-tenants. I want to programatically run a cummand I have created with management.call_command() but I am getting error. Can someone help me with this?
This command runs without ...
0
votes
0
answers
82
views
Passing value from Django custom command to a view
I want to pass value from django custom command to a view.
Custom command:
GDA_frontend/GDA_datatables/management/commands/gda_start.py
class Command(BaseCommand):
help = 'Starts the GDA app with ...
1
vote
1
answer
723
views
Django management command as a package? [duplicate]
I'm trying to have a directory structure for my custom django-admin commands.
According to the Django tutorial, commands are created as modules under the management/commands directory.
e.g.
management/...
0
votes
1
answer
172
views
Scheduled Tasks - Runs without Error but does not produce any output - Django PythonAnywhere
I have setup a scheduled task to run daily on PythonAnywhere.
The task uses the Django Commands as I found this was the preferred method to use with PythonAnywhere.
The tasks produces no errors but I ...
1
vote
1
answer
521
views
Django how to not comment some lines with makemessages
Problem
I translate my group names in my Django application with the default translation tools.
Since my group names are not hard-coded in my code, when I run makemessages, the lines corresponding to ...
6
votes
2
answers
7k
views
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?
0
votes
1
answer
230
views
How to pass extra arguments to startapp command in bash?
I want to pass values to template_context and the docs says:
Any option passed to the startapp command (among the command’s supported options)
What I understand is, that any extra argument that I pass,...
3
votes
2
answers
404
views
What is `*args` in a Django BaseCommand handle function for?
The signature of BaseCommand.handle is handle(*args, **kwargs). The documentation example only uses the kwargs argument.
Are there cases/ways to define command arguments/options such that they will ...
0
votes
0
answers
355
views
How to send data to running django management command?
I have a custom django management command that is constantly running through the supervisor (keep alive)
I need under certain circumstances (for example, a signal in the project, or a change in the ...
0
votes
1
answer
2k
views
How to execute django runserver and python script at the same time (on one line in cmd)
I have wrote a python script which automatically uploads files from a given folder to a django modell. I want this script running while django server is running. My script runs perfectly when I run it ...
0
votes
2
answers
426
views
Heroku django.core.exceptions.ImproperlyConfigured: Set the SECRET_KEY environment variable
I am trying to run a django command on my heroku production server, but get the following error:
Note: The same command works fine in my local dev environment.
I took the following steps:
ssh onto ...
0
votes
0
answers
49
views
Deleting posts via Django command doesn't work
Deleting posts via Django command does not work. I do not know what to do, I am at a dead end. I hope you can help me...
delnc.py File command
class Command(BaseCommand):
help = 'Командa для ...
0
votes
0
answers
283
views
CommandError in django while using call_command(startapp, app_name)
I want to create a Django app from user input. Here is my code.
def createAppname(name):
split_name = name.split(" ")
s = "".join(i[0:] for i in split_name)
...
1
vote
2
answers
1k
views
Django, how to run a command through Windows Task Scheduler
How to schedule and run a specific command in django using Windows Task Scheduler. My django project is not currently local server deployed but using the manual set up just like activating the virtual ...
1
vote
2
answers
4k
views
Visual Studio Code 'django-admin' command not recognized
'django-admin' is not recognized as an internal or external command,
operable program or batch file... So I am getting this error in terminal. I am trying to build an app. First I opened a folder(page)...
0
votes
1
answer
604
views
Django: Can I use a subprocess w/ docker-compose inside a custom command?
I created a custom command in django and I want to use a docker-compose command in it. I use a subprocess as follow:
class Command(BaseCommand):
def handle(self, *args, **options):
data = ...
0
votes
0
answers
412
views
Django command running a shell script
I have an app that deletes files that have been uploaded more than one month ago.
from django.core.management.base import BaseCommand, CommandError
from blacklist_app.models import EntradaHistorial
...
1
vote
1
answer
371
views
How to update existing data and create new one django base command?
i am trying to store data in from json file and i added its not a problem to add data but when i trigger data again again they copy data and create same new one that i don't want , i want that it will ...
6
votes
4
answers
3k
views
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 ...
2
votes
1
answer
1k
views
Django custom command not working with args
I am trying to call the command using args in Django 2.0. When I pass the args it give this error message:
"TypeError: Unknown option(s) for dummy command: args. Valid options are: help, no_color, ...
2
votes
1
answer
3k
views
How to execute python manage.py django management command via button on the website on Heroku
I have a Django management commands that I would like to run. I would like to have it available for a user by clicking the button and it would execute it. I do not need help to write one - I have them ...
4
votes
3
answers
4k
views
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(...
2
votes
1
answer
4k
views
Asynchronous asyncio Django command runs sequentially
I have written a simple command to loop through all of Result objects and check its www field (representing URL of the published scientific result eg. https://doi.org/10.1109/5.771073)
There is 1M ...
0
votes
0
answers
829
views
How to upload file to Django Server with management command?
I am writing a management command to upload a file to my server. I am able to upload the file to media properly when the file is in the project folder. But i couldn't manage to upload a file from ...
0
votes
1
answer
446
views
Python Django call_command permissions gunicorn+nginx
Problem
Receive 502 bad gateway when i try to execute a django management command via gunicorn
Logic Line
I think the problem is about permissions, something like gunicorn is not able call the ...
1
vote
0
answers
361
views
How to prevent django from running multiple instances of a command?
We have a custom command in a django app that performs synchronization of data with an external service.
The command is started hourly.
Usually, the command is finished within half an hour or less, ...
0
votes
0
answers
507
views
Call Django command with phrase as argument
I'm trying to run the command
zappa manage staging 'run_sql --sql \"show databases\"'
But I get the following error:
zappa manage staging 'run_sql --sql "show databases"'
[START] RequestId: ...
0
votes
1
answer
57
views
Trouble understanding how the Django save() handles *args
Was fighting yesterday with the issue of importing pics from URL to the Django model. Was able to come up with a working solution, but still don't know how this is works. How a save func knows what ...
0
votes
1
answer
1k
views
django shell_plus timeit call_command?
I've written a django command and want to see it's timing so inside django shell_plus I do this:
import timeit
from django.core.management import call_command
timeit.timeit("""call_command('prova')""...
2
votes
2
answers
485
views
Django: generate python code from command line
Is here a way to write a Django command to generate code automatically?
In my case: every time I create a new model I must create the following stuff too:
Create Administration classes in admin.py
...
0
votes
0
answers
296
views
Exclude Django Installed Apps while execute custom django command
I have "xxx" in installed apps (settings.INSTALLED_APPS)
Inside this applications, I check on existing schema in Postgresql
If schema not exists I throw the exception.
I request a user to execute ...
-1
votes
1
answer
538
views
Redirect the output of custom Django command to the browser
I have created a custom command which takes a positional and a named optional argument. It does many checks, downloads a file, unzips it and populates the database with the unzipped data.
To make the ...
1
vote
2
answers
620
views
My custom django-admin command won't call celery task
I am trying to write a custom django-admin command that executes a celery task, however the task doesn't execute and django just hangs when I try.
from django.core.management.base import BaseCommand
...
2
votes
2
answers
2k
views
Django: disable initial system checks in production?
I've scoured the documentation and am looking for a Django setting that disables system checks (not just silences them) in production. I have a project with 20,000+ models which are autogenerated to ...
2
votes
3
answers
2k
views
Custom command to upload photo to Photologue from within Django shell?
I have successfully employed Photologue to present galleries of regularly-created data plot images. Of course, now that the capability has been established, an obscene number of data plots are being ...
2
votes
0
answers
800
views
Django custom commands, start and stop a python file
I have a Django project which is used to remotely call a python script with predefined arguments (retrieved as a string from database). The python script is designed to loop indefinitely until killed/...
4
votes
0
answers
3k
views
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 ...
-1
votes
1
answer
1k
views
Run view in command
I have a view to download a file. I want to create a command to be able to call this view and download the file in a certain folder.
class DownloadFile(View):
def get(self, request, pk):
....
1
vote
2
answers
3k
views
Testing Django commands file or stdin
I am writing a django command that takes a bunch of input and processes it.
It seems natural that because of the volume of the data, the input should either come in as a file or as stdin.
I would ...
0
votes
1
answer
135
views
Modifying Django Command argument
Lets say i have a command like:
class Command(object):
help = 'roll over and die'
def add_arguments(self, parser):
parser.add_argument(
'--foo',
help='see ...
0
votes
1
answer
649
views
Dumping database & migrate to new DB using django management command
class Command(BaseCommand):
args = 'Arguments is not needed'
help = 'Django admin custom command poc.'
def handle(self, *args, **options):
db_alias = options.get('olddb')
...
3
votes
1
answer
4k
views
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....
12
votes
2
answers
16k
views
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 ...
1
vote
2
answers
410
views
Run Django command from crontab, only one concurrently
I have a Django commend "script" that i running every 20 second
like this:: (only shows part of it, and works fine ;))
* * * * * /manage.py btupdate
* * * * * sleep 20; /manage.py btupdate
* * * * * ...