On Sun, Jun 9, 2013 at 4:04 PM, Ji H Park <jhp...@gmail.com> wrote:

> After going through the basic tutorials on django 1.5, I went on to the
> advanced tutorial on how to create reusable apps.
>
> My OS is windows7 and I'm using virtualenv to create the virtual
> environments. I keep all the virtual environments for django in:
> C:\Users\light\django-projects
>
> In the django-projects folder, I initially I ran the command: virtualenv
> --nosite-packages django-tutorial, then in that directory as suggested by
> the tutorial I created a django project called "mysite":
> C:\Users\light\django-projects\django-tutorial\Scripts\mysite
>
> After going through the basics of the tutorial I had the poll app ready to
> be packaged as a resuable django app. Then I tried to install that app by
> following the instructions in "advanced tutorial on how to create reusable
> apps" tutorial.
>
> The issue here is that when I run the command: setup.py install --user
> within "django-polls" app, polls app gets simply copied
> into: 
> C:\Users\light\django-projects\django-tutorial\Scripts\django-polls\build\lib,
> but I expected it to be copied into the mysite django project.
>

It sounds like there has been some confusion here about the role of a
Django project, and how to use a virtualenv.

There's no formal connection between a Django project directory and a
virtualenv.

A virtualenv is just a way to isolate a particular running Python runtime
-- making sure that packages installed in one virtualenv don't affect
another virtualenv. When you install a package into a virtualenv, it is put
into the virtualenv's directory -- using the approach you've described,
that means it will be put in the Scripts directory of your virtrualenv.

A Django project is just a Python package. It holds no special significance
in the context of a virtualenv.

If your Django project uses another package (i.e., a reusable app), the
reusable app *doesn't* need to be "in" your Django project, in the sense of
being in the same directory. It just needs to be discoverable in the Python
environment -- and if you're using a virtualenv, that means being
discoverable inside your virtualenv. By installing the reusable app in your
virtualenv, you've met that requirement; if you start a Python shell, you
should find that you're able to import the packages of the reusable app.

In fact, it's a good idea to keep your reusable apps separate from your own
project code, so that it's easy to use version control. You only want to
track changes in your own code, not the code of other apps; other apps are
tracked using their own version numbering scheme.

How would I setup virtualenv so that when I'm install a django resuable
> app, it will automatically be copied into the correct django project?
>

This is something you *don't* want to do. Don't think of your Django
project as a directory containing all the code needed to run the project,
including a copy of all apps. Think of it as the glue code that is needed
to tie together all the reusable parts together. You don't need to have
everything in the same directory in order to glue them together.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to