Without quite knowing the details of your particular project, I can assert that a django app will happily double as a cli app. In fact, I do this almost all the time. The only thing you are now missing is the proper way to import the settings.
Try something like this from django.core.management import setup_environ import settings setup_environ(settings) Geert On Jul 2, 9:25 am, Harsha Reddy <nhar...@gmail.com> wrote: > I using Django from past one week. > > On the Django web site, I read that it is a high-level python web > framework. Inspite of knowing this I am trying to use a Django > application both as a web application as well as a CLI client. > > To know if this works out, I created a Django project named "pyMyApp" > and added an application into it. > I updated the: > > settings.py to detect my application, > also models.py to create two tables. > > I have an other python file in the application which parses XML. This > python file makes use of objects defined in the models.py to store the > parsed values in those 2 tables. > > In the directory "../" where my "pyMyApp" resides, I created a file > index.py added the code to test the parser code. Runnning this file > yeilds: > > python index.py > Traceback (most recent call last): > File "index.py", line 3, in ? > from pyAPP.translator.translate import * > File "/usr/src/pySCAF/translator/translate.py", line 3, in ? > from pySCAF.translator.models import duo, scenario > File "/usr/src/pySCAF/../pySCAF/translator/models.py", line 1, in ? > from django.db import models > File "/usr/lib/python2.4/site-packages/django/db/__init__.py", line > 10, in ? > if not settings.DATABASE_ENGINE: > File "/usr/lib/python2.4/site-packages/django/utils/functional.py", > line 269, in __getattr__ > self._setup() > File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", > line 38, in _setup > raise ImportError("Settings cannot be imported, because > environment variable %s is undefined." % ENVIRONMENT_VARIABLE) > ImportError: Settings cannot be imported, because environment variable > DJANGO_SETTINGS_MODULE is undefined. > > By looking at the trace, I got a thought that "Django is designed to > be used as web framework" > if at all I want to use it both as cli and web apps, how to achieve > this in the case above? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---