4

I am unable to run python script inside my django project.

  1. I have create a directory with mkdir scripts
  2. Then I use touch scripts/__init__.py
  3. Then I create my python script using touch scripts/update_keyword.py
  4. here is the code of my script

def run():
    # Fetch all questions
    print("run script")


Then I run my script with the help of the following command:

python manage.py runscript update_keyword.py

Now I am getting following error:

Unknown command: 'runscript'
Type 'manage.py help' for usage.


I have follow this blog https://django-extensions.readthedocs.io/en/latest/runscript.html . Kindly Help.

6
  • 3
    have you added django_extensions in installed apps ?? Commented Mar 11, 2019 at 13:04
  • write a bash script which will call your python script. Please check your export path. @saiful Commented Mar 11, 2019 at 13:10
  • 1
    You're using django-extensions so you should make sure you follow the installation instructions Commented Mar 11, 2019 at 13:10
  • please don't change your question to a follow-up question once it was answered. Create a new question. Commented Mar 11, 2019 at 13:12
  • Thanks all . I have added django_extensions but getting database issue. I have update the answer. Please have a look. Commented Mar 11, 2019 at 13:13

2 Answers 2

10

Django does not know this command since it is not listed anywhere. When you want to run a command with manage.py, use Django's Admin Command.

EDIT Or if you really want to use django_extensions for some reason, use their GitHub docs as reference. There it states you need to add this app to INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'django_extensions',
    ...
)
Sign up to request clarification or add additional context in comments.

1 Comment

Use pip install django-extensions to install django-extention.
4

Check the installation:

https://django-extensions.readthedocs.io/en/latest/installation_instructions.html

I guess you have missed this:

INSTALLED_APPS = (
    ...
    'django_extensions',
)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.