Saturday, August 27, 2011

Re: Help with Django code.

You haven't said which OS you use. If you are in a unix-based
environment, I found this article very helpful.
http://www.juiceanalytics.com/writing/django_settings_module/
Good luck

On Aug 26, 5:28 am, Yaşar Arabacı <yasar11...@gmail.com> wrote:
> Try this, always worked for me,
>
> import os
> import sys
> # assuming this file resides at the same directory at settings file
>
> PROJECT_FOLDER = os.path.abspath(os.path.dirname(__file__))
> UPPER_PATH = os.path.abspath(PROJECT_FOLDER + "/../")
>
> sys.path.append(UPPER_PATH)
> os.environ['DJANGO_SETTINGS_MODULE'] = "project_name.settings"
>
> """
> At this point, you can do anything with django, as django setting module
> environment variable is set
> and your project is in pythonpath
> """
>
> 2011/8/26 akaariai <akaar...@gmail.com>
>
>
>
>
>
>
>
>
>
> > On Aug 25, 10:26 pm, Dr00p <jvbyto...@gmail.com> wrote:
> > > Hi, I need to get Django to run in my code and I am having trouble.
> > > Every time I try to import my project (this is a seperate code I
> > > created to generate polls) it gives an import error and says
> > > DJANGO_SETTINGS_MODULE is not defined.
> > > I have tried multiple things like
> > > django.core.management.call_command('syncdb',
> > > 'settings=mysite.settings')
> > > django.core.management.call_command('syncdb', "pythonpath='/home/guest/
> > > Downloads/Site/Django/mysite'")
> > > But those give me the same error!
> > > I am trying to import mysite.polls but it won't let me.
> > > I have been trying to do it with out using manage.py because I don't
> > > know how to do it with manage.py
> > > If their is a way to use manage.py in my code I would but I personally
> > > can not figure it out.
>
> > Try to start your code with:
>
> > import settings
> > from django.core.management import setup_environ
> > setup_environ(settings)
>
> > > Any way you can help is great.
> > > If I am being to vague, I need to generate thousands of polls(even if
> > > you think this is stupid just ignore it), and to do that I created a
> > > script and I need to import my project but it will not allow me.
> > > I am in dire need of help!
>
> > --
> > 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+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --http://yasar.serveblog.net/

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment