how to include django templates in app installed via pip? - django

I'm working on a django app (django-flux) and I'm trying to get it to properly install with pip from pypi. From this blog post and the distutils documentation, it seems like my setup.py and MANIFEST.in files should be including the flux/templates/flux/*.html data files, for example, but they are not included when I install the app via pip for some reason.
Any suggestion on what I am doing wrong? How can you install django templates (among other non-python files)?
For reference, I have distutils 2.7.3.

You are missing include_package_data=True in your setup function.
For more information on this you could turn to Flask's excellent documentation which covers writing a Basic Setup Script:
include_package_data tells distribute to look for a MANIFEST.in file
and install all the entries that match as package data.
Then your are importing find_packages but aren't using it so far (packages = find_packages())

Related

Linux python django site-packages not recognized in envelope

I have tried to create envelope on my linux pop os system using miniconda. When I activate it, I can install packages using pip, but when I run my django instance it doesn't find the modules.
If I type which python is shows the miniconda path correctly. I can look in the site-packages folder and see the packages installed.
I've tried installing django-anymail and corsheaders and they are both not being found. It does find my locally installed apps.
If I use the command line and open python and then import, it does not recognize my modules installed in the virtual envelope either. I thought it was a problem with conda, so I also created an envelope using python's native method: python3 -m venv
I have the same problem with it finding pip install site-packages.
Is there a command I can run to show all available packages?
I hadn't realized I had aliased my python. Now it is working.

Is it possible to install a django package without pip?

I am trying to install django-dash to run one of the dashboard examples and see what it's like.
I am on Windows running Python 2.7 and Django 1.6.5. I know the usual approach is to download pip then install the package using pip. However, I am on a work computer with no administrative rights so I can't access my Internet Option Settings to find my proxy URL to follow the instructions below:
Proxy problems
If you work in an office, you might be behind a HTTP proxy. If so, set the environment variables http_proxy and https_proxy. Most Python applications (and other free software) respect these. Example syntax:
http://proxy_url:port
http://username:password#proxy_url:port
I had the same issue when trying to install Django but was able to get it to work by moving the django directory under Python27/Lib/site-packages. Is there something similar I can do with django-dash?
I also tried downloading the sources and running python setup.py install. I received the following error:
File "setup.py", line 3, in <module> from setuptools import setup, find_packages ImportError: No module named setuptools
Link to django-dash: http://django-dash.readthedocs.org/en/latest/
Yes, you can probably get the sources from The Python Package Index
Once you have them, uncompress the files and install them manually (this will depend on you OS).
On Linux systems:
python setup.py build
python setup.py install
Here's the full reference
EDIT : Note that when manually installing those packages, you must also install any missing dependencies, eg. setuptools in your case

using dajaxice and editlive apps in django

So I am pretty new to Django and I am a little confused on how to install apps.
I am trying to get the editlive app to work in Django. This requires dajaxice to also be installed. Both of the instructions for this are very similar, basically it says to change some things in settings.py, urls.py, and add some imports to your main.html.
I did these things, but the instructions don't say what I am supposed to do with the dajaxice, and editlive packages. In each package there is a install.py, should I build and run this? Or am I supposed to just include all the code in with my project?
The python/django community uses a tool called pip to install python packages and libraries. Look up how to install pip on your system (and also look up virtualenv), and then you can simply do:
pip install django-dajaxice
pip install django-editlive

How can I uninstall Django apps?

So I was installing an app in order to bootstrap my Django admin interface, and I thought this app was going to be Project specific but it appears to be installed on a global Django level.
http://riccardo.forina.me/bootstrap-your-django-admin-in-3-minutes/
https://github.com/riccardo-forina/django-admin-bootstrapped
My question is how can I uninstall it if I need to do so at a later date? I wanted my project to be as independent as possible. I was also wondering if there was a way of doing the installation within the project so that people that download my repository will automatically get it.
Also some minor questions are that after adding "add django_admin_bootstrapped into the INSTALLED_APPS list before django.contrib.admin" I was not required to run a syncdb command like we usually are when installing models. I guess this applications doesn't creates tables on my database so that is probably why, but I just wanted to know your thoughts.
I know it is a lot to answer but any clarification is appreciated. Thanks.
If you have installed the django app using pip do:
pip uninstall app_name
Or you have to go manually to your site-packages directory and remove it.
After that,
Remove the app from INSTALLED_APPS. django-admin-boostrapped might have overridden your templates. After you are done, do ./manage.py collectstatic and ./manage.py syncdb
If you're writing something that you want other people to use, and it relies on other packages (whether Django apps or more generic Python packages) it's standard to use pip. This makes it easy to install and uninstall packages, and specific versions of those packages. You can then create a requirements.txt file, which you include with your project. This lets other people know what packages are required, and they can easily install them using pip.
So, first off, install pip.
Then you would install django-admin-bootstrapped by doing:
$ pip install django-admin-bootstrapped
You can also install django using pip:
$ pip install django
If you then do this:
$ pip freeze > requirements.txt
you'll end up with a requirements.txt file that lists any packages you've installed with pip, and which version of each. Include that file with your project when you share it with others (on GitHub or wherever). Those people would then do this, to install the same packages:
$ pip install -r requirements.txt
It would also be worth installing and using virtualenv – this lets you have separate environments for your python work, so that when you pip install something it's only available in that environment. Then you can have different versions of packages (eg, different versions of Django) in each environment. Virtualenvwrapper also makes some of the common virtualenv tasks a little easier.
It's a lot to get to grips with at first, as I know from experience, but it's worth doing so and will make development easier in the long term.
As to your other question, it looks like django-admin-bootstrapped doesn't have any models, so it doesn't require any updating of the database after installation.

django-registration oddity

So I downloaded the app with easy_install and it worked. I can import registration.
BUT the code installed doesn't match the source code for the project, as seen in github. For example, I'm missing the modules backends.urls and tests. I'm also missing key files like auth_urls. Without these modules, the registration app is failing on me.
Could this be related to my directory structure?
My Ubuntu distribution has placed all my python files in /usr/local/lib/python2.6/dist-packages/
as opposed to /usr/local/lib/python2.6/site-packages/
Otherwise, I'm stumped here.
The easy_install version was really out of date last time I tried.
You'll need to either download the source and run python setup.py install from the extracted directory or checkout from the Git repo and run the same command.
I guess that easy_install installing 0.7 version. But in a github you can see 0.8 alpha