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. Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
  3. Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
  5. Help text hyperlinks by sa2812 1 year, 8 months ago

Comments

Please login first before commenting.