When you have a problem like this, try first to remove all .pyc files El lun., 24 dic. 2018 a las 3:41, Adrian Lazăr (<[email protected]>) escribió:
> Hello, The space between the dot and the module does not make any > difference, thank you though. > > I have managed to resolve this issue by re-writing the entire project. > Somehow it was bugged from the beginning. Thank you guys! > > On Sunday, December 23, 2018 at 5:21:50 AM UTC+2, Wandss wrote: >> >> Hi, I believe the issue is at the import: "from . serializers import...." >> >> Try to remove the space between the dot and the serializers: >> >> "from .serializers import ..." >> >> Regards >> >> Em Sáb, 22 de dez de 2018 23:44, Adrian Lazăr <[email protected] >> escreveu: >> >>> Yes. It is listed within the installed_apps list. >>> >>> On Sun, Dec 23, 2018, 02:41 Roberth Mejias <[email protected] wrote: >>> >>>> Did you add *rest_framework *in the settings.py file? in the >>>> definition of applications? >>>> >>>> On Sat, Dec 22, 2018 at 7:38 PM Adrian Lazăr <[email protected]> >>>> wrote: >>>> >>>>> Hello guys, >>>>> >>>>> I am struggling to determine what seems to be the issue here. There >>>>> error that I get is: NameError: name 'viewsets' is not defined >>>>> >>>>> I am following the Quick Start Tutorial while using Python3 and Django >>>>> 2.1 >>>>> >>>>> Here is my views.py code: >>>>> from django.shortcuts import render >>>>> from django.contrib.auth.models import User, Group >>>>> from rest_framework import viewsets >>>>> from . serializers import UserSerializer, GroupSerializer >>>>> >>>>> >>>>> class UserViewSet(viewsets.ModelViewSet): >>>>> """ >>>>> API endpoint that allows users to be viewed or edited. >>>>> """ >>>>> serializer_class = UserSerializer >>>>> queryset = User.objects.all().order_by('-date_joined') >>>>> >>>>> >>>>> class GroupViewSet(viewsets.ModelViewSet): >>>>> """ >>>>> API endpoint that allows groups to be viewed or edited. >>>>> """ >>>>> serializer_class = GroupSerializer >>>>> queryset = Group.objects.all() >>>>> And here is my urls.py code: >>>>> >>>>> from django.contrib import admin >>>>> from django.urls import path >>>>> from django.conf.urls import url, include >>>>> from rest_framework import routers >>>>> from quickstart import views >>>>> >>>>> router = routers.DefaultRouter() >>>>> router.register(r'users', views.UserViewSet) >>>>> router.register(r'groups', views.GroupViewSet) >>>>> >>>>> # Wire up our API using automatic URL routing. >>>>> # Additionally, we include login URLs for the browsable API. >>>>> >>>>> >>>>> urlpatterns = [ >>>>> url(r'^', include(router.urls)), >>>>> url(r'^api-auth/', include('rest_framework.urls', namespace= >>>>> 'rest_framework')) >>>>> ] >>>>> >>>>> >>>>> >>>>> >>>>> As you can see, I have imported the viewsets and declared them for the >>>>> class argument. Please let me know what am I doing wrong. Here is the link >>>>> for the short tutorial: >>>>> https://www.django-rest-framework.org/tutorial/quickstart/ >>>>> >>>>> Thank you!! >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> 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. >>>>> >>>> >>>> >>>> -- >>>> piedrucci... >>>> >>>> -- >>>> 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. >>>> >>> -- >>> 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. >>> >> -- > 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. > -- -------- Gonzalo Amadio -- 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.
