48
I assume you’re using a virtualenv which is located in the same directory as other project files. Python should know exactly that path. So, it’s possibly that Pycharm is using the wrong Interpreter.
Go to Settings -> Project: -> Project Interpreter -> switch to the right path
In the interpreter packages, there should be Django package installed. If not, do it here/in terminal.
- [Django]-How can I get all the request headers in Django?
- [Django]-Separating form input and model validation in Django?
- [Django]-Django render_to_string missing information
18
Above answers are answered partially.
Problem Description: I’ve multiple versions of python installed and Django is installed in one of Python version. There are two issues
-
Issue 1: Pycharm has wrong python interpreter. For this the
Project Interpreter
has to be changed to Python version where Django is installed. Solution: Follow all steps. -
Issue 2: Django isn’t listed as package. For this we need make available the installed python packages in the Pycharm environment. Solution: Follow all steps except step 3.
Solution:
Peform following steps.
- In preference/settings go to
Project
>Project Interpreter
- On right hand side click on
settings icon
>Add Local
- Select correct Python version from
Base Interpreter
- Mark the checkbox against
Inherit global site-packages
andMake available to all projects
- Click
ok
Once this is done in Project Intepreter
you will be able to see Django
in the Package list.
- [Django]-Turn off automatic pagination of Django Rest Framework ModelViewSet
- [Django]-Http Delete request to django returns a 301(Moved permenantly)
- [Django]-Django – convert a list back to a queryset
6
I got this problem and it stopped my unit tests from running.
I found that PyCharm, during an upgrade, had set my Python Interpreter
to one which was in a virtual environment, which I do not use any more for this project. So I set it to my global Python environment in C:\Python
and everything works like a charm.
I hope this will help someone.
- [Django]-Django download a file
- [Django]-How to access a dictionary element in a Django template?
- [Django]-What's the point of Django's collectstatic?
6
If you create the project use python2.7, and in python2.7 path you installed the django, the project works normal. Then you switch the Project Interpreter to the python3.5, but this path did not install the django, then you will get this issue.
- [Django]-Django "You have unapplied migrations". Which ones?
- [Django]-How to get a particular attribute from queryset in Django in view?
- [Django]-Command not found: django-admin.py
5
if you have installed Django successfully before, in a different location from project location:
in pycharm go to the setting
>Project
>project interpreter
.
right side of the Project Interpreter, click on setting icon and choose add local
.
then in New Environment check these two checkbox:
- inherit global site-packages
- make available to all projects
then press Ok
and Apply
button and wait installing the interpreter to your project location.
- [Django]-Django authentication and Ajax – URLs that require login
- [Django]-"{% extends %}" and "{% include %}" in Django Templates
- [Django]-How to make an Inner Join in django?
- [Django]-Django return file over HttpResponse – file is not served correctly
- [Django]-How to drop all tables from the database with manage.py CLI in Django?
- [Django]-How to save a model without sending a signal?
4
You can make pyCharm recognize it by setting it to use your virtualenv setup that I assume you had it already for the project
STEP 1: open preferences PyCharm > Preferences
STEP 2: Search for interpreter
and on the right window, select your virtual environment to be used in Project Interpreter
STEP 3 (ADDITIONAL): adding your environment to the list if it didn’t show up
-
select show all interpreter, and then on the pop up window, click + icon on the bottom left
-
select radio button
Existing Environment
and select your virtual env, and then check “Make available for all project” if you use the env for other project, and click ok
STEP 4: On the preferences window, click apply or straight click the ok button. wait couple second and django variable should be available in your project
- [Django]-Django MEDIA_URL and MEDIA_ROOT
- [Django]-Setting default value for Foreign Key attribute in Django
- [Django]-How can I upgrade specific packages using pip and a requirements file?
3
- [Django]-Django query filter with variable column
- [Django]-Django check for any exists for a query
- [Django]-Automatically create an admin user when running Django's ./manage.py syncdb
1
I had this problem too. In fact, I faced with this problem because django
package had not been installed in Pycharm. Therefore, I went to this path and clicked on plus sign;then, I searched django
and installed it. It worked well.
file
>setting
>project
>project interpreter
- [Django]-Negating a boolean in Django template
- [Django]-Django static annotation
- [Django]-When I run test cases I get this error: psycopg2.OperationalError: cursor "_django_curs_140351416325888_23" does not exist
0
I used virtualenv in my project and the following steps is works for me.
Settings -> Project:XXX -> Project Interpreter –> click the right
side icon next to project interpreter -> more -> select the virtualenv
interpreter
hope it can help someone
- [Django]-How to perform filtering with a Django JSONField?
- [Django]-How to use pdb.set_trace() in a Django unittest?
- [Django]-How to manually assign imagefield in Django
-1
I fix this issue by changing “Project Structure”.
Try to unmark parent folder as “Sources”
- [Django]-Django Rest Framework Conditional Field on Serializer
- [Django]-Django Rest Framework and JSONField
- [Django]-Django DetailView – how to use 'request' in get_context_data