3

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.

Mr.Robot
  • 133
  • 2
  • 3
  • 10

2 Answers2

8

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',
    ...
)
gonczor
  • 3,994
  • 1
  • 21
  • 46
3

Check the installation:

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

I guess you have missed this:

INSTALLED_APPS = (
    ...
    'django_extensions',
)
kosist
  • 2,868
  • 2
  • 17
  • 30
ikcam
  • 33
  • 1
  • 3