django

Multiple installs of Django - How to configure transparent multiplex through the webserver (Lighttpd)?

Hi Everyone, This question flows from the answer to:How does one set up multiple accounts with separate databases for Django on one server? I haven't seen anything like this on Google or elsewhere (perhaps I have the wrong vocabulary), so I think input could be a valuable addition to the internet discourse. How could one configure a s...

Django versus Plone?

I plan to read about Django. Should I go with Django or Plone? What makes Django/Plone better than the other? Edit: From a comment below: I just wanted to know a framework for developing web applications. ...

Foreign key from one app into another in Django

Hi, I'm wondering if it's possible to define a foreign key in a models.py file in Django that is a reference to a table in another app? In other words, I have two apps, called cf and profiles, and in cf/models.py I have (amongst other things): class Movie(models.Model): title = models.CharField(max_length=255) and in profiles/mo...

In a django form, How to make a field readonly (or disabled) so that it cannot be edited?

In a django form, How to make a field readonly (or disabled) so that it cannot be edited? When the form is being used for a new record entry, all fields are enabled, but when the record is in update mode some fields need to be readonly. For example, in the Item model, for a new record entry, all fields are editable, but while updating ...

Strategies for speeding up batch ORM operations in Django

One of my API calls can result in updates to a large number of objects (Django models). I'm running into performance issues with this since I'm updating each item individually, saving, and moving on to the next: for item in Something.objects.filter(x='y'): item.a="something" item.save() Sometimes my filter criterion looks like...

Multiple Django Admin Sites on one Apache... When I log into one I get logged out of the other.

I have two Django projects and applications running on the same Apache installation. Both projects and both applications have the same name, for example myproject.myapplication. They are each in separately named directories so it looks like .../dir1/myproject/myapplication and .../dir2/myproject/myapplication. Everything about the ...

Django equivalent for count and group by

I have a model that looks like this: class Category(models.Model): name = models.CharField(max_length=60) class Item(models.Model): name = models.CharField(max_length=60) category = models.ForeignKey(Category) I want select count (just the count) of items for each category, so in SQL it would be as simple as this: select...

Looking for some good resources to get started with Django

All, I'd like to check Django out and maybe hack together some web pages to see how it feels - but after having a look at a few tutorials like this one I am starting to wonder if there is any way of getting it up and runinng without typying cmd line stuff for 1/2 hour. Can people point out some good straightforward resources/tutorials ...

Python CMS for my own website?

I'm an accomplished web and database developer, and I'm interested in redesigning my own website. I have the following content goals: Support a book I'm writing Move my blog to my own site (from blogger.com) Publish my articles (more persistent content than a blog) Host a forum with light use Embed slide sharing and screencasts I ...

Replace textarea with rich text editor in Django Admin?

I would like to know the best way to replace a standard textarea field with a rich text editor in Django Admin? ...

What is the best way to catch and show an error if user enters only whitespace in a form field in Django?

In Django 1.0, what is the best way to catch and show an error if user enters only whitespace (" ") in a form field? class Item(models.Model): description = models.CharField(max_length=100) class ItemForm(ModelForm): class Meta: model = Item if user enters only whitespace (" ") in description CharField, what change ne...

Firefox handles xxx.submit(), Safari doesn't ... what can be done?

I'm trying to make a pull down menu post a form when the user selects (releases the mouse) on one of the options from the menu. This code works fine in FF but Safari, for some reason, doesn't submit the form. I re-wrote the code using jquery to see if jquery's .submit() implementation handled the browser quirks better. Same result, wo...

How to generate a filmstrip image in python from a folder of images?

I would like to do the equivalent off this (ruby code) in python for a Django project I am working on. I want to make a filmstrip image of X number of images in a folder. ...

How do I create trivial customized field types in Django models?

I'm trying to make some types in Django that map to standard Django types. The custom model field documentation goes into complicated cases; I just want to store a basic Django type from a class with a bunch of handy methods. For example, if I were storing playing cards, I want something like: class Card(object): """ A playing car...

In Django, is it possible to access the current user session from within a custom tag?

I am writing a custom tag in Django that should output a value stored in a user session, but I cannot find a way to access the session object from within a custom tag function. Is there any way to do this, without manually assigning the session object to a context variable? ...

Django FormWizard and Admin application

I have a series of forms that I need a user to complete in sequence, which is perfect for the formwizard app. However, I've some need of the admin application also and would like to set the whole thing up to trigger several forms within the admin app. Is it possible/easy to integrate a 'formwizard' into the admin application? If not, ...

Problems raising a ValidationError on a Django Form

I'm trying to validate that a submitted URL doesn't already exist in the database. The relevant parts of the Form class look like this: from django.contrib.sites.models import Site class SignUpForm(forms.Form): # ... Other fields ... url = forms.URLField(label='URL for new site, eg: example.com') def clean_url(self): ...

Django Foreign Keys Read Only

Hi, I have two models one is Employee and other is Asset, with Many to one relation between Asset and Employee. And Asset is added as StackedInline field to Employee Admin interface, Is there anyway I can make Asset as read only field in the Employee Admin. My intention was to show all the assets the employee is currently holding in t...

Navigation in django

I've just done my first little webapp in django and I love it. I'm about to start on converting an old production PHP site into django and as part its template, there is a navigation bar. In PHP, I check each nav option's URL against the current URL, in the template code and apply a CSS class if they line up. It's horrendously messy. I...

Python Decorators run before function it is decorating is called?

As an example, def get_booking(f=None): print "Calling get_booking Decorator" def wrapper(request, **kwargs): booking = _get_booking_from_session(request) if booking == None: # we don't have a booking in our session. return HttpRedirect('/') else: return f(request=reque...