ModuleNotFoundError: No module named 'rest-auth'

29 views
Skip to first unread message

Tim Vogt

unread,
May 17, 2019, 5:22:06 PM5/17/19
to Django REST framework
I have rest_auth installed but recieve an error.
I user pipenv shell on osx.

rest-auth = "*"

ModuleNotFoundError: No module named 'rest-auth'

Felipe Rodrigues

unread,
May 17, 2019, 5:41:45 PM5/17/19
to django-res...@googlegroups.com
Are you sure you're running this command from within pipenv's shell?


--
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/c8d65d60-7993-4a93-867d-866b2774c782%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

TimT Vogt

unread,
May 18, 2019, 2:59:22 AM5/18/19
to django-res...@googlegroups.com
Yes,
Very strange.
I also add it to settings.py


Verstuurd vanaf mijn iPhone

Tim Vogt

unread,
May 18, 2019, 6:06:38 AM5/18/19
to django-res...@googlegroups.com
DEBUG = True
#settings.py
ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'posts',
'rest_framework',
'rest_framework.authtoken',
'rest-auth',
]
REST_FRAMEWORK = {

'DEFAULT_PERMISSION_CLASSES':[
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_AUTHENTICATION_CLASSES':[
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
],




#post/views.py

from rest_framework import generics , permissions

from . import models
from . import serializers
from . models import Post
from . permissions import IsAuthorOrReadOnly


class PostList(generics.ListAPIView):
permission_classes = (permissions.IsAuthenticated,)
queryset = models.Post.objects.all()
serializer_class = serializers.PostSerializer


class PostDetail(generics.RetrieveUpdateDestroyAPIView):
permission_classes = (IsAuthorOrReadOnly,)
queryset = models.Post.objects.all()
serializer_class = serializers.PostSerializer

#post/permissions.py
from rest_framework import permissions


class IsAuthorOrReadOnly(permissions.BasePermission):
"""

A Base Class from wich all permission classes should inherit.
"""

def has_object_permission(self, request, view, obj):
# Read only permissions ara allowed for any request
if request.method in permissions.SAFE_METHODS:
return True
# Write permissions are only allowed to the author of the post
return obj.author == request.user()






Op za 18 mei 2019 om 08:59 schreef TimT Vogt <timt...@gmail.com>:

Tim Vogt

unread,
May 18, 2019, 6:07:37 AM5/18/19
to django-res...@googlegroups.com
This happens:

(api_django_new) bash-3.2$ python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/timvogt/.virtualenvs/api_django_new-CWU1E4iq/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/Users/timvogt/.virtualenvs/api_django_new-CWU1E4iq/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/Users/timvogt/.virtualenvs/api_django_new-CWU1E4iq/lib/python3.7/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
    raise _exception[0](_exception[1]).with_traceback(_exception[2])
  File "/Users/timvogt/.virtualenvs/api_django_new-CWU1E4iq/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/Users/timvogt/.virtualenvs/api_django_new-CWU1E4iq/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/timvogt/.virtualenvs/api_django_new-CWU1E4iq/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/Users/timvogt/.virtualenvs/api_django_new-CWU1E4iq/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/Users/timvogt/.virtualenvs/api_django_new-CWU1E4iq/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'rest-auth'

Op za 18 mei 2019 om 12:06 schreef Tim Vogt <timt...@gmail.com>:

Jakob Damgaard Møller

unread,
May 18, 2019, 11:26:43 AM5/18/19
to django-res...@googlegroups.com
rest_auth != rest-auth ??


For more options, visit https://groups.google.com/d/optout.


--
Jakob Damgaard Olsen
Tlf: 24613112

Tim Vogt

unread,
May 18, 2019, 11:41:55 AM5/18/19
to django-res...@googlegroups.com
thanx!
😁👍 
That was the solution

Op za 18 mei 2019 om 17:26 schreef Jakob Damgaard Møller <jak...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages