Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Preventing django-cms's toolbar from showing on certain urls (updated 2011-05-23)
Django-cms has a toolbar at the top of the page when you're editing. Handy for adding/editing pages or for going to the admin interface. It does that by means of some django middleware that injects (mostly) javascript code at the top of your page. Fun. Only, you don't want it everywhere if you've got non-django-cms parts of your site. See for instance a recent mailinglist discussion. There's currently no build-in way to disable it, but doing that yourself turned out to be pretty simple. Updated: this didn't work. In my site, I originally added a mysite.hacked_toolbar.py: from cms.middleware.toolbar import ToolbarMiddleware START_OF_EXCLUDED_URLS = ['/map/', '/share/'] # ^^^ Modify to your needs. class HackedToolbarMiddleware(ToolbarMiddleware): """Hacked version of django-cms's toolbar middleware. This modification prevents /map and /share urls from getting a toolbar as django-cms's toolbar contains conflicting jquery stuff, leading to javascript errors in our own part of the application. To use it, instead of 'cms.middleware.toolbar.ToolbarMiddleware', use 'mysite.hacked_toolbar.HackedToolbarMiddleware' in your ``MIDDLEWARE_CLASSES``. """ def show_toolbar(self, request, response): """Return False on excluded urls, use original method otherwise. """ for url in START_OF_EXCLUDED_URLS: if request.path.startswith(url): return False return ToolbarMiddleware.show_toolbar(self, request, response) Afterwards, in your settings.py I told you to go to the MIDDLEWARE_CLASSES. And switch 'cms.middleware.toolbar.ToolbarMiddleware' … -
Django and Whiskey.
No, not programming whilst inebriated. Although the effects of theBallmer Peakare well known.I mean usingwsgiand Apache together withDjango.But, perhaps, I should explain my (current) layout of projects.I now use:/path/to/project/ .git .gitignore project_name/ urls.py settings.py production_settings.py [...] apache/ project_name.conf django.wsgi env/ [...] sitestatic/ requirements.txt fabfile.pyThis allows me to have revision control of things meta to the project and of the project itself.This setup is relatively new, I've only been using it in about 4 projects now.Which meant that my wsgi file had to be slightly modified.This took me alotlonger than I expected to get going. But if you decide to use a layout similar to mine, this might help.import os import sys import site ## Assumptions: # Assume that the Django project and the environment are at the same level. # i.e. # /home/ # /<project root>/ <- * # /<project name>/ <- * # /apache/ # django.wsgi # production_settings # /env/ # /lib/ # /pythonX.Y/ # /site-packages/ <- * # /sitestatic # # Directories marked with '<- *' need to be imported for everything to work PROJECT_NAME = "control" PYVER = "%d.%d" % (sys.version_info[0], sys.version_info[1]) APACHE_DIR = os.path.abspath(os.path.dirname(__file__)) PROJECT_ROOT = os.path.abspath(os.path.join(APACHE_DIR, "..")) site_packages = os.path.join(PROJECT_ROOT, 'env/lib/python%s/site-packages' % PYVER) site.addsitedir(os.path.abspath(site_packages)) sys.path.insert(0, … -
You should use django-haystack like this
There is an annoying API mistake in django-haystack, leading to bugs and hacks. In this article, I tell you about the *only* way you should use django-haystack, which will save us all a lot of time. -
You should use django-haystack like this
There is an annoying API mistake in django-haystack, leading to bugs and hacks. In this article, I tell you about the *only* way you should use django-haystack, which will save us all a lot of time. -
Three easy rules about parts of code of apps within django project
Very easy convention about parts of code of apps within django project:Any functions which aren't views shouldn't be placed in views.pyAny functions related to work with forms should be in forms.py and be method of the form classAny function which used by more than one view/form/function should be saved in utils.pyUseful links: Django Reusable App Conventions , Django Application Conventions -
Admin django, deux petits tips pour les change_list
L'admin django est vraiment un bonheur pour la productivité. On peut faire plein de choses en moins de temps qu'il n'en faut pour écrire le descriptif des choses en questions. Après avoir passé quelques heures à farfouiller dans la doc et à faire quelques tests, je me suis dit qu'il n'y avait pas de raisons ... -
SimpleDB backend for Django-nonrel
Dan Fairs has started developing a SimpleDB backend. That's the sixth backend for Django-nonrel! Check out django-simpledb from github. The code is experimental and far from finished, but in a recent tweet Dan mentioned that he thinks he's very close to having the Django admin running on SimpleDB. That's huge, Dan! :) We're very close to supporting every popular NoSQL database. Guys, if you want to use Dango-nonrel with SimpleDB please help Dan with the django-simpledb backend (or help Mirko with the Redis backend if you prefer that). Leave a comment -
Django + TinyMCE = Profit
I recently had a request at work for a rich text editor to be added to one of our web applications.Its a job vacancies advertising system, where users log in to a backend and post an ad. The ads are then reviewed by a moderator and then allowed to be displayed on our public website. Quite a tidy little django app. Anyway....The moderator was sick of using asterisks (*) instead of proper bullet points and etc. so a rich text editor was a must. I started looking around the interwebz, and before long discovered django-tinymce.Having used TinyMCE previously on php applications without too much hassle, it seemed like a good choice. It turned out to be relatively easy to install and configure, really did the trick. The rough steps I used are below. One thing to remember if adding something like this to an existing app is ask yourself the question "Do I still need this in the database as a plain string as well?" because after you add TinyMCE to the form the data will be saved in HTML format.Steps 1 - 7 below describe the setup steps, where as 8 and 9 are some configuration things that I … -
How to install django on ubuntu using apache and mod_wsgi
Django is my favourite web framework, and one that I have become very familiar with over the last 3 years or so, as I develop web applications in it at work on an almost daily basis.One of the unfortunate things about it though is that it is much more difficult to set up and deploy a web app written in Django than it is to deploy an app written in PHP, for example. Django and python aren't popular enough yet that you can easily find a cheap web host that supports them, so the next best option is to set up your own web server for hosting your applications.A good way to do this is using Ubuntu server, Apache http server, mod_wsgi and MySQL database. Here are some basic instructions I wrote a while ago for setting up a production Django server with this combination:How to setup django server with apache2 and MOD_WSGIOn a clean install of ubuntu1. sudo apt-get install apache22. install mod_wsgi for apache2. (sudo apt-get install libapache2-mod-wsgi)3. sudo apt-get install python3. Download current stable version of django from www.djangoproject.com4. uncompress the tar tar xzvf Django-1.2.3.tar.gzcd Django-1.2.3sudo python setup.py install4. create a new project in /usr/local/src/ (sudo django-admin.py … -
Django web hosting
I've been using django for a number of years now, and one of the more frustrating things about it has been the almost complete lack of web hosting providers that support it.When you do locate one of the handful that support python and django, typically their prices are hiked up as it is more of a specialised service. Worst still, you can't find any "out-of-the-box" hosting plans that will work for what you're trying to do, so you are forced into either hosting it on your own, possibly unreliable, internet connection, or forking out for an expensive dedicated linux server so you can then set django up on it yourself.The good news is that this all seems to be changing. Support for python is becoming a standard inclusion on many web hosting plans. The thing that has particularly brought this to my attention was a marketing email I received a few days ago from Australian based website host ziphosting.Ziphosting is a spin-off company of one of Australia's larger providers of domain names and web hosting, netregistry. They offer an "economy" plan for $6.95/month which should do nicely for anyone wanting to host a small to medium sized website based on … -
Merging forms from django-formwizard
On a recent project, I was making use of the django-formwizard app and needed to be able to pull out any one of the fields from the series of forms. On the final step of one of the sample apps, it is suggested that you do something like: form_list = [form.cleaned_data for form in form_list]Continue Reading -
DjangoCanvas - Finally prototype goes live
I have spent quite some time on this project, thought it was time to release it as a prototype and see what people thought about it. URL to the project is http://www.djangocanvas.com The purpose of the project is to create a base project on the fly given a list of selected packages, inspired by Ninite. I guess there are loads of features I could implement in order to increase the utility of it, here are a few:Package version specificationSaving/Bookmarking of created projectsSupport different project layoutsSupport other Django versions (currently built for Dajgno 1.3)More configuration optionsIf you have any suggestion I would be really happy to hear them, as I would love to see this project finished and being useful. -
django-lastfm 1.0.1
Django-lastfm is a small Django app that allows you to embed your charts or recently listened tracks from Last.fm into your website. You can see the widget in action in the sidebar of this website. Version 1.0.1 includes a few minor bugfixes and a more comprehensive test coverage. You can find django-lastfm in the Cheese Shop or at Bitbucket. -
django-lastfm 1.0.1
Django-lastfm is a small Django app that allows you to embed your charts or recently listened tracks from Last.fm into your website. You can see the widget in action in the sidebar of this website. Version 1.0.1 includes a few minor bugfixes and a more comprehensive test coverage. You can find django-lastfm in the Cheese Shop or at Bitbucket. -
A small update on django-completion
Just a quick heads-up to anyone out there using django-completion, I've released a couple important updates this weekend and you may be interested in updating your checkouts. These changes are purely additive, so don't worry about having to update your own code. There are three important updates: Bug: the (experimental) Redis backend could fail to return results under certain conditions and, if data were removed frequently, leak memory all over the place Bug: partial titles generated for the Redis and Database backends were too restrictive, i.e. "testing python code" would not complete on "python" unless the AUTOCOMPLETE_MAX_WORDS setting was 2 (or 1) Feature: it is now possible to restrict suggestions to certain models by passing in a list of acceptable models to the suggest() method -
Django settings template
A better template for Django settings, ready to use. -
Django's Template Language is Turing Complete
-
Django-extended-choices, l’app qui te donne le choix (mais pas la date)
J'avais plein d'app possible à présenter pour ce billet du mois d'avril. Mais en réfléchissant, je me suis dit que la meilleure app possible à présenter ce moi-si c'était celle qui a été libéré pendant les DjangoCongs à savoir Django-extended-choices. Et en plus, ce qui est bien, c'est que comme c'est une toute petite app, ... -
Release 1.0.4
-
Django-SmartAgent
Dajngo-smartagent identifies Browser and OS name, version and characteristics. It achieves this surprisingly fast (<1ms) compared to other libraries with similar qualities. Some of characteristics identifiable are:if client is a mobile devicemax CSS version is supportedif client is a web crawlerif a client is considered alpha/betaOS and OS versionAlso popped in are some useful features for Django sites that want to support mobile versions.To install it you can either use pip/easy_install pip install django-smartagent #or easy_install django-smartagent or alternatively from repository git git+https://jamespacileo@github.com/jamespacileo/django-smartagent.git#egg=django-smartagent Code and documetnation is at https://github.com/jamespacileo/django-smartagent. Hope this helps a few peeps out. :) -
Django: quick templating with CleverCSS
CleverCSS is one of the alternatives for SASS CSS templating for Django. The markup language is a great way of replacing and generating ordinary and complex CSS stylesheets on the fly. In this article we will delve into how CleverCSS can exponentially speed up your Django projects and how we can start using this tool in a few easy steps. Tutorial Details Program: Django, CleverCSS, django-clevercss Difficulty: Intermediate Estimated Completion Time: 30 minutes What is CleverCSS? CleverCSS is a powerful markup language for the swift implementation of CSS stylesheets. The design of the markup is similar to that of SASS, so if you are already familar with the language this tutorial will be a breeze. CleverCSS drammatically reduces the time it takes to write up CSS rules mainly by: Decreasing repetitive punctuation such as semicolons and curly brackets Nesting rules Defining variables Enabling use of expressions This is an example of CleverCSS markup: div.article: width: 300px h2.article-title: color: #111 font-size: 16px &:hover: color: #222 div.body: font-size: 12px This is the equivalent CSS code: div.article{ width: 300px; } div.article h2.article-title{ color: #111; font-size: 16px; } div.article h2.article-title:hover{ color: #222; } div.article div.body{ font-size: 12px; } As you can see the first … -
Finally. Created myself a blog.
Hi folks!I'm quite excited as this is my first proper blog, and I am planning on writing quite often. Will look forward to see how this goes :) -
Organizing Django settings
I think it’s not cool that I’m not blogging. I decided to write small posts about several simple things, techniques and conventions I use often. Configuration is hard to get right, and I don’t think Django’s settings is the best way to configure a web app. The most common problem with Django’s settings is a desire to customize them for some particular environments, e.g. have a different DATABASE setting on development and production machines. And on of the most common solutions is simple and stupid: # settings.py as is, the standard Django's from django-admin.py startprojects DEBUG = True TEMPLATE_DEBUG = True # ... all this kind of stuff, and in the end: try: from local_settings import * # this is wrong. don't do this! except ImportError: pass The main reason to hate it when somebody does it is that you can’t use any value from settings.py in local_settings.py. It’s not cool. I want to be able to do things like, you know: INSTALLED_APPS += ('gunicorn',) No, it’s not possible. And don’t try from settings import INSTALLED_APPS, it won’t work. What to do about it? I really think of myself as a smart person, but the first time I decided to … -
Django Admin Override Save for Model
Sometimes it's nice to be able to add custom code to the save method of objects in the Django Admin. So, when editing an object on the Admin object detail page (change form), adding the following method override to your ModelAdmin in admin.py will allow you to add custom code to the save function. In admin.py: class MyModelAdmin(admin.ModelAdmin): def save_model(self, request, obj, form, change): # custom stuff here obj.save()This is documented in the Django Docs, but I found it particularly useful. -
Ken Cochrane | Blog | Deploying my Django application to DotCloud