django

TypeError: instancemethod expected at least 2 arguments, got 0

Django 1.1.2 & Python 2.6.5 I keep getting this error when executing a seemingly innocent queryset. Looks exactly like the issue described in http://code.djangoproject.com/ticket/7204 However, I'm running Django 1.1.2, which is supposed to have the fix for this bug. Has anybody dealt with something similar before? Here's the code that...

Django - Model with 2 foreign keys from the same class

I wanted a Django model with 2 foreign keys from the same table. It's an event table which has 2 columns for employees: the 'home' and the 'away'. But I get this error: Error: One or more models did not validate... class Team(models.Model): name = models.CharField(max_length=200) class Match(models.Model): home = models.Foreign...

Django Query using .order_by() and .latest()

I have a model: class MyModel(models.Model): creation_date = models.DateTimeField(auto_now_add = True, editable=False) class Meta: get_latest_by = 'creation_date' I had a query in my view that did the following: instances = MyModel.objects.all().order_by('creation_date') And then later I wanted instances.latest(), but ...

How to add optgroups to a django ModelMultipleChoiceField ?

Hello Guys, I have a form with a ModelMultipleChoiceField to list of categories. I would like to group categories using the Category.group field. I thought that by changing the field.choices in the init function it will make the trick class CategoriesField(forms.ModelMultipleChoiceField): def __init__(self, queryset, **kwargs): ...

Slow Postgres JOIN Query

I'm trying to optimize a slow query that was generated by the Django ORM. It is a many-to-many query. It takes over 1 min to run. The tables have a good amount of data, but they aren't huge (400k rows in sp_article and 300k rows in sp_article_categories) #categories.article_set.filter(post_count__lte=50) EXPLAIN ANALYZE SELECT * ...

Possible to send date triggered email in django?

Hi, I am wondering if it is possible to send an email before a certain date? To explain a bit more we have talks that run every month on the second wednesday of the month and they have a title and speaker. I would like to email the members(email addresses stored in member object) 2 weeks before each meeting so on the first of the month y...

Django Pylons myths

I'm just starting with web frameworks and web development (I work only a little with PHP CI) and decided to move to python (I need language for general programing not only limited to web apps). I did research on google and found Pylons and Django as best and most popular web frameworks for python. But on some blogs, discussions people sa...

Django trying to set up a project and find out which Django I have

I'm on a Mac OS X Snow Leopard with Python 2.6.5, I'm trying to get django working but I keep getting this error. Do I need to add it to the path? I'm not sure where django is installed is there any way that I can find it? james:~/home/james → python Python 2.6.5 (r265:79063, Aug 8 2010, 21:45:26) [GCC 4.2.1 (Apple Inc. build 5659)]...

Django: how to rearrange object ids

I've started a model with the default, automatically handled IDs Django provides. Now I've started interfacing with an external system which has its own IDs for the same objects, and it would be very convenient to align my own IDs with the external system's. However, the numerical ranges overlap, so a naive solution wouldn't work. Is ...

Django, unable to import validators in form class, getting "name 'validatorname' is not defined"

I am trying to use validators in my form fields but am getting an error: from django import forms from django.db import models from django.core.exceptions import ValidationError class Register(forms.Form): username = forms.CharField(max_length=100,label="Username",validators=[validate_email]) >>>> name 'validate_email' is not def...

Partial updates to an SWF

Suppose all that happens initially in a client swf is a user clicks a hyperlink in a text object of the swf, so this requests a "page" from the server. In response the server just modifies that existing swf in the client browser, by for example (?) invoking public functions of it, and possibly passing in as parameters the name of image...

adding extra field to django-registration using signals

I want to add a locale selection to the default django-registration. I tried to follow this tutorial from dmitko. The form shows up correctly but the additional data (locale) is not saved. I defined a custom model: class AnymalsProfile(models.Model): user = models.ForeignKey(User, unique=True) locale = models.CharField(max_leng...

Django ModelForm Ajax Upload

I'm using an Ajax code for uploading files. Django takes good care of file uploads on ModelForms. Just writing form.save() would upload any file data in the header, manage creating the folders if needed and even rename the file if a duplicate already exists. Take this ModelForm which only has one filed named file for example: class Uplo...

Django: Integrating Avangate IPN

Does anyone have example code showing how to process the Avangate IPN (Instant Payment Notification) in a Django app? In particular, I'm interested in seeing examples of creating the hash signature for the response. ...

Relational Fields - Django

Hi, I am making a product app to add machines to a product list. Every product had a list of features, like motor type, motor output. Not all have the same features. Each feature has a value, like 2W, 1.5m etc, but this will only be put in once you add a product. So I wanna add all the possible features to my feature model. Then when I ...

Django UnicodeDecodeError when using pdb

I've notice every time I put an: import pdb; pdb.set_trace() in My Spanish Django project, if I have a specific Unicode character in a string like: Gracias por tu colaboración I get a UnicodeDecodeError with an 'ordinal not in range(128)' in a Django Debug window. The problem is that I can not debug my application easily. On the ot...

returning a link to a named URL from a model function

Hello all, Well, it has finally happened, and I have stumbled across a problem for which no amount of googleing has helped. (Although I may simply be looking in the wrong direction, in which case, any pointers in the right direction would be great). I am trying to find a way to return a link to a named url (with variable arguments) fro...

How to solve "cannot open shared object" problem while opening subprocess within apache

I run a web application in apache. My application try to execute a executable written by QT. But I always encounter "cannot open shared object libQtWebkit.so: No such file or directory" error. I can run this executable in shell without any problem. I tried set LD_LIBRARY_PATH but still not working. How can I set shared library path ...

Django: ModelForm confusion

I am trying to display a bound ModelForm in my template. Here the the code from the view: assessment = Assessment.objects.get(slug=slug) form = AssessmentForm(assessment) But when I then pull up the template, it is empty except for the submit button. When I try to debug with PDB, I get: (Pdb) form.data <Assessment: Alaska - Coastal...

Sharing django sessions on specific subdomains

I have example.com and support.example.com . If a user is logged in on the main site, I'd like to have the session be accessible from the support site. Setting the SESSION_COOKIE_DOMAIN to '.example.com' isn't what I want because I have many, many other subdomains with django apps that I would like to NOT have access to the session. C...