Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » Django

How to use Static Data in Django?



Here, we are going to learn through an example, how to use static data in Django web application framework?
Submitted by Pankaj Singh, on November 07, 2018

Static Data means those data items that we cannot want to change, we want to use them as it is like audio, video, images, files etc.

Here, are the steps to create an application that will demonstrate the use of static data in Django:

Step 1: Create a Sandbox, Activate it, Install Django and Create Sample Project

Creating Sandbox

Use static data in django 1

Activating it

Use static data in django 2

Installing Django

Use static data in django 3

Creating Sample Project [myapp]

Use static data in django 4

Project Structure [myapp]

Use static data in django 5

Step 2: Add a new folder (i.e. static) in root location (i.e. myapp folder[outer])

Use static data in django 6

Step 3: Add Static Data (audio, videos etc) inside static folder

Use static data in django 7


Step 4: Add static folder path to settings.py of admin app (i.e. myapp[inner])

Use static data in django 8
Use static data in django 9

Step 5: Add a new folder templates for HTML Templates in project folder (i.e. myapp[outer])

Use static data in django 10

Step 6: Add templates location to setting.py in admin app (i.emyapp[inner])

Use static data in django 11
Use static data in django 12

Step 7: Add a master page (base.html) in templates folder

Use static data in django 13

Different sections of Body Tag of base.html

Use static data in django 14
Use static data in django 15
Use static data in django 16
Use static data in django 17


Step 8: Now Add child pages (i.e. index.html, audio.html, video.html, image.html, pdf.html)

Use static data in django 18

Index.html

Use static data in django 19

Audio.html

Use static data in django 20

Video.html

Use static data in django 21

Image.html

Use static data in django 22

Pdf.html

Use static data in django 23

Step 9: Add a controller file (views.py) to manage views in admin app (i.e. myapp[inner])

Use static data in django 24


Step 10: Add controller actions (functions) to views.py to manage requests.

Use static data in django 25

Step 11: Add new url to urls.py in admin app (i.e. myapp[inner])

Use static data in django 26
Use static data in django 27

Step 12: Run the Server

Use static data in django 28
Use static data in django 29

Step 13: Open Browser and type http://127.0.0.1:8000

Use static data in django 30

Use static data in django 31

Use static data in django 32

Use static data in django 33






Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates



© https://www.includehelp.com (2015-2018), Some rights reserved.