See also: Heapify

Pages: 1

Serving Static Content With Django

A question that is frequently asked by new Django programmers is: "How can I serve static content (css, images, javascript) with the Django development server?". This article is my attempt to answer that question by demonstrating the best practices way to do so.

Why Doesn't Django Serve Static Content Automatically?

Well, Django (and python in general) is built around the idea that it is better to be explicit than implicit. This concept means that you may need to write more code in order to do something, but that by doing it that way, you preserve code clarity and reduce complexity.

...

Read more

There are 3 comments on this post.

Auto Generate Forms With Django's ModelForm

In this short article, we'll analyze a better way (in some cases) to create forms for your Django models.

If you've ever worked with Django forms, then you know that there is a lot of repetitive code involved in the process of writing a form to create your model. Take, for instance, the following model, which represents a physical server (somewhere):

from django.db import models
 
class Server(models.Model):
    """
    This class represents a physical server.
    """
    hostname = models.CharField('Server Name',
        help_text = 'Hostname of the server.',
        max_length = 50
    )
    ip = models.IPAddressField('Server IP Address',
        help_text = 'Public IP of the server.',
        unique = True
    )
    disk_space = models.IntegerField('Disk Space on Server',
        help_text = 'Total disk space in MB.'
    )
    ram = models.IntegerField('RAM on Server',
        help_text = 'Total RAM in MB.'
    )
    cpu = models.IntegerField('Processing Power',
        help_text = 'Total Processing Power in MHz.'
    )
 
    def __unicode__(self):
        """
        Make the model human readable.
        """
        return self.hostname

...

Read more

There are 4 comments on this post.

User Authentication With Django

Introduction

This article will teach you how to authenticate users with Django in a simple, quick, and secure manner. You'll also learn how to require authentication on certain pages of your website, and how to gracefully handle login and logout functionality.

The target audience is people who have had minimal experience with Django, and are aware of how Django works in a basic manner.

...

Read more

There are 13 comments on this post.

Pages: 1

RSS
Powered by Debian, Guinness, and excessive quantities of caffeine and sugar.