23.03.2017 Views

wilamowski-b-m-irwin-j-d-industrial-communication-systems-2011

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

63-2 Industrial Communication Systems<br />

FIGURE 63.1<br />

Shell interface of Python.<br />

It adheres to the DRY principle, which means “don’t repeat yourself.” Django also provides optional<br />

administrative “create, read, update, and delete” (CRUD) interface templates, which are generated<br />

dynamically through introspection and configured via admin models.<br />

63.2 Software Installation<br />

Both Python and Django are required for setting up the programming environment. Python can be<br />

freely downloaded from http://www.python.org. Versions 2.4 to 2.6 are recommended (Django is<br />

not properly compatible with Python 3.0). The shell interface of Python after installation is shown in<br />

Figure 63.1.<br />

Django can be downloaded from http://www.djangoproject.com/download/ as a packed file, like<br />

“Django-[version number].tar.gz.” After unpacking the file, in command prompt model, the current<br />

directory should be set as where the Django files were released (by cd [directory]). Then the command<br />

setup.py install can be entered for installation. After installation, enter import django<br />

in the shell interface of Python; if there is no error information, it means Django is successfully installed<br />

and bonded with Python (Figure 63.2).<br />

For database development, at least one database server, PostgreSQL, MySQL, or Orade, is required to<br />

be installed in the server. If Django is used on a production site, Apache with mod_wsgi is required for<br />

server configuration [A08].<br />

63.3 Database-Driven Web Site Design<br />

In order to introduce how to use Django for database-driven Web site design, let us have a simple example.<br />

The purpose is to build an online database with basic “CRUD” operations.<br />

63.3.1 Create a Project<br />

The project can be auto-generated by Django, and the important part<br />

is to set a proper instance, including database configuration, Djangospecific<br />

options and application-specific settings [B08].<br />

The whole process is shown in Figure 63.3. First of all, copy the file<br />

django-admin.py to the place where the project will be built, then<br />

locate into the directory by cd in command prompt model. After that,<br />

FIGURE 63.2 Successful instalÂ<br />

lation of Django.<br />

© <strong>2011</strong> by Taylor and Francis Group, LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!