You are on page 1of 16

CSCI 2133

RAPID PROGRAMMING TECHNIQUES FOR INNOVATION


Lab 09:

Prep Lab: Local Storage, Session Storage and Intro to Django


Instructor: Gang Liu
Faculty of Computer Science

Dalhousie University
Objectives

■ Local Storage
■ Session Storage
■ Introduction to Django
Local Storage
■ The read-only localStorage property allows you to access a Storage object for the
Document's origin; the stored data is saved across browser sessions.
■ localStorage is similar to sessionStorage, except that while data stored in localStorage
has no expiration time, data stored in sessionStorage gets cleared when the page session
ends — that is, when the page is closed.
■ The keys and the values are always strings (note that, as with objects, integer keys will
be automatically converted to strings).
Syntax
Example
Session Storage

■ The sessionStorage property allows you to access a session Storage object for the
current origin. sessionStorage is similar to localStorage; the only difference is while
data stored in localStorage has no expiration time, data stored in sessionStorage gets
cleared when the page session ends.
■ A page session lasts for as long as the browser is open and survives over page reloads
and restores.
Example
Install virtualenv

■ Use this command in your terminal,


>pip install virtualenv
>virtualenv my_virtual_env
>cd my_virtual_env
For activation in windows:
>.\Scripts\activate
For linux:
>source bin/activate
Why virtualenv?

virtualenv and virtualenvwrapper provide a dedicated


environment for each Django project you create. While
not mandatory, this is considered a best practice and will
save you time in the future when you’re ready to deploy
your project.
Install django

>cd ..
Even after traversing outside the virtualenv, you will notice that your virtualenv is still
activated.
Now, create a Django project here. It is perfectly okay to create a Django project inside the
virtualenv directory but when you push your project to Git, you need to add .gitignore to
ignore the virtualenv libraries.
>pip install Django
Create Django project

>django-admin startproject mysite


Create superuser
Run server

>cd mysite
>python manage.py runserver
Extras!
Let’s play with the Django’s cool admin
console, shall we?
Go to:

“http://127.0.0.1:8080/admin” in your local machine.


References

■ https://docs.djangoproject.com/en/2.1/intro/tutorial01/

You might also like