Open tkhyn opened 5 years ago
Original comment by Sharo Qadir (Bitbucket: sharlock93, GitHub: sharlock93).
I have the same problem,
#!python
get_limit_choices_to
most likely is used to get
#!python
limit_choices_to
attribute from django as its used in foreign_relations when rendering for ModelForm
how it is suppose to work with gm2m and rest framework is something I haven't thought about. but I fixed this issue temporarily by making a new class that extends GM2MField
#!python
from gm2m import GM2MField as gm2m_field
class GM2MField(gm2m_field):
def get_limit_choices_to(self):
pass
this you can put at the top of your models.py file and leave the rest of the code as is.
Original comment by Thomas Khyn (Bitbucket: tkhyn, GitHub: tkhyn).
Hi,
The limit_choices_to
feature is not implemented yet in django-gm2m
(see the docs). As I have not used django-gm2m
for more than a year (nor django at all), and my time is very limited at the moment, it is unlikely I'll have the time to implement it.
However, I could probably think of a temporary fix just to avoid the exception as per @sharlock93's suggestion. Would you be happy with that?
Original comment by Nikita (Bitbucket: konyshevn, GitHub: konyshevn).
Hi, I fixed it like @Sharo Qadir. That's enough, thank you.
Original report by Nikita (Bitbucket: konyshevn, GitHub: konyshevn).
I am using Django REST Framework and django-gm2m application:
models.py
serializers.py
views.py
But I open api url I get the error -
Does anyone know how to fix it?