mirror of
https://github.com/jazzband/django-dbtemplates.git
synced 2026-03-16 22:20:28 +00:00
Update docs
This commit is contained in:
parent
70fb31c190
commit
d3221c3acd
4 changed files with 23 additions and 56 deletions
3
CONTRIBUTING.md
Normal file
3
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[](https://jazzband.co/)
|
||||||
|
|
||||||
|
This is a [Jazzband](https://jazzband.co/) project. By contributing you agree to abide by the [Contributor Code of Conduct](https://jazzband.co/docs/conduct) and follow the [guidelines](https://jazzband.co/docs/guidelines).
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
include LICENSE AUTHORS README.rst MANIFEST.in tox.ini .coveragerc
|
include LICENSE AUTHORS README.rst MANIFEST.in tox.ini .coveragerc CONTRIBUTING.md
|
||||||
recursive-include docs *.txt
|
recursive-include docs *.txt
|
||||||
recursive-include dbtemplates/locale *
|
recursive-include dbtemplates/locale *
|
||||||
recursive-include dbtemplates/static/dbtemplates *.css *.js
|
recursive-include dbtemplates/static/dbtemplates *.css *.js
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
v2.0 (unreleased)
|
v2.0 (2016-09-29)
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
* Moved to Jazzband: https://github.com/jazzband/django-dbtemplates
|
.. warning::
|
||||||
|
|
||||||
|
This is a backwards-incompatible release!
|
||||||
|
|
||||||
|
* Moved maintenance to the `Jazzband <https://jazzband.co/>`_
|
||||||
|
|
||||||
* Dropped support for Python 2.6
|
* Dropped support for Python 2.6
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,22 +55,23 @@ Setup
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
Order of ``TEMPLATES.OPTIONS.loaders`` is important. In the former example, templates from database
|
The order of ``TEMPLATES.OPTIONS.loaders`` is important. In the former
|
||||||
will be used as a fallback (ie. when template does not exists in other locations).
|
example, templates from the database will be used as a fallback (ie. when
|
||||||
If you want template from database to be used to override templates in other locations,
|
the template does not exists in other locations). If you want the template
|
||||||
put ``dbtemplates.loader.Loader`` at beginning of ``loaders``.
|
from the database to be used to override templates in other locations,
|
||||||
|
put ``dbtemplates.loader.Loader`` at the beginning of ``loaders``.
|
||||||
|
|
||||||
4. Sync your database ``python manage.py syncdb``
|
4. Sync your database ``python manage.py migrate``
|
||||||
5. Restart your Django server
|
5. Restart your Django server
|
||||||
|
|
||||||
.. _Git repository: http://github.com/jazzband/django-dbtemplates/
|
.. _Git repository: https://github.com/jazzband/django-dbtemplates/
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
Creating database templates is pretty simple: Just open the admin interface
|
Creating database templates is pretty simple: Just open the admin interface
|
||||||
of your Django-based site in your browser and click on "Templates" in the
|
of your Django-based site in your browser and click on "Templates" in the
|
||||||
"Dbtemplates" section.
|
"Database templates" section.
|
||||||
|
|
||||||
There you only need to fill in the ``name`` field with the identifier, Django
|
There you only need to fill in the ``name`` field with the identifier, Django
|
||||||
is supposed to use while searching for templates, e.g.
|
is supposed to use while searching for templates, e.g.
|
||||||
|
|
@ -84,44 +85,3 @@ other template loaders. For example, if you have a template called
|
||||||
contents in the database, you just need to leave the content field empty to
|
contents in the database, you just need to leave the content field empty to
|
||||||
automatically populate it. That's especially useful if you don't want to
|
automatically populate it. That's especially useful if you don't want to
|
||||||
copy and paste its content manually to the textarea.
|
copy and paste its content manually to the textarea.
|
||||||
|
|
||||||
Example
|
|
||||||
=======
|
|
||||||
|
|
||||||
``dbtemplates`` comes with an example Django project that let's you try it
|
|
||||||
out. The example uses Django's own `flatpages app`_ to enable you to create
|
|
||||||
a simple page using ``dbtemplates``. Flat pages are a perfect fit to
|
|
||||||
dbtemplates since they come prepackaged and are simple to use.
|
|
||||||
|
|
||||||
Here is how it works:
|
|
||||||
|
|
||||||
1. Open your command line and change to the ``example`` directory in the
|
|
||||||
directory with the extracted source distribution.
|
|
||||||
2. Run ``python manage.py syncdb`` and follow the instructions.
|
|
||||||
3. Run ``python manage.py runserver`` and open your favorite browser with the
|
|
||||||
address http://127.0.0.1:8000/admin/.
|
|
||||||
4. Next add a new `Template` object in the ``dbtemplates`` section and use
|
|
||||||
``flatpages/default.html`` as the value for the ``name`` field. For the
|
|
||||||
``content`` field use this example::
|
|
||||||
|
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>{{ flatpage.title }}</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{{ flatpage.content }}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
5. Return to the home screen of the admin interface and add a new flat page.
|
|
||||||
Use ``/`` (yep, just a forward slash) and whatever ``title`` and
|
|
||||||
``content`` you prefer. Please make sure you select the default site
|
|
||||||
``example.com`` before you save the flat page.
|
|
||||||
6. Visit http://127.0.0.1:8000/ and see the flat page you just created
|
|
||||||
rendered with the ``flatpages/default.html`` template provided by
|
|
||||||
``dbtemplates``.
|
|
||||||
|
|
||||||
.. _flatpages app: http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue