Tuesday, September 1, 2015

two modelForm fields to a one model Field

Hi,

  In my first post, I have a simple question:

  Its possible a modelForm have two fields for a one model Field ? 

  My codes:


 In my models:

   class MyClass(models.Model):
           COMMON_AMENITIES_CHOICES = (('A', 'Aditional'),
                                                        ('C', 'Commom'))

           type = models.CharField(u'type', max_length=1, choices=COMMON_AMENITIES_CHOICES )

           name = moldes.CharField(max_length=250)



With a default form I have this:

class MyClassForm(forms.Form):      from .models import MyClass        COMMON_AMENITIES_CHOICES = tuple(Amenitie.objects.filter(          type_amenitie='C').values_list('id', 'name'))      ADITIONAL_AMENITIES_CHOICES = tuple(Amenitie.objects.filter(          type_amenitie='A').values_list('id', 'name'))        common_amenitie = forms.MultipleChoiceField(          choices=COMMON_AMENITIES_CHOICES,          label=u'Common Amenities'      )      aditional_amenitie = forms.MultipleChoiceField(          choices=ADITIONAL_AMENITIES_CHOICES,          label=u'Common Amenities'      )


  My question:

  Its possible implements this with a modelForm? 

  -- Leandro.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6f2fd69a-6f30-425a-91b3-d32b256ef0e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment