*Checklist*

- [x] I have verified that that issue exists against the `master` branch of 
Django REST framework.
- [x] I have searched for similar issues in both open and closed tickets 
and cannot find a duplicate.
- [x] This is not a usage question. (Those should be directed to the 
[discussion 
group](https://groups.google.com/forum/#!forum/django-rest-framework) 
instead.)
- [x] This cannot be dealt with as a third party library. (We prefer new 
functionality to be [in the form of third party 
libraries](http://www.django-rest-framework.org/topics/third-party-resources/#about-third-party-packages)
 
where possible.)
- [x] I have reduced the issue to the simplest possible case.
- [ ] I have included a failing test as a pull request. (If you are unable 
to do so we can still accept the issue.)

*Steps to reproduce*

from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.renderers import JSONRenderer
from rest_framework import status, serializers, viewsets
from rest_framework.decorators import api_view
from rest_framework.authentication import SessionAuthentication, 
BasicAuthentication, TokenAuthentication
from rest_framework.permissions import IsAuthenticated, AllowAny


class status(APIView):
    permission_classes = (AllowAny,)


    def get(self, request):
        # return 200 if have registered


        if len(models.bootstrap.objects.all()) > 0:
            return Response({'data': 'hi'}, status=status.HTTP_200_OK)
            # return HttpResponse(status=200)
        else:
            return Response({'data': 'bye'}, status=status.HTTP_200_OK)
            # return HttpResponse(status=204)


*Expected behavior*
Loads the normal REST framework page.

*Actual behavior*
Errors out, says no attribute found. Works if I use the commented default 
return HttpResponse. Is there anything obvious I am doing wrong? 

Environment:




Request Method: GET
Request URL: http://<redacted>:34571/client/status/


Django Version: 1.10.6
Python Version: 3.4.2
Installed Applications:
['client',
 'rest_framework',
 'rest_framework.authtoken',
 'django_cron',
 'bootstrap3',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']






Traceback:


File 
"/usr/local/lib/python3.4/dist-packages/django/core/handlers/exception.py" 
in inner
  42.             response = get_response(request)


File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py" 
in _get_response
  187.                 response = self.process_exception_by_middleware(e, 
request)


File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py" 
in _get_response
  185.                 response = wrapped_callback(request, *callback_args, 
**callback_kwargs)


File 
"/usr/local/lib/python3.4/dist-packages/django/views/decorators/csrf.py" in 
wrapped_view
  58.         return view_func(*args, **kwargs)


File "/usr/local/lib/python3.4/dist-packages/django/views/generic/base.py" 
in view
  68.             return self.dispatch(request, *args, **kwargs)


File "/usr/local/lib/python3.4/dist-packages/rest_framework/views.py" in 
dispatch
  483.             response = self.handle_exception(exc)


File "/usr/local/lib/python3.4/dist-packages/rest_framework/views.py" in 
handle_exception
  443.             self.raise_uncaught_exception(exc)


File "/usr/local/lib/python3.4/dist-packages/rest_framework/views.py" in 
dispatch
  480.             response = handler(request, *args, **kwargs)


File "/home/pi/ee4-FYP/software/peer/client/views.py" in get
  32.             return Response({'data': 'hi'}, status=status.HTTP_200_OK)


Exception Type: AttributeError at /client/status/
Exception Value: type object 'status' has no attribute 'HTTP_200_OK'


-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to