Free Sample
+ Collection

Django JavaScript Integration: AJAX and jQuery

Starting
Jonathan Hayward

Develop AJAX applications using Django and jQuery
$26.99
$44.99
RRP $26.99
RRP $44.99
eBook
Print + eBook

Want this title & more?

$16.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781849510349
Paperback324 pages

About This Book

  • Learn how Django + jQuery = AJAX
  • Integrate your AJAX application with Django on the server side and jQuery on the client side
  • Learn how to handle AJAX requests with jQuery
  • Compare the pros and cons of client-side search with JavaScript and initializing a search on the server side via AJAX
  • Handle login and authentication via Django-based AJAX

Who This Book Is For

This book is for people looking to integrate AJAX / JavaScript functionality into their web applications. It is for Django users who are looking to easily integrate AJAX features into their applications. Conversely, it will also be a priceless companion for users familiar with Django and jQuery who are and looking to integrate them in their AJAX applications. A working knowledge of Django and basic familiarity with AJAX and jQuery are assumed.

Table of Contents

Chapter 1: jQuery and Ajax Integration in Django
Ajax and the XMLHttpRequest object
A look at Django
Setting JavaScript and other static content in place
Summary
Chapter 2: jQuery—the Most Common JavaScript Framework
jQuery and basic Ajax
jQuery Ajax facilities
jQuery as a virtual higher-level language
A closure-based example to measure clock skew
Case study: A more in-depth application
Summary
Chapter 3: Validating Form Input on the Server Side
The standard lecture: low-level validation
The Django way of validation
Validation as demanding that assumptions be met
Making assumptions and demanding that users conform
Better validation may be less validation
Summary
Chapter 4: Server-side Database Search with Ajax
Searching on the client side and server side
Handling databases through Django models
Models for an intranet employee photo directory
Searching our database
A tour of Django persistence facilities
Summary
Chapter 5: Signing Up and Logging into a Website Using Ajax
admin.py: administrative functions called once
functions.py: project-specific functions, including our @ajax_login_required decorator
views.py: functions that render web pages
style.css: basic styling for usability
search.html: a template for client-side Ajax
The Django admin interface
Summary
Chapter 6: jQuery In-place Editing Using Ajax
Including a plugin
A template handling the client-side requirements
Summary
Chapter 7: Using jQuery UI Autocomplete in Django Templates
Adding autocomplete: first attempt
A real-world workaround
Refining our solution further
Summary
Chapter 8: Django ModelForm: a CSS Makeover
"Hello, world!" in ModelForm
Expanding and customizing the example
Customizing ModelForm pages' appearance
Going under ModelForm's hood
An excellent "stupid" question: where's the e-mail slot?
Summary
Chapter 9: Database and Search Handling
Moving forward to an AHAH solution
Summary
Chapter 10: Tinkering Around: Bugfixes, Friendlier Password Input, and a Directory That Tells Local Time
Minor tweaks and bugfixes
Handling password input in a slightly different way
A directory that includes local timekeeping
Summary
Chapter 11: Usability for Hackers
Usability begins with anthropology… and Django hackers have a good start on anthropology
Anthropological usability techniques
Focus groups: cargo cult research for usability
Anthropological observation: the bedrock of usability
Applying this foundation to usability
It's just like (hard) debugging
Lessons from other areas
Understanding the user
Python and usability
What to do in the concrete
Further reading
Summary

What You Will Learn

  • Learn how and why, for certain kinds of web development, Django is more 'Pythonic' than Python
  • Understand whet the XMLHttpRequest Object is and how to implement it in various browsers
  • Embed JavaScript in Django templates
  • Learn account creation and login creation using AJAX
  • Build forms using Django models
  • Embed jQuery auto-complete plugins in your Django templates
  • Validate form input on the server side using AJAX
  • Integrate jQuery sliders into your Django template
  • Minify JavaScript files and also learn the pros and cons of doing so

In Detail

You want to create an AJAX application. Why would you use Django? Why would you use jQuery? Why would you use both together? Enter Django JavaScript Integration: AJAX and jQuery – your comprehensive answer to all these questions and the only extensive, practical, and hands-on guide to developing any AJAX application with Django and jQuery.

Gone are the days when you used to lament over the lack of official documentation on AJAX with Django. This book will teach you exactly why Django is called "The web framework for perfectionists with deadlines", how jQuery – the "write less do more" JavaScript library – is practically a virtual higher-level language, and why they both deserve to be integrated with AJAX.

This hands-on-guide shows you how to put Django and jQuery together in the process of creating an AJAX application. In this book, they are brought together in a real-world scenario, with attention to usability, to build and develop an AJAX application.

The first two chapters provide a short and necessary introduction to the world of Django, jQuery, and AJAX; and the remaining chapters are based on a case study that will make you realize the immense potential and benefits of integrating Django and jQuery with your AJAX application.

By the time you are done with this book, you'll be developing your AJAX applications with Django and jQuery in less time than you can say "integrate".

You will cover the basics of AJAX; use jQuery, the commonest JavaScript library, on the client side, and learn form validation with an eye to usability, build things with Django on the server-side, handle login and authentication via Django-based AJAX, and then dip into the rich jQuery plugin ecosystem to build in-place editing into your pages. You will add auto-complete functionality courtesy of jQuery UI, easily build forms with Django ModelForm, and then look at a client-side search implementation that can look things up without network access after initial download. You will learn to Implement a simple, expandable undo system, and offer more full-blooded account management, tinker, fix some bugs, offer a more usable way to handle password input, add local time support for people who are not in your time zone, look at usability, and finally take a look at debugging.

After working through this book, you will have both an AJAX application and a deep understanding that you can use to customize, extend, and further develop it in your organization.

This book has been written and tested for Django v 1.2.3 and jQuery v 1.4.4.

Authors

Read More

Recommended for You

Web Development with Django Cookbook
$ 29.99
Django Essentials
$ 13.99
Instant Django 1.5 Application Development Starter
$ 12.99