How to Start Django Project & how to Creat First project using Terminal Commands

 How to StepUp New Django Project with python Virtual environment

step 1: Need to create a virtual environment
step-2: create Django Project
Step-3 Setup Virtual environment in pycharm
step-4: setup run/debug configuration in pycharm
step-5: add App to Django Project 
step-6: creating a Superuser to login via Django Admin Dashboard


Step-1:


cit246@cit246-ThinkPad-T430:~/Desktop/venkat$ mkdir assessmentproject
cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject$ virtualenv assenv --python=python3.6
Running virtualenv with interpreter /usr/bin/python3.6
Already using interpreter /usr/bin/python3.6
Using base prefix '/usr'
New python executable in /home/cit246/Desktop/venkat/assessmentproject/assenv/bin/python3.6
Also creating executable in /home/cit246/Desktop/venkat/assessmentproject/assenv/bin/python
Installing setuptools, pip, wheel...
done.
cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject$ source assenv/bin/activate
If you are using Windows then instated of the above line use this below 3 links:
>cd assenv
assenv>cd Scripts
assenv/Scripts>activate

(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject$ pip install django
Collecting django
  Downloading Django-3.0.5-py3-none-any.whl (7.5 MB)
     |████████████████████████████████| 7.5 MB 945 kB/s
Collecting asgiref~=3.2
  Using cached asgiref-3.2.7-py2.py3-none-any.whl (19 kB)
Collecting sqlparse>=0.2.2
  Using cached sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
Collecting pytz
  Using cached pytz-2019.3-py2.py3-none-any.whl (509 kB)
Installing collected packages: asgiref, sqlparse, pytz, django

Step-2:


(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject$ django-admin startproject assessmentproject
(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject$ ls
assenv  assessmentproject

(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject$ cd assessmentproject
(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject/assessmentproject$ ls
assessmentproject  manage.py


(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject/assessmentproject$ django-admin startapp asuser
(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject/assessmentproject$ ls
assessmentproject  asuser  manage.py

(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject/assessmentproject$ cd asuser
(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject/assessmentproject/asuser$ ls

admin.py  apps.py  __init__.py  migrations  models.py  tests.py  views.py

(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject/assessmentproject/asuser$ cd ..
(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject/assessmentproject$ python manage.py makemigrations
No changes detected
(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject/assessmentproject$ python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying sessions.0001_initial... OK
(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject/assessmentproject$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

The system check identified no issues (0 silenced).
April 12, 2020 - 03:27:16
Django version 3.0.5, using settings 'assessmentproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.


Step-3:

Now your Project created in your System then Open that project in your favorite IDE (example Pycharm, Visual Studio...).


If you open this project in Pycharm IDE: then Follow below steps

Open Pycharm -> open  file > Select Open (here you can go to your Above Created Django project and open)

After we need to set up above created virtual env to this project ----- follow me, let go and setup

Open file > Settings >  project > Python interpreter > Left side top Settings Symbol click on it > select ADD > Existing Project > Select your above cretaed Virtualenv Path to as provided on below image.




Step-4:

After we need to add Configuration TO this project:




Click on Ok and Open Terminal In your Pycharm and check before

(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject/assessmentproject.

Step-5:


After then we need to add our APP in project Settings.py
 
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'social_django', # add this
    'asuser' # add this
  ]
Step-6:


then create superuser to access Django Content management Dashboard

Open terminal in Django project

(assenv) cit246@cit246-ThinkPad-T430:~/Desktop/venkat/assessmentproject/assessmentproject$ python manage.py createsuperuser
Username (leave blank to use 'cit246'): admin
Email address:
Password: enter your password
Password (again):
The password is too similar to the username.
This password is too short. It must contain at least 8 characters.
This password is too common.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.












Comments

Popular posts from this blog

ERR: error parsing query: found influx, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line

How To Convert Html File/URL/String Into Image Using Python

How to get Full URL or get absolute url In Django