I have model Foo which has field bar. The bar field should be unque, but allow nulls in it, meaning I want to allow more than one record if bar field is null, but if it is not null the values must be unque.
Here is my model:
class Foo(models.Model):
name = models.CharField(max_length=40)
bar = models.CharField(max_length=40, un...
A few weeks ago I asked the question "Is a PHP, Python, PostgreSQL design suitable for a non-web business application?" http://stackoverflow.com/questions/439759/is-a-php-python-postgresql-design-suitable-for-a-business-application
A lot of the answers recommended skipping the PHP piece and using Django to build the application. As I've...
Let's say trying to use django.views.generic.create_update.create_object to allow the user to a blog entry instance. On the Entry model, there is a required field for the user, that I don't want to show up as an editable field on the blog entry form. So, I would include it into the EntryForm.Meta.exclude tuple.
Where should I set th...
I have an application in Django, that needs to send a large number of emails to users in various use cases. I don't want to handle this synchronously within the application for obvious reasons.
Has anyone any recommendations for a message queuing server which integrates well with Python, or they have used on a Django project? The rest o...
Can anyone help me please to solve this..
from django.db import models
# Create your models here.
class Poll(models.model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
...
I'm building a Django site and trying to use the request.is_ajax() function... But it's only working locally and it's driving me crazy!
I'm at the point where I've just dumped the headers. Here (on the django test server) there's HTTP_X_REQUESTED_WITH but on the production server (cherokee+scgi) all I get is X-Requested-With.
I've used...
Hi,
Django templates offer the builtin tag cycle for alternating between several values at different points in a template (or for loop in a template) but this tag does not reset when it is accessed in a scope outside of the cycles definition. I.e., if you have two or more lists in your template, the rows of all of which you'd like to u...
The following query does what I'd like it to do, however, I have no idea if it's efficient. I went through the Django aggregation documentation, threw it together, looked at the query and tilted my head sideways like a confused dog.
What the query actually does is get published Entry's "name" and "name_slug" that have one or more approv...
I'm creating a jquery time entry in an onready() handler and hiding it in another onready() handler in jquery. (The reason that the code is being called in two different onread() handlers is that the time entry is being created via a reusable Django widget renderer and hidden via local screen application logic.)
The jquery time entry g...
I have a medium sized Django project, (running on AppEngine if it makes any difference), and have all the strings living in .po files like they should.
I'm seeing strange behavior where certain strings just don't translate. They show up in the .po file when I run make_messages, with the correct file locations marked where my {% trans %...
I'm dying to get started Django but I'm really struggling with the initial setup. I have Python/MySql/Apache2.2/mod_python installed. Now I'm trying to create a proper directory structure and then update Django and Apache settings.py/httpd docs respectively. Specifically the location tag in the latter. Django and Python are based on simp...
Can anyone help me spot my problem here:
I'm trying to implement a file upload routine using appengine and django, and I've run into a MultiValueDictKeyError error. It appears that the file is not making it from the webpage to the server.
Some part of this is a learning exercise, so I don't want to use a djangoform to process the data ...
Hi there,
Given an object like:
class M(models.Model):
test = models.BooleanField()
created_date = models.DateTimeField(auto_now_add=True)
Given sample data (assume monotonically increasing automatic created_date):
M(test=False).save()
M(test=True).save()
M(test=False).save()
X = M(test=True).save()
M(test=False).save()
Y =...
I've not used Unit Tests before other than a quick introduction in a Uni course. I'm currently writing an application though and would like to teach myself TDD in the process. The problem is, I've no idea what to test or really how.
I'm writing a Django application, and so far have only created the models (and customised the admin appli...
One of the functionalities in a Django project I am writing is sending a newsletter. I have a model, Newsletter and a function, send_newsletter, which I have registered to listen to Newsletter's post_save signal. When the newsletter object is saved via the admin interface, send_newsletter checks if created is True, and if yes it actually...
So I have this code in a google app engine template:
<select name='voter'>
{% for voter in allowed_voters %}
<option {% ifequal voter last_voter %}selected="yes" {% endifequal %}
value='{{voter}}'>{{voter}}</option>
{% endfor %}
</select>
The page doesn't render with the correct person selected, defaulting instead to the ...
Short and simple. I've got a huge list of date-times like this as strings:
Jun 1 2005 1:33PM
Aug 28 1999 12:00AM
I'm going to be shoving these back into proper datetime fields in a database so I need to magic them into real datetime objects.
Any help (even if it's just a kick in the right direction) would be appreciated.
Edit: Thi...
I've been attempting to setup pywurfl so that I can perform handset lookups to pull attributes from the wurfl api, but I'm currently having issues when attempting the select_ua() request. This is what I'm using : http://celljam.net/
Anyone out there have experience with Python and WURFL?
...
I would like to find a generic way of preventing to save an object if it is saved after I checked it out.
We can assume the object has a timestamp field that contains last modification time. If I had checked out (visited a view using a ModelForm for instance) at t1 and the object is saved again at t2, given t2 > t1 I shouldn't be able t...
I want to run a django appserver behind apache/fastcgi. That's no problem, django does that out of the box.
I want this appserver to be deployable via setuptools. That is, I will make it as an egg and install it with easy_install. And that part I can also handle, even though setuptools is not a standard complement to a django appserv...