Reputation: 1
I am new to Django and coding in general.
When I try to use the django-tastypie (0.14.4) in my virtual env using pipenv, I get the following error when I try to launch the server ModuleNotFoundError: No module named 'tastypie'.
I tried the solutions in here and in here
Here is my models.py of my api app:
from tastypie.resources import ModelResource
from movies.models import Movie
class MovieResource(ModelResource):
class Meta:
queryset = Movie.objects.all()
resource_name= "movies"
excludes = ["date_created"]
and my urls.py:
from django.contrib import admin
from django.urls import path, include
from api.models import MovieResource
movie_resource = MovieResource()
urlpatterns = [
path('admin/', admin.site.urls),
path("movies/",include("movies.urls")),
path("api/",include(movie_resource.urls))
and the full error:
Exception ignored in thread started by: <function check_errors.<locals>.wrapper at 0x10e6d9090>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/core/management/__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/sylvainkreuter/vidly1/api/models.py", line 2, in <module>
from tastypie.resources import ModelResource
ModuleNotFoundError: No module named 'tastypie'
Thank you very much for your help.
Upvotes: 0
Views: 767
Reputation: 51
confirm if you have installed django-tastypie in your virtual environment by: pipenv graph
and enable the virtual environment using: pipenv shell
now try to run your command.....
Upvotes: 0