django importerror: cannot import name list_route

  • Last Update :
  • Techknowledgy :

Im trying to add a new endpoint by marking it with @list_route but when i try to import if :

from rest_framework.decorators
import list_route

Suggestion : 2

Im trying to add a new endpoint by marking anycodings_django-rest-framework it with @list_route but when i try to import anycodings_django-rest-framework if :,It cant find it. Do i need to install anycodings_django-rest-framework something for this to work (I'm new to anycodings_django-rest-framework django)?,The list_route decorator is present in anycodings_django version 3.1.3. See: anycodings_django https://github.com/tomchristie/django-rest-framework/blob/3.1.3/rest_framework/decorators.py,More info in the release 3.8 anycodings_django announcement

Im trying to add a new endpoint by marking anycodings_django-rest-framework it with @list_route but when i try to import anycodings_django-rest-framework if :

from rest_framework.decorators
import list_route

Suggestion : 3

Improved error messages if no .to_representation implementation is provided on a field subclass. #6996,Fix issue if rest_framework.authtoken.models is imported, but rest_framework.authtoken is not in INSTALLED_APPS. [#7571],authtoken.views import coreapi from rest_framework.compat, not directly. #5921,Possible backwards compatibility break if you were relying on such fields being excluded from the outgoing representation. In order to restore the old behaviour you can override data to exclude the field when None.

In order to maintain the old behaviour you may need to pass the value of read_only fields when calling save() in the view:

def perform_create(self, serializer):
   serializer.save(owner = self.request.user)

For example:

@property
def data(self):
   ""
"
Drop `maybe_none`
field
if None.
""
"
data = super().data
if 'maybe_none' in data and data['maybe_none'] is None:
   del data['maybe_none']
return data