Python Web Programming Interview Questions

Complete the following Django model to illustrate how a manufacturer can make many different types of cars.

Give manufacturer a name, founding date and a country.

Give car a name, cost, engine capacity and color. Assume that the manufacturer makes cars in only {red, green, blue and pink}.

class Manufacturer(models.Model):
    # A car manufacturer

class Car(models.Model):
    # A type of car

A user types the following URL into their browser: http://www.foo.com/bar.php

Explain in detail how this would cause a page to appear in their browser, with images, interactive elements (Ajax), styled paragraphs of text etc.

What is a signal in Django? Where might you use one? What's the difference between send() and send_robust()? When might you use one over the other?

What does the following code do? What's another way of doing the same thing?

from django.core.signals import request_finished
from django.dispatch import receiver

@receiver(request_finished)
def my_callback(sender, **kwargs):
    print "Request finished!"

Complete the following Django form to include:

  • A subject with a maximum length of 100 characters
  • An optional, boolean, cc_myself field
  • A sender field that will be validated as a correctly formatted email address
from django import forms

class ContactForm(forms.Form):
    message = forms.CharField()