Django ile teknik servis formu (Python 2)
A Turkish step-by-step guide, with code, for building a technical service form site with Django 1.9 and Python 2.
This repository contains a Turkish guide that explains, from start to finish, how to build a technical service form site with Django 1.9 and Python 2, together with all of the code written in that guide. I prepared it in January 2016 for djangoturkiye.com and updated it almost every day for a week, adding new sections each time. In its final form the guide passed 100 pages. It became my most-starred repository on GitHub.
Purpose
At that time there were very few up-to-date resources that explained Django in Turkish, from installation all the way to a working site. Most resources were either in English or written for older Django versions. I wanted to write a guide in plain, conversational language that even someone who had never touched Django could follow. Instead of abstract examples, I started from a real need: a site where a technical service shop can keep track of its customers, the devices they bring in and the repair process of those devices.
Sample application
The application consists of a single Django app called servisformu. Customers, technicians, accessories and work statuses are kept in separate tables. Each service form is linked to a customer and to the technician who received it, and up to five products can be added under the form. For every product, the type, brand, model, serial number, warranty end date, complaint, accessories that came with the product, status and work done are recorded. The customer code and form number are generated as random eight-digit numbers when a record is created.
Most of the work is done through the Django admin panel. From the customer list, a phone number can be called with a single click. There is an action that bulk-updates the selected records based on a condition. The customer and technician drop-downs on the form screen show only active records. Next to every form there is a link that opens a printable service slip.
The home page of the site has a field where customers type their form number to check the status of their device. The query is sent with AJAX, and the latest status of the products and the work done are shown without reloading the page. Service forms can also be exported as XML.
Topics covered in the guide
- Installation, creating a project, language and time settings, and the
collectstaticandcreatesuperusercommands - Defining requirements and designing tables before starting a project
- Default values and not-blank and not-null constraints on model fields
ForeignKeyandManyToManyFieldrelations, and a comparison ofTabularInlineandStackedInlinelist_display_links, adding actions, bulk updates and limiting the number of records in the admin panel- Copying and changing the admin theme, static files and the
mediafolder - Serving HTML, text and XML files with
TemplateView,HttpResponse, CSRF and querying with AJAX - Using CDATA in XML output, showing related records in a template with
_set.all, andforloop.counter - Splitting templates into blocks, tags such as
extends,cycleandcomment, and filter examples
Repository contents
Next to the application code, the Video_PDF folder contains the PDF versions of the guide as they were updated day by day, the ODT source files and an EPUB version. Because the project uses SQLite as its database, it can be run right after downloading without any extra setup. The guide can be freely shared and edited as long as the name and site address are credited. The Python 3 version of the same guide is in the django-teknikservis-py3 repository.
- Category
- Teaching & community
- Year
- 2016
Technologies
- Python
- Django
- Education
Links
- GitHub https://github.com/muslu/django-teknikservis