Django REST Framework Import Error - django

I'm trying to install Django REST framework and I keep getting:
No module named 'rest_framework'
I've added:
'rest_framework' to my INSTALLED_APPS = []
I installed through pip3 and it still doesn't seem to be working.

This should not be the case. You might have installed globally or inside virtualenv.
Always installed your dependencies inside a virtualenv.
I think best way to get it working.
source <virtualenv>/bin/activate
pip install djangorestframework
Next whenever you work with your project re-enable back virtualenv.

Related

unresolved import 'rest_framework' after installing djangorestframework

I saw similar posts created before, but nothing helped me in the end.
I am using Python 3.7.7 and my IDE is VSC.
I installed pip install djangorestframework (both in my virtualenv and outside of it)
Added 'rest_framework', to INSTALLED_APPS. I did this by command pip install djangorestframework
Now, to used djangorestframework, I created a file serializer with from rest_framework import serializers
Now, rest_framework becomes underlined with the message unresolved import 'rest_framework'.
The whole app still works, there is no error in the console.
What would you advise me to do?
Thanks!
It sounds like VSC doesn't see that you have rest_framework installed. I would try re-setting up your Python Interpreter. Hopefully, you're using some kind of virtual environment that you can tell VSC to look at for all your dependencies.
Using Python Environments in VS Code
I turned off and on the VSC and it worked

cant import flask-wtf after install

I have been looking around for an answer to this question, but everywhere I see the advice of running a pip install flask-wtf in the virtual environment. The requirements have already been satisfied in mine, but for some reason I am getting a missing module error. I am working on a school project building a website using flask and would really appreciate the help. My import is:
from flask_wtf import Form`
When I try to run the install command I get a message that says the requirement is already satisfied, as shown in this image.
Based on the screenshot, your flask-wtf and friends are installed outside virtualenvs, in the system site-packages directory.
It'd be a good idea to uninstall those from the global site-packages directory (python3 -m pip uninstall flask-wtf wtforms flask jinja2 click werkzeug markupsafe itsdangerous), create and activate a virtualenv (python3 -m venv my_venv and ./my_venv/bin/activate), then reinstall the dependencies within the virtualenv.

I cannot found modules in Django

I'm trying to connect my Django with my MongoDB.
So, first of all, I install this:
pip install djongo
And all go fine, no errors.
But If you see my models.py archive:
It's like Django it's not finding and I can't import the models.
I tried to install again Django, but it says to me that it's already installed.
I think I'm installing this in another path or something like that, but I don't know how to solve this.
My Django archive its in C:\PROYECTOS\PageSpeed_Insights__Selenium-Python\miweb
It seems that you are installing djongo in your virtualenv paginaweb, you have to configure PyCharm (or whatever IDE you are using) to look for the packages in that virtualenv, here you can see how to do it for PyCharm. It should work after that.

ModuleNotFoundError: No module named 'push_notifications' I am getting this error after I've uninstalled the module django push notification

snap of error is here which I am getting while I am migrate
First I've installed this package using pip install django-push-notifications
after that I've removed this package through pip uninstall django-push-notifications after that when I've tried migrating this. I am getting this error
You have uninstalled the module, therefore Django could not find it. Thats why it's giving error.
If you have uninstalled the module, please remove push_notifications present in INSTALLED_APPS of your settings.py file
Check, if you still have it registered in your Installed_Apps in settings.py. If so remove it.
If its not in the installed_apps then check your URLCONF --> project/urls.py if there's any url related to it.

Path issue Pip (Psycopg2) inside VirtualEnv

When using Pip (6.0.8) to install Django (1.9) and Psycopg2 (2.6.1), Django got installed in the env/lib/python2.7/site-packages folder and Psycopg2 in the env/lib64/python2.7/site-packages folder.
When I'm using command line (eg python manage.py migrate) or >>> import psycopg2, this all works fine. But when Mod_WSGI is running the application it complains that there is no module Psycopg2.
I'm able to work around this issue by adding the lib64 as a python path in my Apache conf file, but I'm pretty sure this is not the best possible way.
Any suggestions for a better solution?
Btw: I noticed by the way that Pip 7.1.2 is installing Django in Lib64 as well iso Lib.
Yes, there is with the use of --install-option. Have a look at the docs