How to set the value of PATH variable in a virtualenv? - django

I have installed virtualenv and created a virtualenv directory for testing out the newer development version of django.I git cloned the latest version of django and placed .pth file inside the virtualenv's site package directory to the cloned django dir.Now I need to modify the PATH variable(to include django/bin) so that django-admin.py is accessible from the virtualenv.How can i do it?
My current PATH in virtualenv includes a directory
django/core/django/bin
Why does it include it ?
I haven't done any modification to PATH right now.
--I've given the relative path of the django directory here instead of the fullpath to mimnimize the clutter.

It's far easier to pip install using the repo itself. Then, all the linking is done for you automatically:
Just use:
$ pip install svn+http://code.djangoproject.com/svn/django/trunk/#egg=django
And, you're ready to roll.

Related

Where are Django registration redux defaut files stored

After I pip installed django-registration-redux, I want to modify its defaul froms.py, registration/registration/, but can not find that directory. And can not find the default files in any directory. Anyone know how to access those files thanks a lot!
You can check the file location of a python module (it could be pip installed) using .__file__. E.g.
>>> import registration
>>> registration.__file__
'/some/path/to/site-packages/registration/__init__.py'
This should help you locate where the module is physically located on your machine.
Pip installed package files are downloaded into the site-packages directory of your Python installation or virtualenv. You can use python itself to locate the directory:
python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
With that being said, you should avoid modifying files in site-packages. Any changes you make are likely not tracked in version control. Consider either forking the project and installing directly from git, or download the source and add it to your project.
You can find it in the site-packages folder of your python installation. Hopefully you're using virualenv and then your in use python is in the lib folder from the virtualenv folder of your app.
Probably is not a good thing to modify the package itself. You can subclass any of the default forms or views in your project code and add fields, modify validation, etc.

Django installation with python

My intent is to create a project in Django for which I installed pip,virtualenv and django packages. Python was installed my default on my OS X mavericks. The location for python is /usr/bin whereeas the packages I installed using pip (and including pip) werr by default installed into /usr/local/bin.
A post I read advises that these paths for python,virtualenv and pip should be the same(/usr/local/bin). I dnt have that going for me. I also checked my ~ directory and I dont see any .bash_profile file available with any PATH variable set.
Do I have to ensure that these paths are the same because I cannot seem to move python istall to /usr/local/bin where all my packages reside.

Moving django app from virtualenv site-packages folder to projects root directory

New to django… i'm wondering if there is a way to move an app which i installed with pip in virtualenvs site-packages folder to my projects root directory.
I ask this because in my current case i'm using django-cms aldryn-blog and if i modify it's data in site-packages my changes wont be deployed because on server i install everything with pip from requirements. So i think the best would be to take the site-packages i want to modify to my project root directory because this way i wont forget about them when i deploy my site.
Is this clever and how could i do this?
Yes you can, an it is a normal thing to do. Just copy the folder from site-packages or download it directly on PyPI or GitHub. Don't forget to add the apps to the settings.
you could maybe just download it from github?
https://github.com/aldryn/aldryn-blog
And remove it from requirements of course, put it somewhere in your app directory or home directory and change the path in your INSTALLED_APPS accordingly
You can have it both ways:
Download the entire package to where it is most convenient for you to work on.
Install it in development/editable mode using pip install -e dirname (where dirname is the directory containing setup.py).
This will crete a .pth file in site-packages pointing to where you put your sources. You can do this in your requirements.txt file too (-e path/to/package).

How to import a Django app from Git into a project

I want to include a Django app into the project I'm working on. The app is hosted on Github ( https://github.com/lmorchard/django-badger ). As well as the app's directory containing the goodies, there are some files in the root - README, LICENCE, TODO and setup.py. If I clone the app into my project's root directory, the app folder will be in the correct place, but those root files will be in my project's root. How can I add the app while still tracking the upstream code in Github?
I had a similar issue where I was working on two independent projects where both were in a repo, and one of them used the other as an app:
Create a virtualenv and install all dependencies for both projects. I usually like to have a virtualenv for each project/repo but in this case you need one env which can execute Python from both repos.
Clone both repos to independent location. Do not clone the depending app inside the other project. Your file-structure then might look like this (assuming Django 1.3 project layout):
project/
manage.py
project/
__init__.py
settings.py
...
...
app/
README
...
app/
__init__.py
models.py
...
And final step is to create a symlink (or shortcut on Windows) from the app directory which has __init__.py in it to the project path.
$ ln -s /abs/path/to/app/app /abs/path/to/project/
Now you can use the virtualenv to run the project!
The final result is that you have two independent repos however one of projects is using the other project without directly copying the code, hence allowing you to maintain two repos.
U can install it by running
python setup.py
or through pip
sudo pip install -e git+https://github.com/lmorchard/django-badger#egg=django-badger
Clone the repository from github using git://github.com/lmorchard/django-badger.git. Then open the cloned folder in terminal. Install the app using the command sudo python setup.py install. This will work good. If you want to have the app included in your project, create a folder named badger(or anything you wish) and copy the installed app from dist-packages to created folder.

Installing python packages in a custom dir

I installed "django-openid-auth" and it copied the egg to the django installation directory. I would like my installations to happen in a "plugins" directory within the django app. How would I do this? I checked options under python setup.py --help but couldn't find anything. Can I just copy everything from the site-packages folder into the plugins folder?
"Custom Installation"