Closed Eloi-Marin closed 6 years ago
Hi, I uploaded a fix for your issue, updating to the latest version should now work for you.
On a side-note regarding what you are trying to do: your solution will not work unless you import all your models where you define this viewset. In order to avoid import them and to make your code more secure, you should checkout https://docs.djangoproject.com/en/1.11/ref/utils/#django.utils.module_loading.import_string
I am closing this issue or now, if your problem is not fixed, feel free to re-open it
When setting:
REST_FRAMEWORK = { 'DEFAULT_METADATA_CLASS': 'drf_auto_endpoint.metadata.AutoMetadata', } DRF_AUTO_METADATA_ADAPTER = 'drf_auto_endpoint.adapters.AngularFormlyAdapter'
and using a ModelViewSet instead of auto_endpoint with a custom get_serializer_class, eg:
`class MyViewSet(viewsets.ModelViewSet): def get_queryset(self): model = eval(self.kwargs.get('string')) return model.objects.all()
class MySerializer(serializers.ModelSerializer): class Meta(): model = None`
where I have set the url pattern:
url(r'^api/(?P[\w-]+)/$',MyViewSet.as_view({'get':'list'})),
http request GET works, however when I request OPTIONS I get an internal server error:
File ".../drf_auto_endpoint/metadata.py", line 54, in determine_metadata serializer_instance = view.serializer_class() TypeError: 'NoneType' object is not callable
My goal is setting up a view where I can run an OPTIONS request for any model, given its name as a parameter in the URL.