Snippet List
This snippet is based on 928.
I've added the support to update a custom folder, using shell arguments.
It requires the argparse module.
You can install it with:
pip install argparse
Usage:
# Updates repositories in the specified <folder path>
# The default is the ./ folder
update_repos --path <folder path>
# List available options
update_repos -h
Alessandro Molari
- update
- applications
- svn
- git
- baazar
- mercurial
- repositories
I never found a good snippet or tutorial to get the app_list (in django.admin) on other pages except the index page. So i started asking on irc j00bar has given me a very nice answer, but first i didn't know what to do with it till now.
Anyways this snippet is very handy for the people who wants this but don't know how to get it.
This is special made for the django version 1.1
Installation is quite easy, it is a context processor, so download this file put anywhere in your project, i got it in a app called cms_theme (theme and template related stuff.) and put the location in your settings.py file, example:
`TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'****cms.cms_themes.context_processors.theme',
'****cms.cms_themes.context_processors.applist',
)`
The '****' stuff is nothing, i replaced my company name with it.
Of course you may put the context processor anywhere else, that is your choice.
Good luck!
Alexander
- django
- models
- admin
- python
- applications
- app_list
- app-models
How to make this work:
* Put the code into your settings.py (or even better, local_settings.py if you have one)
* Put 3rd party apps you'd like to use into the directories specified in APP_DIRS.
* Place 'appname', into INSTALLED_APPS.
Just a little trick I use to keep from having to install apps via setup.py; I can just stick apps into arbitrary locations and use them. I also do this to keep single copies of 3rd party apps I use in multiple projects (but again without installing to the global python path). No idea if this is bad practice or anything, but I find it useful.
- settings
- apps
- applications
Use this snippet at the end of your main settings.py file to automagically import the settings defined in each app of `INSTALLED_APPS` that begins with `APPS_BASE_NAME`.
Set `APPS_BASE_NAME` to the base name of your Django project (e.g. the parent directory) and put `settings.py` files in every app directory (next to the `models.py` file) you want to have local settings in.
# works in the Django shell
>>> from django.conf import settings
>>> settings.TEST_SETTING_FROM_APP
"this is great for reusable apps"
Please keep in mind that the imported settings will overwrite the already given and preceding settings, e.g. when you use the same setting name in different applications.
Props to [bartTC](http://www.djangosnippets.org/users/bartTC/) for the idea.
- settings
- import
- reusable
- apps
- applications
5 snippets posted so far.