Hi,

On the html form, you could probably use javascript to filter out the value 
in the many to many when you select the primary language.

In the django form, you could add extra validation by defining 
form.clean_further_languages(self)

Collin

On Sunday, December 7, 2014 12:37:22 AM UTC-5, inoyon artlover KLANGRAUSCH 
wrote:
>
> Hi Collin, yes exactly. It is as follows:
> User can select a main coummunication language which is connected as 
> ForeignKey to the main langauges table.
> Withn the field below the user can select further languages but when I 
> select english as main language,
> this language shouldn't be available within the ManyToMany.. 
>
> Am Samstag, 6. Dezember 2014 18:25:59 UTC+1 schrieb Collin Anderson:
>>
>> Hi,
>>
>> Are you saying you have a ForeignKey choice field on the same form (above 
>> the ManyToMany), and when you change the choice field it should change the 
>> available values in the ManyToMany?
>>
>> Collin
>>
>> On Thursday, December 4, 2014 7:20:13 PM UTC-5, inoyon artlover 
>> KLANGRAUSCH wrote:
>>>
>>> Very cool! :) Many thanks, once more! :) Could be off-topic, but there 
>>> is somethin more tricky:
>>> Before a ManyToManyField there is one ForeignKeyField which has few of 
>>> the same values. 
>>> So the ForeignKey-value has to be excluded from the ManyToMany choices. 
>>> For example 
>>> the ForeignKey selection (labeld as: additional values) could trigger on 
>>> submit a queryset and 
>>> a view colud display the filterd ManyToManyField... (btw. I am very new 
>>> to python/django so..
>>> try'n error is the tedious way to go since two month... )
>>>
>>>
>>> Am Freitag, 5. Dezember 2014 00:52:18 UTC+1 schrieb larry....@gmail.com:
>>>>
>>>> On Thu, Dec 4, 2014 at 6:46 PM, inoyon artlover KLANGRAUSCH 
>>>> <inoyona...@googlemail.com> wrote: 
>>>> > Great, it works with one form but not with an another... 
>>>> > Btw. how is it possible to overwrite the 'this field is required' 
>>>> error 
>>>> > message? 
>>>>
>>>> You can provide your custom set of default errors to the form field 
>>>> definition, e.g.: 
>>>>
>>>> my_default_errors = { 
>>>>     'required': 'You better enter this field!', 
>>>>     'invalid': 'You can do better than that!' 
>>>> } 
>>>>
>>>> class MyForm(forms.Form): 
>>>>     some_field = forms.CharField(error_messages=my_default_errors) 
>>>>
>>>>
>>>> > 
>>>> > Many thanks and best regards! :) 
>>>> > 
>>>> > Am Donnerstag, 4. Dezember 2014 23:01:15 UTC+1 schrieb 
>>>> larry....@gmail.com: 
>>>> >> 
>>>> >> On Thu, Dec 4, 2014 at 4:54 PM, inoyon artlover KLANGRAUSCH 
>>>> >> <inoyona...@googlemail.com> wrote: 
>>>> >> > Hi there, I got a following Form-Class: 
>>>> >> > 
>>>> >> > 
>>>> >> > class CustomUserprofileInterestsForm(forms.ModelForm): 
>>>> >> > 
>>>> >> >     interests = forms.ModelMultipleChoiceField( 
>>>> >> >         queryset=Interests.objects.all(), 
>>>> >> >         widget=forms.CheckboxSelectMultiple) 
>>>> >> > 
>>>> >> > 
>>>> >> > I want to limit the choices for example to 6 of all displayed. 
>>>> >> > Is it possible with some optional arguments I don't know somehow? 
>>>> >> > 
>>>> >> 
>>>> >> You can write your own clean method on the form, e.g.: 
>>>> >> 
>>>> >> def clean_interests(self): 
>>>> >>     value = self.cleaned_data['interests'] 
>>>> >>     if len(value) > 6: 
>>>> >>         raise forms.ValidationError("You can't select more than 6 
>>>> items.") 
>>>> >>     return value 
>>>>
>>>

-- 
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+unsubscr...@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/9d8ceee6-b888-4613-92f5-4783cb2d4e67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to