Hi all,
is there any way to use the ModelChoiceField without any value in it? I
tried to set query = None but it gave an error while rendering the html page
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, sen
hi all,
i am trying to write auto populated select box by using jquery and
ModelChoiceField. I have 2 variables cates and subcates, the first one take
all the objects from the Category model, the second takes None object
(Subcategory.objects.none ()). at first the html rendering is fine. When i
Hi:
in the example this link
http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other
additional validation is performed cc_myself and subject fields,
could give me an example to validate a field of type ModelChoiceField
Thanks
Hi Group. Please look at this snippet from my forms. It uses two
ModelChoiceFields as shown below. Each database table currently has 2
records.
On the webpage, when the form is being called, the options are like
this:
Template object
Template object
and
PageCategory object
PageCategory obje
I was trying to find a way to get ModelChoiceFields to use an already
cached Model, and I came across in django/forms/models.py , under
class ModelChoiceField, a variable called:
self.choice_cache=None
class ModelChoiceIterator seems to be the only thing that plays with
it, but with or without
On 6/25/10 8:25 AM, Tran Cao Thai wrote:
is there any way to use the ModelChoiceField without any value in it?
I tried to set query = None but it gave an error while rendering the
html page
Use EmptyQuerySet.
field = ModelChoiceField(queryset=YouMode.objects.none())
http
Thank you very much. I missed that part in the documentation
On Fri, Jun 25, 2010 at 4:54 PM, Oleg Lomaka wrote:
> On 6/25/10 8:25 AM, Tran Cao Thai wrote:
>
>> is there any way to use the ModelChoiceField without any value in it? I
>> tried to set query = None but it g
Hello list,
I was wondering which would be the best way to handle this situation
with ModelChoiceFields:
I have a form with a ModelChoiceField, the options presented in this
field may change at the view depending on the user, however,
ModelChoiceField requires the queryset to be given as a
Hi, I'm making one app with 3 classes: emploee, company and department.
1- When I edit an emploee I need to know his company, and after to have a
field with all the departments from the selected company. But when I use
ModelChoiceField I see all departments from all companies.
2- Another pr
I am using a ModelChoiceField (default_project) in a form and want the
initial queyset to change when the form is created.
I've tried doing it like this:
forms.py --
class UserAccountForm(forms.Form):
.
default_project =
forms.ModelChoiceField(queryset=Project.object
Hi,
I have a modelForm that has a foreign key. I want the control to be a link
instead of a element. This I have managed. It opens a div which lets
me pick a value from a long list.
The problem I am having is feeding the chosen value back into the original
form. I can't figure out which clean
Input())
nome = CharField(widget=TextInput(attrs={'class':'textInput
required'}), required=True)
pai = ModelChoiceField(PlanoConta.objects.none(), empty_label=None)
def __init__(self, *args, **kwargs):
super(PlanoContaForm, self).__init__(*args, **kwargs)
queryset to League.objects.all(). I don't want to do this cos the
League data is huge.
2. Since the fields don't bind to the values, when the form get
redisplayed, the values are not redisplayed.
I am struggling with the ModelChoiceField in general as well.
--~--~-~--~~---
I'm using a ModelChoiceField on a form and it seems the value
attributes of the generated option tags are simply their numeric order
in the queryset. How can I set the value attribute to some useful
information like id or the __unicode__ representation itself?
T
ed_data['page_category_id']
>return data
>
>def clean_template_id(self):
>data=self.cleaned_data['template_id']
>return data
>
> >
>
Take a look at label_from_instance:
http://docs.dj
> Take a look at
> label_from_instance:http://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield
>
> Alex
>
yeah I'm lookin at that but it makes no sense to me.
Here's what i have and it's not working:
from django import forms
from web_pages.m
On Wed, May 20, 2009 at 12:32 PM, Bobby Roberts wrote:
>
> > You aren't actually using that Field though, you need to use it in place
> of
> > ModelChoiceField where you want that behavior.
> >
> > Alex
>
>
> here's what i'
On Wed, May 20, 2009 at 10:38 AM, Bobby Roberts wrote:
>
> > Take a look at label_from_instance:
> http://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield
> >
> > Alex
> >
>
> yeah I'm lookin at that but it makes no sense to me.
&g
ur form (in the file), otherwise the Field
> won't be defined when you go to use it.
>
> Alex
Alex -
I really appreciate your help. I made the changes you suggested and
it's shown here:
class MyModelChoiceField (ModelChoiceField):
def label_from_instance(self,o
s a note, you're going to want to have the
> > MyModelChoiceField class before your form (in the file), otherwise the
> Field
> > won't be defined when you go to use it.
> >
> > Alex
>
>
>
> Alex -
>
> I really appreciate your help. I mad
> You aren't actually using that Field though, you need to use it in place of
> ModelChoiceField where you want that behavior.
>
> Alex
here's what i've got:
class FrmWebPage (forms.Form):
active = forms.ChoiceField(required=True, choices=active_choices,
wid
> Your class should inherit from "forms.ModelChoiceField", not just
> ModelChocieField.
>
> Alex
Ok i'm getting somewhere! Thanks for your patience. I'm still
finding my python / django legs. This populates the dropbox with
My Object #1
My Object #2
My Object #3
I see why it's dong that in
On Wed, May 20, 2009 at 2:05 PM, Bobby Roberts wrote:
>
>
> > Your class should inherit from "forms.ModelChoiceField", not just
> > ModelChocieField.
> >
> > Alex
>
>
> Ok i'm getting somewhere! Thanks for your patience. I'm still
> finding my python / django legs. This populates the dropbox w
> Sure, label_for_instance gets the object itself, with all it's fields. So
> isntead of returning the string with the id number, change it to return:
> obj.name.
>
> Alex
PERFECT! Thanks a lot!
--~--~-~--~~~---~--~~
You received this message because you are subs
hi group
i'm trying to create a drop box that is populated with a distinct list
of values from a certain field (fieldname=page_plaque) in the table.
Here is what i have in my forms.py
class PagePlaqueModelChoiceField (forms.ModelChoiceField):
def label_from_instance(self,obj):
Say I have this model:
model Foo(models.Model):
bar = models.ForeignKey(Baz)
I have a ModelForm for Foo (FooModelForm). However, instead of having
a ModelChoiceField for bar, I want a single bar object in a hidden
field that's specified when creating the FooModelForm.
m
I believe ModelChoiceField is meant to be used with ModelForm. I'd
stick to one or the other. Either use ModelForm and let it do the
work, or use Form and do the work yourself rather than trying to get
ModelChoiceField to work.
Euan
On 29 July, 05:23, Carlos Daniel Ruvalcaba Valenzuela
On Jul 29, 5:23 am, Carlos Daniel Ruvalcaba Valenzuela
wrote:
> Hello list,
>
> I was wondering which would be the best way to handle this situation
> with ModelChoiceFields:
>
> I have a form with a ModelChoiceField, the options presented in this
> field may change at the
On 7/29/2010 8:56 AM, Daniel Roseman wrote:
> On Jul 29, 5:23 am, Carlos Daniel Ruvalcaba Valenzuela
> wrote:
>> Hello list,
>>
>> I was wondering which would be the best way to handle this situation
>> with ModelChoiceFields:
>>
>> I have a form with a
I believe you can filter them using ModelAdmin.formfield_for_choice_field.
Check out the docs here:
http://docs.djangoproject.com/en/1.2/ref/contrib/admin/
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email
Is there any secury issues by using adminfield in normal user forms?
2011/3/17 Shawn Milochik
> I believe you can filter them using ModelAdmin.formfield_for_choice_field.
>
> Check out the docs here:
> http://docs.djangoproject.com/en/1.2/ref/contrib/admin/
>
> Shawn
>
> --
> You received this m
The formfield_for_choice_field method can be overridden to change the
default formfield for a field that has declared choices. For example, if the
choices available to a superuser should be different than those available to
regular staff.
That doesn't seem to be the case, because the staff and th
I had similar problem and i sort it out by overloading __init__ func
of my form and change queryset method of a field (ModelChoiceField),
i.e.:
self.fields[depatment].queryset =
self.fields[depatment].queryset.filter(company=selectedcompany)
Maybe it will help You with finding right solution.
On
On Jun 1, 3:27 am, sorrison <[EMAIL PROTECTED]> wrote:
> I am using a ModelChoiceField (default_project) in a form and want the
> initial queyset to change when the form is created.
>
> I've tried doing it like this:
>
> forms.py --
>
hi,
while learning and experimenting with forms ... one should use
ModelChoiceField in order to let newforms bind the value on a
foreignkey field of a model. My concern is that in the real world, you
usually don't use to let the user chose the value
to be filled especially if the li
how can i make one of the options in a select the default. (i
previously changed the select widget so that it only shows a selection
of options).
my code:
ModifyComment.base_fields['fk_bullet'] =
forms.ModelChoiceField(queryset=Bullet.objects.filter(fk_day=day_id))
i what one of the options in t
Hello there,
I'm using Django 0.96 here. I've got a couple of models
related by a ForeignKey that look more or less like this:
class Server(models.model):
name = models.CharField(maxlength=20)
users = models.ManyToManyField(User)
class Ticket(models.model):
des
What I'm trying to do seems relatively simple, but I have yet to find
a proper solution for it.
I'm trying to query a list of years from a database of registered
vehicles in my county and display them in a drop-down select menu in a
form.
Since the registered vehicles database has many cars of
Perhaps if I ask it in a different way:
1. A 'book' has a title (string) and an author (foreign key).
2. I use a ModelForm from the model.
3. I want the 'author' form-control to look like this:
Author:__ [click here to choose or add an author]
4. When you click the link it opens a div.
5. The
If you do all that stuff with jquery, why not have jquery hide the original
select (or modify it for that matter), and on select of an author, have
jquery set the selected author as 'selected' in the dropdown box? That way
there is no need for a custom validation or insertion, and when somebody has
Bump
\d
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For
On Wednesday, 01 October 2008 10:28:13 TiNo wrote:
> If you do all that stuff with jquery, why not have jquery hide the original
> select (or modify it for that matter), and on select of an author, have
> jquery set the selected author as 'selected' in the dropdown box? That way
> there is no need
On Wed, Oct 1, 2008 at 9:39 AM, Donn <[EMAIL PROTECTED]> wrote:
> I am expecting there to be at least hundreds of authors, perhaps thousands.
> It
> makes no sense to me to stream them all into a select control in the first
> place.
>
> I am aiming for a new kind of control that let's one page/fil
On Wednesday, 01 October 2008 16:13:18 Karen Tracey wrote:
> looking-glass icon on
> an admin change page where the ForeignKey field has been included in
> raw_id_fields.
Thanks for the lead!
\d
--~--~-~--~~~---~--~~
You received this message because you are subsc
Hi everyone,
What's the trick to getting a ModelChoiceField to use the first object
in a QuerySet as the initial value to get rid of -?
If I do:
qs = Model.objects.all()
my_field = forms.ModelChoiceField(queryset=qs, initial=qs[0])
I still get -- as the first choice.
objects.none(). How do I make the
> values bind to the fields without having to resort to changing the
> queryset to League.objects.all(). I don't want to do this cos the
> League data is huge.
>
> 2. Since the fields don't bind to the values, when the form get
> redispla
The text displayed in the drop down comes from the __str__ method of
the referenced model.
So, just implement the __str__ method in the model that your
ModelChoiceField references, and the display will show you that.
On Jun 7, 10:55 am, Mihai Damian <[EMAIL PROTECTED]> wrote:
> I&
10x, I eventualy solved the problem. I think I was doing some caching
and so the values didn't resemble the id's I was reading from the
database
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To
Hello,
I try to set data for a ModelChoiceField() manually. This means the
data is not in my db, so it s not in a Queryset.
my form:
class PictureForm(forms.Form):
image = forms.ImageField(label='Picture')
gallery= MyModelChoiceField(models.Gallery.ob
l='Picture')
gallery= MyModelChoiceField(models.Gallery.objects.none(),
empty_label=None)
__
View:
picture_form = forms.PictureForm()
picture_form.fields['gallery'].queryset = Gallery.objects.filter(...)
It displays all
With the ModelChoiceFiled you can represent relationships between
models.
So my form looks something like this:
class MyForm(forms.Form):
name = forms.CharField()
trials = forms.ModelChoiceField(...)
According to the documentation I have to pass the queryset to the
modelchoicefield
Hello,
I use a modelchoicefield and want to remove the entry that represents
"no item selected"(--), because in my
scenario I will only allow to select between existing entries.
Is there a way to do this?
Thanks,
-Toni
--~--~-~--~~~---~--~~
Yo
ble
with thousands of rows into a ModelChoiceField.
The postcode field changes relatively seldom, so a sensible solution
would seem to be some sort of passive display-only field which mirrors
the choice field's functionality (show the link's __unicode__ and hold
the link's pk for form va
I want to create a form with a select box populated from a query that
I pass from the view.
For example:
if country == 'Canada':
methods = ShippingMethod.objects.filter(
delivery_time__lte=time_avail_hours,
abbrev__contains='SC'
)
On Thu, Jun 11, 2009 at 12:13 PM, Bobby Roberts wrote:
>
> hi group
>
> i'm trying to create a drop box that is populated with a distinct list
> of values from a certain field (fieldname=page_plaque) in the table.
> Here is what i have in my forms.py
>
>
> class PagePlaqueModelChoiceField (f
> The issue is the line: WebPage.objects.filter(page_plaque!=''). The
> queryset syntax doens't use the != operator anywhere. To do != operations
> you need to instead do WebPage.objects.exclude(page_plaque='').
>
ok that got past the error but there are dupes in there. Is there a
way to pull
Hi.
You should take a read on the queryset api, that would help you a lot
In the furture. For distinct values add .distinct() so you fx get
...filter(...).distinct()
~Jakob
On Jun 11, 7:28 pm, Bobby Roberts wrote:
> > The issue is the line: WebPage.objects.filter(page_plaque!=''). The
> > quer
> Hi.
> You should take a read on the queryset api, that would help you a lot
> In the furture. For distinct values add .distinct() so you fx get
> ...filter(...).distinct()
>
> ~Jakob
Jakob -
I've read the docs and know about distinct. The issue here is that a
modelcho
y last post.
On Dec 12, 11:03 am, Aaron wrote:
> Say I have this model:
>
> model Foo(models.Model):
> bar = models.ForeignKey(Baz)
>
> I have a ModelForm for Foo (FooModelForm). However, instead of having
> a ModelChoiceField for bar, I want a single bar object in a h
esn't seem to be applicable. What I think I want to do is
override the description field in the RateForm to be a custom
derivative of ModelChoiceField... but I'm not sure where to intercept
validation, etc. -- Indeed the documentation seems to skip over
ModelChoiceField altogether. Can anyon
Hello,
I have a form with a ModelChoiceField, and when I want to create a new
bound form using the first form cleaned_data (that I stored in a
session before), I get an error when rendering the template ("Caught
TypeError while rendering: int() argument must be a string or a
number"
Hello,
I have a small issue, I am sure the solution is simple, but I couldn't
find it (I blame Monday). I have a model with a Many2Many field, and I
have a few forms for editing that model. Everything is working fine
there. In one specific case however I have to produce a form where the
user can s
Is there an easy way to use a ModelChoiceField with multiple databases?
The only thing I've seen that looks promising is overriding the form
__init__ and setting the queryset for the field. Seems kinda clunky.
--
You received this message because you are subscribed to the Google Groups
&q
Hello,
I have a model that has a foreign key field that I want to use in a form as
a select box.
That particular field at times appears multiple times in the database. How
do I make it
only have distinct values?
This is a snippet, drop down will have repeated values if same color is
entered:
cla
t work, of course, as ModelChoiceField has queryset as
required argument.
So I have to do something like,
class SetDefaultForm(forms.Form):
topics = forms.ChoiceField()
def __init__(self, user):
super(SetDefaultForm, self).__init__()
self.fields['topics'].choices=
On Fri, 2007-08-17 at 08:22 +, james_027 wrote:
> hi,
>
> while learning and experimenting with forms ... one should use
> ModelChoiceField in order to let newforms bind the value on a
> foreignkey field of a model. My concern is that in the real world, you
> usually don&
Hi all,
I have a newform GroupSelectionForm with:
group_id = forms.ModelChoiceField(Group.objects.all())
where users are supposed to choose their primary group.
However I only want to offer them groups in which they have
membership. I.e. instead of Group.objects.all() do something like
Group
initial works for me, however, you must set the initial by the id of the
record not the instance, i.e.
forms.ModelChoiceField(queryset=Bullet.objects.filter(fk_day=day_id),
initial = Bullet.objects.get(pk = day_id).id)
-richard
On 9/17/07, Rufman <[EMAIL PROTECTED]> wrote:
>
>
> how can i make
Gonzalo Delgado wrote:
>
> The question is: why doesn't something like this work:
>
> ticketform.fields['server'].queryset =
> Server.objects.filter(users=request.user)
> ?
> It doesn't end up on any error, but the rendered form doesn't filter out the
> server choices.. any clue?
>
>
El Tue, 06 Nov 2007 10:28:39 -0800
Chris Brand <[EMAIL PROTECTED]> escribió:
>
> Gonzalo Delgado wrote:
> >
> > The question is: why doesn't something like this work:
> >
> > ticketform.fields['server'].queryset =
> > Server.objects.filter(users=request.user)
> > ?
> > It doesn't end up on
I'm struggling with a newforms issue. Specifically I'm trying to pre-
select an option in a ModelChoiceField and I cannot figure out how
this can be accomplished. Here are the code snippets:
class Account(models.Model):
title = models.CharField(maxlength=30, unique=True
Hi,
I would like to use ModelChoiceField in the following ways:
models.py
class Project(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE, null=True, blank=True)
...
class Profile(models.Model):
project = models.ForeignKey(Project, on_delete
How do I get the value of a selected model choice field? I have a model
that has a field 'user' as a foreignKey and I am trying to figure out how
to get the value of a user that was selected.
I have a form that looks like below,
[image: image.png]
class update_entitlement_form(forms.ModelForm):
You can try something like this:
class SearchForm(forms.ModelForm):
year = forms.ChoiceField()
def __init__(self, *args, **kwargs):
super(SearchForm, self) .__init__(*args, **kwargs)
self.fields['year'].choices = \
set([(obj.year, obj.year) for obj in \
You can try something like this:
class SearchForm(forms.ModelForm):
year = forms.ChoiceField()
def __init__(self, *args, **kwargs):
super(SearchForm, self) .__init__(*args, **kwargs)
self.fields['year'].choices = \
set([(obj.year, obj.year) for obj in \
Thanks dmorozov, that worked fine in the sense that it returned only
unique years in a select box, but it still didn't order them properly
(getting non-duplicate years as 1961, 1931, 2000, 1975, 1995, etc.).
Somehow the order_by section of "set([(obj.year, obj.year) for obj in
Vehicle.objects.al
On Sep 5, 11:19 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-09-05 at 03:11 -0700, mwebs wrote:
> > Hello,
>
> > I use amodelchoicefieldand want to remove the entry that represents
> > "no item selected"(--), because in my
> > scenario I will only allow to select between ex
On Sep 22, 10:58 pm, BobZ <[EMAIL PROTECTED]> wrote:
> Thanks dmorozov, that worked fine in the sense that it returned only
> unique years in a select box, but it still didn't order them properly
> (getting non-duplicate years as 1961, 1931, 2000, 1975, 1995, etc.).
>
> Somehow the order_by sectio
Thanks Daniel. I've found solutions similar to yours in other threads
on the net, and everytime I test them, I literally get no form at all
in my rendered template.
My template appears to have all the correct code in it as you can see
in the link "search.html" at the bottom of this post.
Looking
I had SOME luck with "queryset=Vehicle.objects.filter(year=True)" in
that the form actually rendered in my template, but the year select
box is empty now. All other select boxes load fine (Make and Model)
with their data...only year still won't work.
On Sep 23, 10:44 am, BobZ <[EMAIL PROTECTED]>
On Sep 23, 4:44 pm, BobZ <[EMAIL PROTECTED]> wrote:
> Thanks Daniel. I've found solutions similar to yours in other threads
> on the net, and everytime I test them, I literally get no form at all
> in my rendered template.
> My template appears to have all the correct code in it as you can see
>
Wow, thank you so much Daniel.
I totally get this now, and it works!
Looks like I've sort of been skirting around this solution for a while
but, being clueless as I can be sometimes with Django, I never knew
what I could've been doing wrong.
Thanks a lot for the help again.
-Bob
On Sep 23, 4:
Solved: ModelChoiceField(empty_label=None)
On Feb 23, 9:14 pm, Brandon Taylor wrote:
> Hi everyone,
>
> What's the trick to getting a ModelChoiceField to use the first object
> in a QuerySet as the initial value to get rid of -?
>
> If I do:
> qs = Mode
Hello,
I have stepped through code, and cruised the django docs, forums, and
internet in general looking for how to setup an empty label with
TypedChoiceField (or ChoiceField.) I suspected it would be done
similar to the way it is done with ModelChoiceField.
With ModelChoiceField, we can
ok here's my form:
class ParseFileChoiceField (forms.ModelChoiceField):
def label_from_instance (self,obj):
return obj.ProcessFile
class FrmParser (forms.Form):
parsefile = ParseFileChoiceField(queryset=Upload.objects.filter
(numrecs__exact=0),empty_label='Choose',required=True,w
In a form, I have a field defined as ModelChoiceField
class myForm(forms.Form)
myfield = forms.ModelChoiceField(MyClass.objects.all())
myfield2 = forms.CharField()
My problem is that I cant seem to dynamically set the value that the
user selected for this field. When ever, user edits the
step.
-Regards
Adi
On Jun 26, 12:27 pm, mwebs <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I try to set data for a ModelChoiceField() manually. This means the
> data is not in my db, so it s not in a Queryset.
>
> my form:
>
> class PictureForm(forms.Form):
> i
Looking at the source, ModelChoiceField validates the given id against
the initial queryset, where you provided an empty one.
"models.Gallery.objects.none()"
So no id's validate. I think changing none() to all() should make it
work.
TiNo
On Jun 26, 9:01 pm, mwebs <[EMAIL
Hi!
When I try to test a post to a form that have a ModelChoiceField form
I get always a form error in that field "Select a valid choice".
The form is this:
class OperacionForm(forms.Form):
ticker = forms.ModelChoiceField(Valor.objects.all())
fecha = forms.DateFi
This solved the problem:
http://groups.google.com/group/django-users/browse_thread/thread/63c2058c7892f865
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to dj
On Fri, 2008-09-05 at 03:11 -0700, mwebs wrote:
> Hello,
>
> I use a modelchoicefield and want to remove the entry that represents
> "no item selected"(--), because in my
> scenario I will only allow to select between existing entries.
Specify a default value
jango?
>
> My current example is an address>post/ZIP-code relationship where
> Django's automatic field creation pulls in the whole postcode table
> with thousands of rows into a ModelChoiceField.
>
> The postcode field changes relatively seldom, so a sensible solution
This should fix it.
def __init__(self, something, *args, **kwargs):
super(ShippingMethodForm, self).__init__(*args, **kwargs)
self.fields["ship_method"].queryset =
ShippingMethod.objects.filter(something)
when you initiate the form, you do it like this:
form = ShippingMethodForm(
I tried in the view:
filter_string = "delivery_time__lte=time_avail_hours,
abbrev__contains='SC'"
formShip = ShippingMethodForm(filter_string)
Then the form def is:
class ShippingMethodForm(forms.Form):
# tricky thing done here to change queryset based on ticket date
and destination
shi
oops! missing the filter_string arg in __init__. After I added that,
I get:
ValueError .too many values to unpack
On May 11, 4:27 pm, adrian wrote:
> I tried in the view:
>
> filter_string = "delivery_time__lte=time_avail_hours,
> abbrev__contains='SC'"
> formShip = ShippingMethodForm(fil
For the record, here's what works:
In views.py:
if country == 'Canada':
delivery_time__lte=time_avail_hours
abbrev__contains='SC'
formShip = ShippingMethodForm(delivery_time__lte, abbrev__contains)
Then in models.py:
class ShippingMethodForm(forms.Form):
# tricky
def __init__(self, *args, **kwargs):
super(ShippingMethodForm, self).__init__(*args, **kwargs)
if self.fields['country'].initial == 'Canada':
filter_kwargs = { 'delivery_time__lte': time_avail_hours,
'abbrev__contains'='SC' }
elif: ...
else: ..
self.fi
I was struggling to find a solution to the ModelChoiceField looking up
100,000 students every time I wanted to add an RtI so I did the following.
Can anyone find problems with this, or have an alternate solution...This
does work though
Instead of using an id I used a student_number as an
.
In RateForm.clean I do the necessary search for the description model
if there isn't one already defined, and setting the text of the model
in any case.
The override of ModelChoiceField may well be simple ... I started to
go down that road before I realized it wasn't what I wanted in any
On 2011-04-21, at 4:07 PM, ekms wrote:
> So, what is the correct way to create a bound form of
> ModelChoiceField? I could store request.POST or myform.data instead
> of myform.cleaned_data, but I don't know if this is right.
You are confusing me when you say a bound form of a Mo
1 - 100 of 229 matches
Mail list logo