SlideShare a Scribd company logo
BUILD WEBSITE IN DJANGO

  WITH A SEARCH ENGINE IN THE END
DJANGO?

 a Web development framework
 Written in Python
 Originally used in a News Site
 Now used in many place
FEATURES

It comes with

   ORM
   Administration Site
   Development Tools
   Templates
   Form validation
   Authentication Framework
   Comments Framework
   Feeds
   And many more
ENOUGH TALKING

  LET GET TO WORK
LADIES AND GENTLEMEN

Start your project, by using the command
django-admin startproject projectname

You should see the content in the new folder
__init__.py manage.py settings.py urls.py
CONFIGURE IT A LITTLE

The settings is in settings.py we start with the database
find the similar template in settings.py
** show settings.py
http://gist.github.com/376201
A LITTLE MORE


here find the line in settings.py
find the same similar in settings and change it accordingly
** show template_dirs
http://gist.github.com/376203
PHEW.....

Now we can start working,

after we
python manage.py startapp issues

Now we really can start working
btw you should see the following

__init__.py models.py tests.py views.py
WHILE WE AT IT

Lets get a enable admin page in urls.py
change the part in settings.py
**show settings.py

http://gist.github.com/376207

and urls.py
**show urls.py
http://gist.github.com/376208
WHO WANT TO BE A MODEL?

model.py == database table (almost)
copy into models.py
**shows issues models
http://gist.github.com/376205
SETUP A APP


now save the models.py

add application in settings.py

this is just part of settings.py
**show example
http://gist.github.com/376207

create in issue/admin.py
**show admin.py

http://gist.github.com/376210
SYNC IT!!!!

Now we can create a database,

python manage.py syncdb

python mange.py runserver




**show admin page
FIRST SUBMIT A FORM

One cool aspect of django is you can automate form generation,
free with validation!!!!

create this one in issue/forms.py
** show form.py

http://gist.github.com/376290
NOW TO VIEW THE APPS


lets create django views

add the following
**show add view
**show item view
**show list view
http://gist.github.com/376304
TEMPLATING

Django uses template to present to user, let start with a main
template, and the template for app

** show base.html
http://gist.github.com/376294
** show add.html
http://gist.github.com/376297
** show view.html
http://gist.github.com/376298
** show list.html
http://gist.github.com/376300
URL.PY


now lets create a url to point to the webapp
create this one
** show issue/urls.py
http://gist.github.com/376310

modify from the template
** show urls.py
http://gist.github.com/376311
and demo
EXTRA!!!!

NOW A REVIEW OF HAYSTACK
FINDING NEEDLE IN HAYSTACK

Haystack is a search api for django, it support several backend,
including solr, whoosh,
A LITTLE SETUP(AGAIN)

Let do a little setup

git clone http://github.com/toastdriven/django-haystack.git

**show changes in settings.py
http://gist.github.com/376659

**show search_index
http://gist.github.com/376662
TELL HAYSTACK WHICH NEEDLE

We create a search index

** show search index
http://gist.github.com/376668

** search document place on
<template dir>/search/indexes/issue/issue_text.txt
http://gist.github.com/376672
NOW TELL SOLR


Create solr index, and run index

create a schema.xml for solr
python manage.py build_solr_schema > schema.xml

create search index
python manage.py rebuild_index
NOW CREATE A SEARCH SITE


We just reuse the search view
** show urls.py
add (r'^search/',include("haystack.urls"))

and create a template
** show search/search.html
http://gist.github.com/376685
VOILA!!!

Now we have a basic search.

except haystack can do quite a lot, which is another story
altogether

More Related Content

KEY
LvivPy - Flask in details
PDF
Quick flask an intro to flask
PPTX
PDF
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
PDF
Python Flask app deployed to OPenShift using Wercker CI
PPT
Learn flask in 90mins
PPTX
Python/Flask Presentation
PPTX
Django Girls Tutorial
LvivPy - Flask in details
Quick flask an intro to flask
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask app deployed to OPenShift using Wercker CI
Learn flask in 90mins
Python/Flask Presentation
Django Girls Tutorial

What's hot (20)

PDF
CakePHP and AJAX
PDF
2 introduction-php-mvc-cakephp-m2-installation-slides
PDF
CakePHP: An Introduction
PDF
Scalable web application architecture
PDF
Behaviour Driven Development con Behat & Drupal
PDF
4 introduction-php-mvc-cakephp-m4-controllers-slides
ODP
Django for Beginners
PDF
6 introduction-php-mvc-cakephp-m6-views-slides
PPT
Django, What is it, Why is it cool?
KEY
CakePHP 2.0 - It'll rock your world
PPTX
CakePHP - Admin Acl Controlled
PPTX
Play with Alfresco ADF 2.0.0 Angular
PPT
Installation of Joomla on Windows XP
PDF
Django Introduction & Tutorial
PPTX
Web development with django - Basics Presentation
PPTX
Django app deployment in Azure By Saurabh Agarwal
PDF
Introduction to django
PPT
Top 50 Interview Questions and Answers in CakePHP
PDF
Installing AtoM with Ansible
PDF
What The Flask? and how to use it with some Google APIs
CakePHP and AJAX
2 introduction-php-mvc-cakephp-m2-installation-slides
CakePHP: An Introduction
Scalable web application architecture
Behaviour Driven Development con Behat & Drupal
4 introduction-php-mvc-cakephp-m4-controllers-slides
Django for Beginners
6 introduction-php-mvc-cakephp-m6-views-slides
Django, What is it, Why is it cool?
CakePHP 2.0 - It'll rock your world
CakePHP - Admin Acl Controlled
Play with Alfresco ADF 2.0.0 Angular
Installation of Joomla on Windows XP
Django Introduction & Tutorial
Web development with django - Basics Presentation
Django app deployment in Azure By Saurabh Agarwal
Introduction to django
Top 50 Interview Questions and Answers in CakePHP
Installing AtoM with Ansible
What The Flask? and how to use it with some Google APIs
Ad

Viewers also liked (12)

PDF
Flask patterns
PDF
Writing your first web app using Python and Flask
PDF
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
PPTX
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
PDF
Python and GIS
PPTX
Introduction to Google App Engine with Python
PPTX
Django vs Flask
PDF
Making use of OpenStreetMap data with Python
PPTX
Flask – Python
PDF
Flask Introduction - Python Meetup
ODP
Django와 flask
PPTX
OpenStreetMap in 3D using Python
Flask patterns
Writing your first web app using Python and Flask
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
Python and GIS
Introduction to Google App Engine with Python
Django vs Flask
Making use of OpenStreetMap data with Python
Flask – Python
Flask Introduction - Python Meetup
Django와 flask
OpenStreetMap in 3D using Python
Ad

Similar to Build website in_django (20)

PDF
Basic Steps of Web ApplicationDjango.pdf
PPT
Mini Curso Django Ii Congresso Academico Ces
PPT
DJango
PDF
Easy Step-by-Step Guide to Develop REST APIs with Django REST Framework
PPTX
PDF
Django tutorial
PDF
Mini Curso de Django
PDF
Django - basics
PDF
Build and deploy Python Django project
PDF
Introduction to development with Django web framework
PDF
An Introduction to Django Web Framework
ODP
Introduce Django
PPTX
1-_Introduction_To_Django_Model_and_Database (1).pptx
PPTX
Django crush course
PPTX
Creating Openbravo Workspace Widgets
PDF
How to Webpack your Django!
DOCX
Akash rajguru project report sem v
PDF
Learn Django Tips, Tricks & Techniques for Developers
ODP
Web Development in Django
Basic Steps of Web ApplicationDjango.pdf
Mini Curso Django Ii Congresso Academico Ces
DJango
Easy Step-by-Step Guide to Develop REST APIs with Django REST Framework
Django tutorial
Mini Curso de Django
Django - basics
Build and deploy Python Django project
Introduction to development with Django web framework
An Introduction to Django Web Framework
Introduce Django
1-_Introduction_To_Django_Model_and_Database (1).pptx
Django crush course
Creating Openbravo Workspace Widgets
How to Webpack your Django!
Akash rajguru project report sem v
Learn Django Tips, Tricks & Techniques for Developers
Web Development in Django

More from swee meng ng (9)

PPTX
Civic tech in malaysia and beyond
PDF
High Level View of Civic Tech
PPTX
Python on pi
PDF
Lvl.up
ODP
Data prospecting
PDF
How we use Bottle and Elasticsearch
PPT
Hackerspacekl
PDF
a hands on guide to django
ODP
introduction to linux desktop draft 5
Civic tech in malaysia and beyond
High Level View of Civic Tech
Python on pi
Lvl.up
Data prospecting
How we use Bottle and Elasticsearch
Hackerspacekl
a hands on guide to django
introduction to linux desktop draft 5

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Spectroscopy.pptx food analysis technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
“AI and Expert System Decision Support & Business Intelligence Systems”
Network Security Unit 5.pdf for BCA BBA.
Per capita expenditure prediction using model stacking based on satellite ima...
Understanding_Digital_Forensics_Presentation.pptx
Big Data Technologies - Introduction.pptx
Encapsulation_ Review paper, used for researhc scholars
Spectral efficient network and resource selection model in 5G networks
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Programs and apps: productivity, graphics, security and other tools
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation theory and applications.pdf
Review of recent advances in non-invasive hemoglobin estimation
Diabetes mellitus diagnosis method based random forest with bat algorithm
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectroscopy.pptx food analysis technology

Build website in_django

  • 1. BUILD WEBSITE IN DJANGO WITH A SEARCH ENGINE IN THE END
  • 2. DJANGO? a Web development framework Written in Python Originally used in a News Site Now used in many place
  • 3. FEATURES It comes with ORM Administration Site Development Tools Templates Form validation Authentication Framework Comments Framework Feeds And many more
  • 4. ENOUGH TALKING LET GET TO WORK
  • 5. LADIES AND GENTLEMEN Start your project, by using the command django-admin startproject projectname You should see the content in the new folder __init__.py manage.py settings.py urls.py
  • 6. CONFIGURE IT A LITTLE The settings is in settings.py we start with the database find the similar template in settings.py ** show settings.py http://gist.github.com/376201
  • 7. A LITTLE MORE here find the line in settings.py find the same similar in settings and change it accordingly ** show template_dirs http://gist.github.com/376203
  • 8. PHEW..... Now we can start working, after we python manage.py startapp issues Now we really can start working btw you should see the following __init__.py models.py tests.py views.py
  • 9. WHILE WE AT IT Lets get a enable admin page in urls.py change the part in settings.py **show settings.py http://gist.github.com/376207 and urls.py **show urls.py http://gist.github.com/376208
  • 10. WHO WANT TO BE A MODEL? model.py == database table (almost) copy into models.py **shows issues models http://gist.github.com/376205
  • 11. SETUP A APP now save the models.py add application in settings.py this is just part of settings.py **show example http://gist.github.com/376207 create in issue/admin.py **show admin.py http://gist.github.com/376210
  • 12. SYNC IT!!!! Now we can create a database, python manage.py syncdb python mange.py runserver **show admin page
  • 13. FIRST SUBMIT A FORM One cool aspect of django is you can automate form generation, free with validation!!!! create this one in issue/forms.py ** show form.py http://gist.github.com/376290
  • 14. NOW TO VIEW THE APPS lets create django views add the following **show add view **show item view **show list view http://gist.github.com/376304
  • 15. TEMPLATING Django uses template to present to user, let start with a main template, and the template for app ** show base.html http://gist.github.com/376294 ** show add.html http://gist.github.com/376297 ** show view.html http://gist.github.com/376298 ** show list.html http://gist.github.com/376300
  • 16. URL.PY now lets create a url to point to the webapp create this one ** show issue/urls.py http://gist.github.com/376310 modify from the template ** show urls.py http://gist.github.com/376311 and demo
  • 17. EXTRA!!!! NOW A REVIEW OF HAYSTACK
  • 18. FINDING NEEDLE IN HAYSTACK Haystack is a search api for django, it support several backend, including solr, whoosh,
  • 19. A LITTLE SETUP(AGAIN) Let do a little setup git clone http://github.com/toastdriven/django-haystack.git **show changes in settings.py http://gist.github.com/376659 **show search_index http://gist.github.com/376662
  • 20. TELL HAYSTACK WHICH NEEDLE We create a search index ** show search index http://gist.github.com/376668 ** search document place on <template dir>/search/indexes/issue/issue_text.txt http://gist.github.com/376672
  • 21. NOW TELL SOLR Create solr index, and run index create a schema.xml for solr python manage.py build_solr_schema > schema.xml create search index python manage.py rebuild_index
  • 22. NOW CREATE A SEARCH SITE We just reuse the search view ** show urls.py add (r'^search/',include("haystack.urls")) and create a template ** show search/search.html http://gist.github.com/376685
  • 23. VOILA!!! Now we have a basic search. except haystack can do quite a lot, which is another story altogether