■ CONTENTS
xiv
A Quick Word about Django Signals...................................................................................... 293
Front-End Engineering ............................................................................................................... 293
Move CSS and JavaScript Into Separate Files....................................................................... 295
Reduce the Number of External Components........................................................................ 295
Optimize External Components ............................................................................................. 296
Summary.................................................................................................................................... 297
■Chapter 14: Django Testing .................................................................................299
Why We Test .............................................................................................................................. 299
How to Test Code .................................................................................................................. 300
Creation of the Test Database ............................................................................................... 301
Python & Django Test Methods ............................................................................................. 301
Anatomy of a Test Class........................................................................................................ 303
Testing the Product Catalog....................................................................................................... 304
Writing Functional Tests........................................................................................................ 304
Managing Test State with Fixtures........................................................................................ 307
Category Testing.................................................................................................................... 309
Testing the ActiveProductManager ....................................................................................... 312
Product Catalog Model Tests ..................................................................................................... 313
Testing Forms & Shopping Cart ................................................................................................. 315
Testing the Checkout Form........................................................................................................ 318
Security Testing ......................................................................................................................... 319
Summary.................................................................................................................................... 321
■Chapter 15: Deployment ......................................................................................323
The Django Philosophy............................................................................................................... 324
Finding a Hosting Plan ............................................................................................................... 325
Phase One: Apache and mod_wsgi............................................................................................ 326
Installing the Apache Web Server ......................................................................................... 326
Creating the mod_wsgi File and Apache Virtual Host ........................................................... 328
Phase Two: Nginx for Static Media ............................................................................................ 331
Installing and Configuring NginX........................................................................................... 331
Updating the Apache Virtual Host.......................................................................................... 333
Phase Three: Configuring SSL.................................................................................................... 334
Transferring Data with Django................................................................................................... 338