As I said I don't use ViewSets, but if you add in mixins that cause the signature of the ViewSet to change it cannot easily and automatically generate schemas--at least this is my understanding. The mixins are used in generic views and are not generally needed when defining your own views except under very few situations when you need to override a lot of functionality in the given generic views. You might want to just use the generic view I mentioned previously.
ViewSets are there to make things easy and give you some additional perks, but they take away a lot of flexibility. ~Carl On Tue, Sep 29, 2020 at 4:10 PM Ali Yazdi <ma.yazd...@gmail.com> wrote: > I've got a new problem with this new viewset that when I generate schema > with `generateschema --file schema.yml` it says: > ``` > UserWarning: <class 'recommendation.api.views.RecommendationViewSet'> is > not compatible with schema generation > warnings.warn( > ``` > But, it creates the schema of that viewset! > > On Tuesday, September 29, 2020 at 11:04:35 PM UTC+3:30 Ali Yazdi wrote: > >> Thanks for your answer. I try using >> `(mixins.RetrieveModelMixin,mixins.ListModelMixin, GenericViewSet)` without >> setting `http_method_names = ['get']` and my action works fine for `post` >> method. >> Thank you Carl. >> >> On Tuesday, September 29, 2020 at 9:47:59 PM UTC+3:30 carl....@gmail.com >> wrote: >> >>> If you set `http_method_names = ['get']` and the POST is on the same >>> endpoint it won't allow a POST. You might want to add 'post' to that >>> variable. >>> I, myself don't use ViewSets. I tend to use generic Views. In your case >>> the ListCreateAPIView generic view in this case. You can find it at >>> https://www.django-rest-framework.org/api-guide/generic-views/#listcreateapiview >>> >>> ~Carl >>> >>> On Tue, Sep 29, 2020 at 11:16 AM Ali Yazdi <ma.ya...@gmail.com> wrote: >>> >>>> 1. I have a `viewsets.ModelViewSet` that has `http_method_names = >>>> ['get']` >>>> 2. and its action method needs to have `methods=['get', 'post']` >>>> 3. But `post` method is not allowed for its action >>>> 4. I don't is it normal behavior to have this scenario or not? >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Django REST framework" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to django-rest-fram...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/django-rest-framework/abec1376-0619-4557-a7ea-1bab1f6473aan%40googlegroups.com >>>> <https://groups.google.com/d/msgid/django-rest-framework/abec1376-0619-4557-a7ea-1bab1f6473aan%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> >>> >>> -- >>> >>> ------------------------------------------------------------------------------- >>> Carl J. Nobile (Software Engineer) >>> carl....@gmail.com >>> >>> ------------------------------------------------------------------------------- >>> >> -- > You received this message because you are subscribed to the Google Groups > "Django REST framework" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-rest-framework+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-rest-framework/411bdc9a-6f7d-40e2-8b16-d6e4298af2dfn%40googlegroups.com > <https://groups.google.com/d/msgid/django-rest-framework/411bdc9a-6f7d-40e2-8b16-d6e4298af2dfn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- ------------------------------------------------------------------------------- Carl J. Nobile (Software Engineer) carl.nob...@gmail.com ------------------------------------------------------------------------------- -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/CAGQqDQJML4z1KCsuS8sOXhMnZusjqe0buiJVsa4R8yDfrhu56Q%40mail.gmail.com.