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

Build website in_django

  • 1.
    BUILD WEBSITE INDJANGO WITH A SEARCH ENGINE IN THE END
  • 2.
    DJANGO? a Webdevelopment 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 Startyour 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 ALITTLE 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 herefind 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 canstart 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 ATIT 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 TOBE A MODEL? model.py == database table (almost) copy into models.py **shows issues models http://gist.github.com/376205
  • 11.
    SETUP A APP nowsave 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 wecan create a database, python manage.py syncdb python mange.py runserver **show admin page
  • 13.
    FIRST SUBMIT AFORM 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 VIEWTHE 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 templateto 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 createa 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.
  • 18.
    FINDING NEEDLE INHAYSTACK Haystack is a search api for django, it support several backend, including solr, whoosh,
  • 19.
    A LITTLE SETUP(AGAIN) Letdo 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 WHICHNEEDLE 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 Createsolr 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 ASEARCH 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 havea basic search. except haystack can do quite a lot, which is another story altogether