Login

Hackish Way to Execute on manage.py Action

Author:
joshua
Posted:
March 1, 2007
Language:
Python
Version:
Pre .96
Score:
1 (after 1 ratings)

It's cheap, hackish, and dirty, but it works. \o/

Lines 19 & 20 are what you should edit.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
from django.core.management import execute_manager
import sys

try:
    import settings # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
    sys.exit(1)

if __name__ == "__main__":
   
    try:
        action = sys.argv [ sys.argv.index('manage.py')+1 ]
    except:
        action = sys.argv [ sys.argv.index('./manage.py')+1 ]
   
    if action == 'syncdb':
        pass
       
    execute_manager(settings)

More like this

  1. Treat empty value on DateRangeFilter as a filter for non filled dates by kmmbvnr 1 month ago
  2. Django Settings Assignment Expressions aka Walrus Operator example by webology 2 months, 1 week ago
  3. codigo alto nivel by MrRocklion 4 months ago
  4. Load template from specific app by Krzysiek555 4 months, 3 weeks ago
  5. PostgreSQL JSON subqueries by dolamroth 4 months, 3 weeks ago

Comments

Please login first before commenting.