0% found this document useful (0 votes)
7 views

Module-1-L4. Starting a Project

This document provides a guide for starting a Django project, including creating a project directory and using the command 'django-admin.exe startproject mysite'. It outlines the files generated by the startproject command and explains the purpose of each file, as well as how to run the built-in development server with 'python manage.py runserver'. Additionally, it describes how to create a new app within the project using 'python manage.py startapp myapp'.

Uploaded by

hod.cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Module-1-L4. Starting a Project

This document provides a guide for starting a Django project, including creating a project directory and using the command 'django-admin.exe startproject mysite'. It outlines the files generated by the startproject command and explains the purpose of each file, as well as how to run the built-in development server with 'python manage.py runserver'. Additionally, it describes how to create a new app within the project using 'python manage.py startapp myapp'.

Uploaded by

hod.cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Module 1

Starting a Project
Starting a Project
 A project is a collection of settings for an instance of Django, including database

configuration, Django-specific options, and application-specific settings.

 If this is your first time using Django, you’ll have to take care of some initial setup.

 Create a new directory to start working in, perhaps something like

/home/username/djcode/, and change into that directory.

 Run the command django-admin.exe startproject mysite to create a mysite directory

in your current directory.


Starting a Project
 Let’s look at what startproject created:
 mysite/
 __init__.py
 manage.py
 settings.py
 urls.py
 These files are as follows:
 • __init__.py: A file required for Python; treat the directory as a package (i.e., a group
of modules)
 • manage.py: A command-line utility that lets you interact with this Django project in
various ways
 • settings.py: Settings/configuration for this Django project
 • urls.py: The URL declarations for this Django project; a “table of contents” of your
Django-powered site
The Development Server
 Django includes a built-in, lightweight Web server you can use while developing your

site.

 We’ve included this server so you can develop your site rapidly, without having to deal

with configuring your production Web server (e.g., Apache) until you’re ready for

production.

 This development server watches your code for changes and automatically reloads,

helping you make many rapid changes to your project without needing to restart

anything.
The Development Server
 Change into the mysite directory, if you haven’t done so already, and run the command

 python manage.py runserver.

 You’ll see something like this:

Validating models...

0 errors found.

Django version 0.96, using settings 'mysite.settings'

Development server is running at http://127.0.0.1:8000/

Quit the server with CONTROL-C.


Creating app
 python manage.py startapp myapp

 myapp/
 __init__.py
 admin.py
 apps.py
 migrations/
 __init__.py
 models.py
 tests.py
 views.py
Screenshots
Screenshots
Screenshots
Screenshots
Screenshots
12
13
14

You might also like