Revision: 59343
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 1, 2012 07:15 by scrapy
Initial Code
# This snippet is useful when you want to use a django project which runs in a Python virtual environment. """ This code should be executed before the imports you need from your django project For example, you can place it at the end of your settings.py """ import sys, os # Add the directory containing your django project 'myproj' to the path sys.path.insert(0, '/django-projs/') # Set the django settings environment variable os.environ['DJANGO_SETTINGS_MODULE'] = 'myproj.settings' # Activate the virtual environment used in the django project execfile('/path/to/virtual/env/bin/activate_this.py', {'__file__': '/path/to/virtual/env/bin/activate_this.py'}) # Now you can import any model, for example from myproj.myapp.models import MyModel # Snippet imported from snippets.scrapy.org (which no longer works) # author: anibal # date : Aug 16, 2010
Initial URL
Initial Description
Initial Title
Use a django project with virtualenv from Scrapy
Initial Tags
django
Initial Language
Python