vanderkerkoff
unread,Aug 2, 2011, 10:47:59 AM8/2/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hello there.
I need to use parts of the URL to calculate some thing inside my form.
Here's a stripped down version, I can't seem to get it to give me
anything other than none for self.request :-(
class EventBookForm(ModelForm):
title = CharField()
firstname = CharField()
surname = CharField()
address = CharField(widget=Textarea(attrs={'rows': 5, 'cols': 80}))
postcode = CharField()
telephone = CharField()
email = EmailField()
workshops = MultipleChoiceField()
requirements = CharField(widget=Textarea(attrs={'rows': 5, 'cols':
80}))
class Meta:
model = Event
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request', None)
print self.request
super(EventBookForm, self).__init__(*args, **kwargs)
workshop_choices = []
data = Workshop.objects.filter("some rules based on what I get back
from the request object, which is currently none")
for d in data:
workshop_choices.append((d.title,d.title))
self.fields['workshops']=MultipleChoiceField(widget=CheckboxSelectMultiple,
choices=workshop_choices, required=False)
I'm pretty certain I'm doing something unbelievably stupid but I am
trying, honestly!
Anyone got any ideas?