Good morning,

Yeah it works. Thank you

Agni Venus <praispra...@gmail.com> schrieb am Mo., 15. Feb. 2021, 05:32:

> Put this inside and below if your model
>
>
>
> Def __str__(self):
> return self.what-ever-name-you-want
>
> On Mon, 15 Feb, 2021, 10:01 am Agni Venus, <praispra...@gmail.com> wrote:
>
>> Put this below the model...
>> Add
>> Def __str__(self):
>> return self.what-ever-name-you-want
>>
>> On Mon, 15 Feb, 2021, 10:00 am Agni Venus, <praispra...@gmail.com> wrote:
>>
>>> Add
>>> Def __str__(self):
>>> return self.what-ever-name-you-want
>>>
>>> On Sun, 14 Feb, 2021, 9:00 pm sebasti...@gmail.com, <
>>> sebastian.ju...@gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> i have installed per pip django-filters.
>>>>
>>>> Models.py:
>>>>
>>>> class Productinterests(models.Model):
>>>>     id = models.AutoField(primary_key=True)
>>>>     name = models.CharField(max_length=255, default="", blank=False,
>>>> null=False)
>>>>
>>>> class Address(models.Model):
>>>>    productinterests = models.ManyToManyField(Productinterests,blank=True,
>>>> default=0)
>>>>    lastname = models.CharField(max_length=255, default="", )
>>>>    firstname = models.CharField(max_length=255, default="", blank=True,
>>>> null=True)
>>>>
>>>> filters.py:
>>>>    class AddressFilter(django_filters.FilterSet):
>>>> lastname = django_filters.CharFilter(lookup_expr='icontains',label=
>>>> "Nachname")
>>>> firstname = django_filters.CharFilter(lookup_expr='icontains', label=
>>>> "Vorname")
>>>>
>>>>     productinterests = django_filters.ModelMultipleChoiceFilter(
>>>> to_field_name='name',queryset=Productinterests.objects.all(),
>>>> widget=forms.CheckboxSelectMultiple, label="Produktinteresse")
>>>>
>>>>     class Meta:
>>>>        model = Address
>>>>        fields = ['lastname','firstname','productinterests' ]
>>>>
>>>> views.py:
>>>>    def search(request):
>>>>          liste = Address.objects.all()
>>>>
>>>>          address = AddressFilter(request.GET, queryset=liste)
>>>> return render(request, 'search/address_list.html', {'filter':
>>>> user_filter})
>>>>
>>>>
>>>> *Problem: Website shows in Multiselect Productinterest only as Output:*
>>>> * "Productinterests object (1)" instead of name from object. How can i
>>>> output name?*
>>>>
>>>> Regards
>>>>
>>>> --
>>>> 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 view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/636ab5c4-d24e-42ab-bec2-be2eab833bdbn%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/636ab5c4-d24e-42ab-bec2-be2eab833bdbn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CADaZBzFj_67RTdDmtcbA3LcsxJ_nH6OXmEg%3DCMCcjB29N-bSxA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CADaZBzFj_67RTdDmtcbA3LcsxJ_nH6OXmEg%3DCMCcjB29N-bSxA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKGT9mzrhfN%3DPd7PPr8w%2BJqh3T%2B6chQi%2B48bfCxqmpL5jCL9AA%40mail.gmail.com.

Reply via email to