In PyCharm Django version - django

How can I use Django 1.11 as default version in pycharm ?
Letting you know that I'm using macOS and default Django version is 2.0.3 !

Pycharm has nothing to do with Django version. You can just install django version you need.
Use: pip3 install django==1.11
Note:
You can check your globally installed django version by typing:
python3
import django
django.VERSION
You will probably get 2.0.3 as global django version. So now you have to type:
pip3 install django==1.11
That will install django with version 1.11 as global. From now, whenever you will create new project via:
django-admin startproject your_project
Django version of that new project will be 1.11 by default
And some advice:
Next time just use virtualenv or virtualenvwrapper, by using it you will set your libraries locally for each project

You can use python virtualenv to create a custom environment for your project with django version 1.11.
https://docs.python.org/3/library/venv.html
https://www.jetbrains.com/help/pycharm-edu/creating-virtual-environment.html
In your project folder :
python3 -m venv env
source env/bin/activate
pip install django=1.11
This will create a folder named env (source command activates this environment). You may need to install all your other dependencies.
In PyCharm, under project settings Project Interpreter, select this environment.

Related

How to install django in miniconda?

i want to develop django rest API in windows.
Due to some reason i have to use miniconda in my system.
My project location is c:/users/noman/dev/cardionic/ .
i create virtualenv 'env' using miniconda which is created in c:/user/noman/miniconda3/envs/env instead of base folder. I activate my env using 'activate env' and install django. I create new django project using 'django-admin startproject cardio' .
when i run 'python manage.py runserver' it generates "ModuleNotFoundError: No module named 'sqlparse' "
i have done my best but could not resolve this issue. Thanks in advance
First, Setup an environment
conda create — name django2 python>3.7
Switch to / Activate the environment
conda activate django2
Install Django — the default version was 2.2.1
conda install -v django
Encountered ModuleNotFoundError: No module named ‘sqlparse’ when running python manage.py runserver. This will resolved by conda install sqlparse.

I installed Django version over 2.x but the command django-admin startproject(lowercase) make project with 1.x version

python3 -m venv venv
source venv/bin/actvaite # activate virtual env
pip install --upgrade pip
pip3 install Django # Django 2.1.7 installed
django-admin startproject temp # 1.x version
Django-admin startproject temp # 2.x version
django-admin vs Django-admin
django-admin start with lowercase make project 1.x version
Django-admin start with uppercase make project 2.x version
offical docs - start with lowercase
docs
summary
1) whats wrong in my environment?
2) how can i make project with django-admin(lowercase)
It seems like the pip command is pointing to Python 2.x, and pip3 is pointing to Python 3.x. To see if this is this case:
deactivate # in case you're in a virtual environment
pip --verison
pip3 --verison
This will show you which version of Python each one points to. Since Django 2.x is only compatible with Python 3, pip will automatically installed Django 1.11.x if you're installing with pip under Python 2.x.
The best way around this is to ensure you're using a virtual environment. To start a new Django project:
python3 -m venv my_project_venv
. my_project_venv/bin/activate
pip --version # Make sure it is pointing to Python 3
pip install django
django-admin startproject my_project
The next time you come back to work on your project, you can re-activate the virtual environment with everything you've pip installed inside it:
. my_project_venv/bin/activate
Good luck!
Did you install Django in your environment?
pip install Django
A quick workaround is running the following in your environment:
python3 venv/bin/django-admin startproject temp

Can't install Django 1.11 version with python 2.7 virtual environment

I am trying to setup Django-2.0 & Django-1.11 version in my system with virtual environment.I done the Django-2.0 version with python-3 and am able to run the server.
But I am facing an issue when am able to install django-1.11 with python-2.7 it's installing Django-2.0 instead of Django-1.11
>>> import django
>>> print(django.get_version())
it's giving 1.11
django-admin startproject projectname
When I run this command it's installing Django-2.0 and my django_admin --version is 2.0
You could try using python -m django instead of django-admin. This will ensure that it is using the django install for the active virtual environment.
python -m django startproject myproject

How to create a django project in ubuntu

I'm following a tutorial on Django and I'm suppose to create a folder in Ubuntu in terminal
$ django-admin startproject mysite
This above line shows
"Cannot find installed version of python-django or python3-django."
After installing all the required stuffs.
The recommended way of starting a django project in Ubuntu is using a virtualenv so first install it.
Then run
virtualenv -p python3 env
This will create an env named folder. Active the virtualenv by running
source ./env/bin/activate
Then install django with pip. now django will be installed in activated virtualenv
pip install django
and then create your project
django-admin startproject mysite

How to install Django on different version of PYTHON?

I have two python versions 2.6 and 3.0. I want to install django1.3 in python3.0's site-package directory and my default python setting is on 2.6. I also added path /usr/local/bin/python3.0 and /usr/local/bin/python3.0 into .bashrc file.
Please help me.
Django is not compatible with Python 3. You must install it in the 2.X branch.
However, what you want to achive will be easier done using virtualenv:
easy_install virtualenv
virtualenv project --python=python2.6
source project/bin/activate
pip install django
Django doesn't yet work with python3.0. So it is better you install it on the python2.6 dist-packages folder.
That said, if you had python2.7 and wanted to install django on python 2.7, while the better approach is to use virtualenv, a simple solution is to:
python2.7 setup.py install
or
easy_install2.7 django
or
/path/to/python2.7/dist-packages/pip/pip install django
easy_install virtualenv
pip install django
Sudo pip install django
Seemed to work for me!
by using pip install django --> it installs the latest version of django.
https://technicalforum.wordpress.com/2016/12/17/introduction-to-django/