Writing your first Django app, part 6

This tutorial begins where Tutorial 5 left off. We’ve built a tested Web-poll application, and we’ll now add a stylesheet and an image. Aside from the HTML generated by the server, web applications generally need to serve additional files — such as images, JavaScript, or CSS — necessary to render the complete web page. In Django, we refer to these files as “static files”. For small projects, this isn’t a big deal, because you can just keep the static files somewhere your web server can find it.

Writing your first Django app, part 7

This tutorial begins where Tutorial 6 left off. We’re continuing the Web-poll application and will focus on customizing Django’s automatically-generated admin site that we first explored in Tutorial 2. Customize the admin form By registering the Question model with admin.site.register(Question), Django was able to construct a default form representation. Often, you’ll want to customize how the admin form looks and works. You’ll do this by telling Django the options you want when you register th

Writing your first patch for Django

Introduction Interested in giving back to the community a little? Maybe you’ve found a bug in Django that you’d like to see fixed, or maybe there’s a small feature you want added. Contributing back to Django itself is the best way to see your own concerns addressed. This may seem daunting at first, but it’s really pretty simple. We’ll walk you through the entire process, so you can learn by example. Who’s this tutorial for? See also If you are looking for a reference on how to submit patches,

“How-to” guides

Here you’ll find short answers to “How do I....?” types of questions. These how-to guides don’t cover topics in depth – you’ll find that material in the Using Django and the API Reference. However, these guides will help you quickly accomplish common tasks. Authentication using REMOTE_USER Writing custom django-admin commands Writing custom model fields Custom Lookups Custom template tags and filters Writing a custom storage system Deploying Django Upgrading Django to a newer version Error rep

#define directive

The preprocessor supports text macro replacement and function-like text macro replacement. Syntax #define identifier replacement-list(optional) (1) #define identifier( parameters ) replacement-list (2) #define identifier( parameters, ... ) replacement-list (3) (since C99) #define identifier( ... ) replacement-list (4) (since C99) #undef identifier (5) Explanation #define directives The #define directives define the identifier as a macro, that is they in

#error directive

Shows the given error message and renders the program ill-formed. Syntax #error error_message Explanation After encountering the #error directive, an implementation displays the diagnostic message error_message and renders the program ill-formed (the compilation stops). error_message can consist of several words not necessarily in quotes. References C11 standard (ISO/IEC 9899:2011): 6.10.5 Error directive (p: 174) C99 standard (ISO/IEC 9899:1999): 6.10.5 Error directive (p

#include directive

Includes another source file into the current source file at the line immediately after the directive. Syntax #include <filename> (1) #include "filename" (2) Explanation Includes source file, identified by filename, into the current source file at the line immediately after the directive. The first version of the directive searches only standard include directories. The standard C++ library, as well as standard C library, is implicitly included in standard include dire

#line directive

Changes the current line number and file name in the preprocessor. Syntax #line lineno (1) #line lineno "filename" (2) Explanation 1) Changes the current preprocessor line number to lineno. Occurrences of the macro __LINE__ beyond this point will expand to lineno plus the number of actual source code lines encountered since. 2) Also changes the current preprocessor file name to filename. Occurrences of the macro __FILE__ beyond this point will produce filename. Any preproc

#pragma directive

Implementation defined behavior is controlled by #pragma directive. Syntax #pragma pragma_params (1) _Pragma ( string-literal ) (2) (since C99) 1) Behaves in an implementation-defined manner (unless pragma_params is one of the standard pragmas shown below. 2) Removes the encoding prefix (if any), the outer quotes, and leading/trailing whitespace from string-literal, replaces each \" with " and each \\ with \, then tokenizes the result (as in translation stage 3), and then use

abort

Defined in header <stdlib.h> void abort(); Causes abnormal program termination unless SIGABRT is being caught by a signal handler passed to signal and the handler does not return. Functions passed to atexit() are not called. Whether open resources such as files are closed is implementation defined. Implementation defined status is returned to the host environment that indicates unsuccessful execution. Parameters (none). Return value (none). Example #include <s