Hi Everyone,
I'm getting an AssertionError from a modal form: "Cannot filter a
query once a slice has been taken."
But only when it is bound.
My model is pretty simple:
class Link(models.Model):
title = models.CharField("Listings title", max_length=100)
# other fields
event = models.ForeignKey("events.Event", blank=True, null=True)
Then the form is:
class LinkForm(ModelForm):
event =
forms.ModelChoiceField(queryset=Event.objects.filter(start_date__lte=today).order_by('-start_date')[:15])
class Meta:
model = Link
It's fine if the queryset is default (without order or filter), and it
loads ok (when not a bound form). But on post it errors.
Is there a way of using a queryset like this to reduce the options shown?
I tried creating a custom method for cleaning the event field, but it
errors even when the form is valid.
Any ideas welcome...
-Alastair
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.