Re: django-filters many to many

2021-02-15 Thread Sebastian Jung
Yeah but this doesn't work. I describe IT in my Last Post why

Regards

MOHIT DILIP MAKWANA  schrieb am Mo.,
15. Feb. 2021, 15:22:

> Hey,
>   You can add a dunder method for your  "Productinterests" model to
> return the name of the object instead of the name of model.
> It involves the use of '__str__()' method. You can implement it in the
> following way:
>
> class Productinterests(models.Model):
> id = models.AutoField(primary_key=True)
> name =
> models.CharField(max_length=255, default="", blank=False, null=False)
> def __str__(self):
> return str(self.name)
>
> Just add the extra function in your models, and then whenever a
> "Productinterests" object is called, it will be outputted as the value of
> its 'name' property.
>
> 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/34ef8ba9-eca9-4c67-923f-b4815dcd9eaan%40googlegroups.com
> 
> .
>

-- 
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/CAKGT9my%2B-D1HW4s0C_3P5hgfr0BsBDG4ianY0k1EQ-YA_w3sKw%40mail.gmail.com.


Re: django-filters many to many

2021-02-15 Thread MOHIT DILIP MAKWANA
Hey,
  You can add a dunder method for your  "Productinterests" model to 
return the name of the object instead of the name of model.
It involves the use of '__str__()' method. You can implement it in the 
following way:

class Productinterests(models.Model):
id = models.AutoField(primary_key=True)
name = 
models.CharField(max_length=255, default="", blank=False, null=False) 
def __str__(self):
return str(self.name)

Just add the extra function in your models, and then whenever a 
"Productinterests" object is called, it will be outputted as the value of 
its 'name' property.

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/34ef8ba9-eca9-4c67-923f-b4815dcd9eaan%40googlegroups.com.


Re: django-filters many to many

2021-02-15 Thread Sebastian Jung
Hello,

now it shows on frontend the name. Problem is, that in value also string is
instead id.

For example:


 Test
  

but this must be:


 Test
  

How can i change this?

Regards

Am Mo., 15. Feb. 2021 um 05:32 Uhr schrieb Agni Venus :

> 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,  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,  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
 
 .

>>> --
> 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
> 
> .
>

-- 
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/CAKGT9myWfChiyyV7_uSnDhOT8GYng4rvvyEbiZSFjCpQPiAx0g%40mail.gmail.com.


Re: django-filters many to many

2021-02-15 Thread Sebastian Jung
Good morning,

Yeah it works. Thank you

Agni Venus  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,  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,  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
 
 .

>>> --
> 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
> 
> .
>

-- 
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.


Re: django-filters many to many

2021-02-14 Thread Agni Venus
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,  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,  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
>>> 
>>> .
>>>
>>

-- 
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.


Re: django-filters many to many

2021-02-14 Thread Agni Venus
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,  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
>> 
>> .
>>
>

-- 
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/CADaZBzFZ_rEC5VsB04QKEYyVLbJM%3Dv%2BVxzxYYbH2Pu9Rc7Vzkg%40mail.gmail.com.


Re: django-filters many to many

2021-02-14 Thread Agni Venus
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
> 
> .
>

-- 
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/CADaZBzG5fS8As84h7x2ouRSS8bEF4nbSEO%3Dn5CrDNE-VegakYg%40mail.gmail.com.