Return to Snippet

Revision: 59343
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

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
    {'__file__': '/path/to/virtual/env/bin/'})

# Now you can import any model, for example
from myproj.myapp.models import MyModel

# Snippet imported from (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

Initial Language