Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call_command replacement #23

Open
D3f0 opened this issue Sep 9, 2020 · 1 comment
Open

call_command replacement #23

D3f0 opened this issue Sep 9, 2020 · 1 comment

Comments

@D3f0
Copy link

D3f0 commented Sep 9, 2020

I'm trying to call a djclick based management command using the traditional Django API, django.core.management.call_command and I'm getting this traceback:

Traceback (most recent call last):
  File "_log.py", line 34, in <module>
    call_command('sync_models')
  File "/home/user/.cache/pypoetry/virtualenvs/ht-ZBbfQ9hA-py3.8/lib/python3.8/site-packages/django/core/management/__init__.py", line 135, in call_command
    for group in parser._mutually_exclusive_groups
AttributeError: 'ArgumentParserAdapter' object has no attribute '_mutually_exclusive_groups'

I could do from myproject.myapp.management.commands.my_command import command although the command I'm using is the grouping feature.

What would be the advised methodology to run the command in a programmatic fashion?

@erayerdin
Copy link

erayerdin commented Jul 13, 2021

I had the issue #28. I solved it by using subprocess.Popen.

import subprocess
(stdout, stderr) = subprocess.Popen(["python", "manage.py", "yourcommand"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
# assert something with stdout and stderr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants