{% extends "base.html" %} {% load example_app_tags %} {% block title %} Example index {% endblock title %} {% block header %} Example index {% endblock header %} {% block content %}
Running django-datatable-view {{ datatableview_version }}, django {{ django_version }} datatables.js {{ datatables_version }}
Click on an example type in the sidebar to interact with a live table and read details on how it can be implemented.
Your database tables appear sync'd! Check out the example pages at your leisure.
{% else %}
Make sure you've done a syncdb
for the test project! This view failed to
read from one of the example model tables!
This project's settings use a simple sqlite3 file to keep things tidy for you, so we
recommend using this project in its own environment. Ideally, you could run the
manage.py
script from inside the root of the django-datatable-view project
directory:
$ cd django-datatable-view $ datatableview{{ os_sep }}test{{ os_sep }}test_project{{ os_sep }}manage.py syncdb $ datatableview{{ os_sep }}test{{ os_sep }}test_project{{ os_sep }}manage.py runserver{% endif %}
The demos and example code found in this example project all rely on the automatic
initialization provided by a simple jQuery document.ready
event. A couple of
the pages use additional static resources (Bootstrap theme, x-editable); these pages include
an HTML comment in the source that highlights their use in the live demo.
Aside from the primary value of this set of examples as a reference site, noteworthy topics that branch outside of basic syntax are:
helpers
column callbacks
The main model used in most of the examples is Entry
, because of its diverse
fields. Blog
makes a simple relationship demonstration possible, and
Author
helps shed light on how to handle
many to many relationships.
class Blog(models.Model): name = models.CharField(max_length=100) tagline = models.TextField() class Author(models.Model): name = models.CharField(max_length=50) email = models.EmailField() class Entry(models.Model): blog = models.ForeignKey(Blog) headline = models.CharField(max_length=255) body_text = models.TextField() pub_date = models.DateField() mod_date = models.DateField() authors = models.ManyToManyField(Author) n_comments = models.IntegerField() n_pingbacks = models.IntegerField() rating = models.IntegerField(){% endblock content %}