Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Migrating django(-cms) from sqlite to postgres
We've got a django-cms site that started out on sqlite. Now we're adding GIS shapefiles so we wanted to move to postgres/postgis. Ok, switch over the DATABASES definition in settings.py, make a fixture and load it, right? Ahem, no. There were a couple of problems, partially with our code, partially django-cms, partially django. Some solutions below might not be needed in every case, but I'm just going to list everything in the hope that it helps someone. South migration dependencies Lots of our code uses south for database migrations. But when creating our database from scratch, "migrate" would complain that a certain table of application A didn't exist yet when migrating application B. Uh oh, a dependency. Turns out that's easily solved. In the failing migration step, just add a dependency on the missing application's relevant step: ... class Migration(SchemaMigration): depends_on = ( ("application_a", "0001_initial"), ) def forwards(self, orm): ... After that, all migrations run fine. Small sqldiff limitation We've got django-extensions in our projects. One of the handy extra management commands it provides is "sqldiff" (so manage.py sqldiff or, as we use buildout, bin/django sqldiff). (The best extension is "graph_models" which creates a picture of your model structure). We … -
Open Source Repositories Have moved
We’ve moved our repositories yet again! First we hosted our repositories here on opensource.washingtontimes.com, then we moved them to http://github.com/washingtontimes. We’ve decided to move the projects (over 40 of them) to our Calloway project’s GitHub account. Please excuse the confusion. We feel this will keep them available for a long time. -
Classes are not just namespaces
There is a mistake that Python developers make every now and then. If they also happen to be authors of some framework, they can get away with telling us that this is the very framework's way and suggesting an ugly (yet "frameworky") workaround. But you can't, so please don't do this to us. A little rant on the "instance greed" and a reason of `View.as_view()` method in Django's class based views classes in the blog post. -
Django job at Net Communities
Net Communities are looking for a Python/Django developer to work on an in-house project. It's a contract that would require some on-site work, but they would also consider a full-time developer for the right individual. If you are interested, get in touch with Andy Evans. -
Django job at Net Communities
Net Communities are looking for a Python/Django developer to work on an in-house project. It's a contract that would require some on-site work, but they would also consider a full-time developer for the right individual. If you are interested, get in touch with Andy Evans. -
Django job at Net Communities
Net Communities are looking for a Python/Django developer to work on an in-house project. It's a contract that would require some on-site work, but they would also consider a full-time developer for the right individual. If you are interested, get in touch with Andy Evans. -
Creating a Read-only Mirror for your GitHub Server
-
django-urli18n
Even I released django-urli18n already two weeks ago, I didn't find the time to actually announce it. So here it is: What is django-urli18n? A reusable Django app to display the current activated language in the URL. Features - different ways to show the language in the URL: in the path (for example www.example.com/en/home/) or in a query string (for example www.example.com/home/?lang=en) - simple to use and include into new or existing Django projects Where to get it? Check out the project page on Github. -
Django Canvas - Planned Feature List
Hi folks,I am really pleased that other developers have found Django Canvas useful and interesting. I had the idea of building this project at PyCon 2011, Atlanta, where I discussed it with other developers. Now that I have finally built it, I am happy that my efforts have been worth something. :)I have had a lot of great advice from many different sources, especially after superchink submitted the project on Hacker News. Useful channels for feedback have been: email, twitter, hacker news, reddit and convore.Despite the Google Code Jam taking up some time today, I have put together a list of features I'm planning for the next release.Feature listAPI for creating, downloading packages + user authenticationSSL (in case sensitive information is used within the configurations)Ability to add packages from djangopackages.com and git/mercurial/svn repositoriesPackage links and descriptions need to be accessible on the home pageUsers will be able to have accounts, save their settings and have their private base projects savedPublic base projects might be a useful addition to the communityAbility for django package owners to make their packages compatible with Django CanvasFabric supportCustomization of project structureLoading modal box to prevent user from downloading multiple archives at the same time.It would … -
Voxy.com Launch!
Voxy helps you learn a language from life. That means, doing things you would do anyway but learn a language while you do it. Like reading about the NFL lock-out in Spanish. If you're learning English, an English version is also available here. The iPhone app has reached #1 in the AppStore for education apps in 14 countries. Android app is coming any day now too. Both apps support location based learning. Are you near a bank and need to figure how to linguically maneuver through a transaction? Voxy can help! One of the fun things about building this site in Django is how well Django handles changes in company direction and the associated functionality. The app has iterated, very quickly, through many different versions and Django has handled everything in stride. The site and associated mobile APIs were created in Django 1.2 using PostgreSQL 9 along with the usual suspects of South, Sentry, django_extensions, debug toolbar, boto, celery with RabbitMQ and also dbgettext, photologue, django-rosetta and newcache. APIs we use are from SimpleGEO, Twilio (SMS), WordNIK, Recurly. And everything is deployed on Linode except for a server to translate audio using Natural Reader 10 running on Windows @ Amazon … -
Voxy Launch!
Voxy helps you learn a language from life. That means, doing things you would do anyway but learn a language while you do it. Like reading about the NFL lock-out in Spanish. If you're learning English, an English version is also available here. The iPhone app has reached #1 in the AppStore for education apps in 14 countries. Android app is coming any day now too. Both apps support location based learning. Are you near a bank and need to figure how to linguically maneuver through a transaction? Voxy can help! One of the fun things about building this site in Django is how well Django handles changes in company direction and the associated functionality. The app has iterated, very quickly, through many different versions and Django has handled everything in stride. The site and associated mobile APIs were created in Django 1.2 using PostgreSQL 9 along with the usual suspects of South, Sentry, django_extensions, debug toolbar, boto, celery with RabbitMQ and also dbgettext, photologue, django-rosetta and newcache. APIs we use are from SimpleGEO, Twilio (SMS), WordNIK, Recurly. And everything is deployed on Linode except for a server to translate audio using Natural Reader 10 running on Windows @ Amazon … -
Using virtual machine (vagrant) for you web development
In my opinion, environments on the development machine and production machine must be as close to each other as possible. But installing Postgres, Solr and whatnot on your local machine is a terrible option, and they quickly become unmanageable. We have a solution for that! -
Minor updates and API changes
Maybe you noticed that we've started to work on our projects again. ;) We unsurprisingly (:P) passed our final physics exams and are ready to work on NoSQL development again. Waldemar has already started to do some work in order to get our efforts into Django trunk. In the meantime I've started to work on some bug reports concerning django-dbindexer and nonrel-search. Both now have a dependency on django-autoload which ensures the loading of indexes or signal handlers before any request is processed. As a consequence, you have to adapt your code if you make use of django-dbindexer or nonrel-search. The documentation has been changed in order to reflect these changes. Maybe we'll take a few days off to go on vacation. Then, we'll come back and continue improving the way of NoSQL development. Leave a comment -
How to search with row level permissions?
Searching on a site where everyone has access to only some content can be tricky to implement. I'm discussing here several basic concepts about row level permissions and how to implement full-text search without hacking and complicated code. -
Haystack 1.2 Released
Haystack 1.2 Released -
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 …