Concepts And Techniques.docx

  • Uploaded by: Rada Dara
  • 0
  • 0
  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Concepts And Techniques.docx as PDF for free.

More details

  • Words: 723
  • Pages: 3
Content:  Github (folder)  Virtual environment  Django setup Source:  https://www.youtube.com/playlist?list=PLeSa1SxNqdJZg91-jpaOps1OqABjvYu7S  https://djangobook.com/installing-django/  … Style:  XXX : Folder name  XXX : Terminal command  “XXX” : Folder with description in quotes  XXX : In the scrip Windows: pip install virtualenvwrapper-win mkvirtualenv myproject workon myproject Install : Django, Jupyter

Windows: Install virtualenv – pip 1. Open command prompt in a folder to create V.Env – virtualenv <__> 2. Cd <___> /Scripts/ 3. Activate to get into the env 4. Pip install Django 5. Go to app name – python manage.py runserver 6.

Sensitivity: LNT Construction Internal Use

Github (folder):  Create a seperate github folder in home where all the project files and their virtual environments can be stored.  This can be later used to sync with github, the website, to upload all the work  ... Virtual environment:  Used to create internal silos where necessary versions of libraries can be used and maintained isolated from the global versions on a system.  Dependencies can be different and avoids confusion with the global versions  To create virtual environment:  pip install virtualenv  Open github in terminal -> virtualenv -p python3 “name of the project”  Check for the file within ls “name of the project”/lib/  To activate this environment, go to the “name of the project” source bin/activate  Change can be seen on the left side within brackets  Here jupyter notebook can be run as usual  Libraies can be loaded using the normal pip  ... Django setup: Django project is an encapsulation of different applications. Like authentication, search, forum etc.  Once in the “name of the project” django-admin.py startproject “name of the project application” to initiate the project  “name of the project application” will have some python scripts  Open up the “name of the project application” in a text editor  “manage.py” : is used to interface with the command line with the application (after launching the server, in cloud mostly)  “Settings.py”: key file to defines global variables to make decisions like templates, static files, file paths  “url.py” : Defines what urls can be accessed on our website and what code runs when accessed  Local server: Go to “name of the project application” python3 manage.py runserver  Get the url (http://127.0.0.1:8000/) and run it  Output : It worked! Congratulations on your first Django-powered page.  Right now one terminal will keep up the server. So open another one, go to the “name of the project”, activate the environment and make changes in that. The changes made will automatically be reflected in the server without refreshing.  Open the virtual environment in the second terminal, go to the folder consisting “manage.py” python3 manage.py startapp “name of the app”  This new “name of the app” will contain few python scripts  Usually Django has in-built application which can be seen under “INSTALLED_APPS” section of “Settings.py”  This has to be updated once a new application has been created to notify Django of its existence by just adding “ name of the app” to the list.  After updating, database (SQLite) by python3 manage.py migrate  ...  Functionality:  Basic is to open a website homepage (‘/’) using a specific url

Sensitivity: LNT Construction Internal Use

 

 To edit, open “URL.py” and add: url(r”^$”,”classname”.as_view())  r is for regex, ^ is for start point, $ is for the end point <- this opens up 8000/  The text after "," is the view and that does the functionality part using functions and classes and can be edited by “views.py” under migrations  https://docs.djangoproject.com/en/1.11/topics/class-based-views/  from django.views.generic import View class “classname” (View): # this will send html files which will be the homepage def get (self, request): # request has info about ip add, cookies, data too return render(request, "html document") # html is a template so render is used, and t he page has to be created to be returned  In “url.py” # the classes from views.py are to be imported from forum_app.views import “Classname” # even better get all from forum_app.views import * Creation of the HTML file has to done in the “name of the app”/”template”/ Refresh the site to see the difference

Sensitivity: LNT Construction Internal Use

Related Documents

Concepts
October 2019 52
Concepts
November 2019 47
Realities And Concepts
November 2019 30

More Documents from "Alan Weller"

Aylien.txt
October 2019 15
Cs224n-2017-lecture4.pdf
October 2019 21
June 2020 24