background preloader

Django

Facebook Twitter

Ajax

Download. Thumbnail. Hack. Couchdb. Captcha. Satchmo Project. Bill de hÓra: Using TinyMCE in Django's admin. Using TinyMCE in Django's admin May 24, 2006 | co.mments After a few failed attempts, I managed to get TinyMCE running inside Django's Admin. This is nice for editing html fragments and suchlike. Here's what to do. First, download TinyMCE and unpack it into the media folder in Django. /usr/local/python24/site-packages/django/contrib/admin/media then put the TinyMCE js folder (in the distro this tinymce/jscripts/tiny_mce) here: /usr/local/python24/site-packages/django/contrib/admin/media/tiny_mce Here's a grab from Windows showing what you should end up with: Configure the TinyMCE pane.

I used the AddWYSIWYGEditor configuration from the Django Wiki for this. That's Django Admin set up. Now let's configure a Model class to use a rich edit area. In Django's regular admin setup it will look like this: To configure it, we need to add one line to the Admin class - a 'js' array field - like this: The js field allows you to set javascript for the admin screens. And that's it. May 24, 2006 04:30 PM. Spawning + Django - Eric Florenzano's Website. Yesterday Donovan Preston released new versions of both eventlet and Spawning . What are those, you ask? Eventlet is a networking library written using coroutines instead of normal subroutes, which makes writing networked non-blocking IO applications much much simpler. Spawning is a WSGI server, written using eventlet , which supports all of the things you'd expect of a good WSGI server: multiple processes, multiple threads, etc.

Considering that I sit next to Donovan at work all day, I've overheard him extolling the numerous advantages to using a server such as Spawning --the most obvious of which is completely graceful code reloading. Donovan has given a presentation explaining how all of this works, the slides of which probably explain it better than I could. When he told me that he'd added the ability to easily run Django apps with Spawning, I decided to check it out.

First, I installed spawning: sudo easy_install Spawning For me, it worked like a charm. The B-List: Newforms, part 3. Now that I’ve got the user-profiles application out in the wild, let’s take a look at one last important feature of Django’s newforms library: the ability to dynamically generate forms “on the fly” from model classes, via the helper functions form_for_model and form_for_instance. And, just as importantly, let’s look at why they shouldn’t always be the first thing you reach for when you need to build a form. How model-generated forms work We’ve already taken a look at how to introspect Django models using Django’s own internal APIs, and if you’ve been following along with my posts this month you’re probably starting to see how the underlying pieces of the model APIs serve all sorts of useful purposes within Django (and can do the same in your own applications).

This stuff is literally everywhere once you start looking for it, and the form_for_model and form_for_instance helpers are no exception. opts = model_class. opts = model_obj. When generating forms is a good idea, and when it’s not. Django-tagging - Google Code. A generic tagging application for Django projects, which allows association of a number of tags with any Model instance and makes retrieval of tags simple. The CHANGELOG is kept up to date with notable commits and the latest version of this application's documentation, in reStructuredText format, is always available in its overview.txt file or rendered nicely. Note: this documentation is for the SVN trunk version - it may differ from the documentation for the packaged release. Version 0.3 Features Version 0.3 was released on 22nd August 2009, packages from revision 158 in Subversion.

Works on 1.0 and other fixes. Version 0.2 Features Version 0.2 was released on 12th January 2008, packaged from revision 122 in Subversion. Version 0.2.1, a bugfix release, was released on 16th January 2008 - this fixes a bug with space-delimited tag input. If you're upgrading from version 0.1, please see the BackwardsIncompatibleChanges wiki page. Requires a recent SVN checkout of Django's trunk. or. Useful form tricks in Django « Collin Grady. July 24, 2008 at 12:46 am | Posted in django | 9 Comments Not much text to put in this post, I just want to show a few useful things you can do with a ModelForm in django, so I can quit retyping examples :) 1) Replace a widget without losing all the default values passed to the form field from the model definition: from django import forms from mysite.polls.models import Poll class PollForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(PollForm, self).

__init__(*args, **kwargs) self.fields['question'].widget = forms.Textarea() class Meta: model = Poll 2) Along the same lines, limit the choices of a ForeignKey based on a user: (assume we’ve added an owner field to the tutorial Poll model to indicate the User who created the Poll) from datetime import datetime, timedelta from django import forms from mysite.polls.models import Poll, Choice class ChoiceForm(forms.ModelForm): def __init__(self, user, *args, **kwargs): super(ChoiceForm, self). or just form = ChoiceForm(request.user) Infrastructure for Modern Web Sites. One of the things that I did when I wrapping up at Yahoo! Was to begin to take a look at the current state of web frameworks. I ended up picking Django, but I have to say, I was disappointed with the state of what’s out there. Friends will have heard me bemoaning this sad state of affairs – that while Rails and Django might make CRUD easier, that the ORMs weren’t suitable for scaling beyond “toy” sizes, and that more importantly, they didn’t seem to address almost any of the pain points of building and maintaining a modern website.

A couple recent posts, most notably Krow’s Scaling, Systems Required list, but also Tom Kleinpeter’s post asking Where Are the AB Testing Frameworks? Reminded me that I had made my own list. I was originally going to start working on these, but since I’ve now been side-tracked by a few projects, I thought I’d put it out there before it gets too completely irrelevant. I’ve split this into two sections.

Tags: framework, infrastructure, iwantapony. Taylan Pince | Schema Migrations with South. I had a few big issues with django-evolution: Inability to go backwards or forwards, or to be able to skip migrations (or mutations as it calls them) Inability to use custom fields that require additional parameters Lack of integration with syncdb (if someone in the team accidentally does a syncdb, it fails) I love how clever evolution can be when guessing the modifications to a model, but I donqaodmasdkwaspemas2ajkqlsmdqpakldnzsdflst think whatqaodmasdkwaspemas1ajkqlsmdqpakldnzsdflss needed from a migration tool is cleverness.

I needed a tool that gave me the freedom to do whatever I wanted, while making my job easier by managing all the changes. I have been playing around with South for the past week, and it seems like it offers pretty much everything I need, plus a bit more. My only grief with it is the lack of documentation. Qaodmasdkwaspemas0ajkqlsmdqpakldnzsdfls qaodmasdkwaspemas1ajkqlsmdqpakldnzsdfls qaodmasdkwaspemas2ajkqlsmdqpakldnzsdfls qaodmasdkwaspemas3ajkqlsmdqpakldnzsdfls. CountryField. Hooking up Users and Profiles - Django users. Org: Using Django with Wing IDE. Haystack - Search for Django. Index — Django Design Patterns. James Tauber. Django-registration - Google Code. WTForm (What The Form) Geektorrent.com. The B-List: Standalone Django scripts.

In the grand tradition of providing answers to frequently-asked questions from the django-users mailing list and the #django IRC channel, I’d like to tackle something that’s fast becoming the most frequently-asked question: how do you write standalone scripts which make use of Django components? At first glance, this isn’t a terribly hard thing to do: Django’s just plain Python, and all of its components can — in theory — be imported and used just like any other Python modules.

But the thing that trips most people up is the need, in most parts of Django, to supply some settings Django can use so it’ll know things like which database to connect to, which applications are available, where it can find templates, etc. Depending on exactly what you need to do, there are several ways you can approach this problem, so let’s run through each of them in turn.

Set DJANGO_SETTINGS_MODULE before you run export DJANGO_SETTINGS_MODULE=yoursite.settings Use setup_environ() Use settings.configure() The B-List: Django tips: user registration. One of the most common and, generally, most successful models for letting people sign up for user accounts requires the user to go through some form of “activation”; usually it looks something like this: User fills out a form with a username, password and email address. User gets an email with a “confirmation link” which must be clicked to activate the account. User clicks the link and the account becomes active; then they log in normally. So let’s look at how to do this with Django. Also, before we dive in, let me note that this one’s still a work in progress. Update: if you’re interested in the mechanics of how registration works, keep reading. Set up a user profile In order to do this effectively, we’ll need to generate some sort of unique key which can be used to activate the account, and we’ll need somewhere to store it.

So here’s a very simple “user profile” model; you’d probably want to add more fields to it, but this has the bare minimum we need to do user registration: