On 5/18/2009 12:55 PM, Rusty Greer wrote:
> 
> i have the following:
> 
> a model:
> class MyClass(models.Model):
>     otherClass = models.ForeignKey('otherClass')
>     someData = models.CharField(max_length=20)
> 
> 
> class MyClassForm(forms.ModelForm):
> 
>     class Meta:
>         model = MyClass
>         fields = ('someData')
> 
> 
> When the user edits or adds a MyClass object with the MyClassForm, the 
> otherClass will always be known.  I don't want the user to ever change 
> the otherClass.  What I want it to be in the MyClassForm is a hidden 
> field.  I know I can do this with a Form instead of a ModelForm, but I 
> like the convenience of the ModelForm.  Is there a way to pass hidden 
> inputs through a ModelForm and still get the convenience of the ModelForm?
> 
> Any help would be appreciated.

Just override otherClass's widget.
See: 
<http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-default-field-types>

-- 
George

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to