Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Introduction to Django Framework: Project Structure, Apps, and Admin Interface, Lecture notes of Project Management

Now that we have installed Django, let's start using it. In Django, every web app you want to create is called a project; and a project is a sum of applications. An application is a set of code files relying on the MVT pattern. As example let's say we want to build a website, the website is our project and, the forum, news, contact engine are applications. This structure makes it easier to move an application between projects since every application is independent.We assume you are in your project folder. In our main “myproject” folder, the same folder then manage.py − $ python manage.py startapp myapp You just created myapp application and like project, Django create a “myapp” folder with the application structure − myapp/ __init__.py admin.py models.py tests.py views.py __init__.py − Just to make sure python handles this folder as a package. admin.py − This file helps you make the app modifiable in the admin interface. models.py − This is where all the application

Typology: Lecture notes

2022/2023

Uploaded on 08/01/2023

jahnavi-m
jahnavi-m 🇮🇳

1 document

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
21IE2047K: PROJECT BASED LEARNING-2
1.Course Description
This course provides an introduction to Python Full Stack Development,GIT- Git Integration with
PYCHARM IDE, PYTEST-Introduction, Installation, Integrating PYTEST to PYCHARM IDE, Run tests
in parallel, fixtures, parameterized tests. Python connectivity with Databases MYSQL, MongoDB CRUD
operations, FLASK FRAMEWORK,Request Objects Sending Form Data to Template, Advanced
Features of Flask, Pagination Database connectivity Sqlite3, MySQL Page Restrictions using decorators
Errors Flash Message ,Working with Mails, Django framework.
2.Aim :Understand the Concept of Django Project,Apps and their Structure
3. Instructional Objectives
This Session is designed to: understand the design technique to solve given real world problems.
1.Remembering the Basic Python Concepts
2.Understand the Concept of python full stack development
3.Apply the Knowledge to Create the Application using Django
4.Analyze the Design Techniques to Solve the Design Techniques to Solve the real world problems
using the Frameworks.
4. Learning Outcomes
1.Describe types of Python Full Stack Development
2.Summarize basic concepts of Python basic concepts and OOPs Concepts and Frameworks
5.Module Description
CO1:Analyze the design technique to solve given real world problems
6.Session Introduction
Understand to Create a Project,Apps and their Structure.
7.Session Description
Explanation to Create a Project, Creation of Apps and their Structure, Working with ADMIN Console
Django - Creating a Project
pf3
pf4
pf5
pf8

Partial preview of the text

Download Introduction to Django Framework: Project Structure, Apps, and Admin Interface and more Lecture notes Project Management in PDF only on Docsity!

21IE2047K: PROJECT BASED LEARNING-

1.Course Description

This course provides an introduction to Python Full Stack Development,GIT- Git Integration with PYCHARM IDE, PYTEST-Introduction, Installation, Integrating PYTEST to PYCHARM IDE, Run tests in parallel, fixtures, parameterized tests. Python connectivity with Databases MYSQL, MongoDB CRUD operations, FLASK FRAMEWORK,Request Objects Sending Form Data to Template, Advanced Features of Flask, Pagination Database connectivity Sqlite3, MySQL Page Restrictions using decorators Errors Flash Message ,Working with Mails, Django framework.

2.Aim : Understand the Concept of Django Project,Apps and their Structure

3. Instructional Objectives

This Session is designed to: understand the design technique to solve given real world problems.

1.Remembering the Basic Python Concepts 2.Understand the Concept of python full stack development 3.Apply the Knowledge to Create the Application using Django 4.Analyze the Design Techniques to Solve the Design Techniques to Solve the real world problems using the Frameworks.

4. Learning Outcomes

1.Describe types of Python Full Stack Development

2.Summarize basic concepts of Python basic concepts and OOPs Concepts and Frameworks

5.Module Description

 CO1: Analyze the design technique to solve given real world problems

6.Session Introduction

Understand to Create a Project,Apps and their Structure.

7.Session Description

Explanation to Create a Project, Creation of Apps and their Structure, Working with ADMIN Console Django - Creating a Project

Now that we have installed Django, let's start using it. In Django, every web app you want to create is called a project; and a project is a sum of applications. An application is a set of code files relying on the MVT pattern. As example let's say we want to build a website, the website is our project and, the forum, news, contact engine are applications. This structure makes it easier to move an application between projects since every application is independent. Create a Project Whether you are on Windows or Linux, just get a terminal or a cmd prompt and navigate to the place you want your project to be created, then use this code − $ django-admin startproject myproject This will create a "myproject" folder with the following structure − myproject/ manage.py myproject/ init.py settings.py urls.py wsgi.py The Project Structure The “myproject” folder is just your project container, it actually contains two elements − manage.py − This file is kind of your project local django-admin for interacting with your project via command line (start the development server, sync db...). To get a full list of command accessible via manage.py you can use the code − $ python manage.py help The “myproject” subfolder − This folder is the actual python package of your project. It contains four files − init.py − Just for python, treat this folder as package. settings.py − As the name indicates, your project settings. urls.py − All links of your project and the function to call. A kind of ToC of your project.

Django - Apps Life Cycle A project is a sum of many applications. Every application has an objective and can be reused into another project, like the contact form on a website can be an application, and can be reused for others. See it as a module of your project. Create an Application We assume you are in your project folder. In our main “myproject” folder, the same folder then manage.py − $ python manage.py startapp myapp You just created myapp application and like project, Django create a “myapp” folder with the application structure − myapp/ init.py admin.py models.py tests.py views.py init.py − Just to make sure python handles this folder as a package. admin.py − This file helps you make the app modifiable in the admin interface. models.py − This is where all the application models are stored. tests.py − This is where your unit tests are. views.py − This is where your application views are. Get the Project to Know About Your Application

At this stage we have our "myapp" application, now we need to register it with our Django project "myproject". To do so, update INSTALLED_APPS tuple in the settings.py file of your project (add your app name) − INSTALLED_APPS =( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myapp',) Django - Admin Interface Django provides a ready-to-use user interface for administrative activities. We all know how an admin interface is important for a web project. Django automatically generates admin UI based on your project models. Starting the Admin Interface The Admin interface depends on the django.countrib module. To have it working you need to make sure some modules are imported in the INSTALLED_APPS and MIDDLEWARE_CLASSES tuples of the myproject/settings.py file. For INSTALLED_APPS make sure you have − INSTALLED_APPS =( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myapp',) For MIDDLEWARE_CLASSES − MIDDLEWARE_CLASSES =( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',) Before launching your server, to access your Admin Interface, you need to initiate the database −

That interface will let you administrate Django groups and users, and all registered models in your app. The interface gives you the ability to do at least the "CRUD" (Create, Read, Update, Delete) operations on your models. 8.Activities/ Case studies/related to the session—NA 9.Examples&contemporary extracts of articles/ practices to convey the idea of the session---NA 10.Table Numbering---NA 11Figures with captions—NA 12.SAQ's-Self Assessment Questions:

  1. How to create Django Project?
  2. How to create an application? 13.Summary Overview of the PFSD Concept 14.Terminal Questions--NA 12.Case Studies (Co Wise)--NA 13.Answer Key: NA 14.Glossary:NA

15.References of books, sites, links: Reference Books: Python Cookbook, Third Edition, by David Beazley and Brian K. Jones Django for Beginners: Build Websites with Python and Django Sites and Web links: https://www.linkedin.com/learning/paths/become-a-python-developer https://www.linkedin.com/learning/paths/advance-your-skills-in- python