Navigation Menu

Skip to content

Commit

Permalink
Updating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed Mar 14, 2012
1 parent fdb9715 commit b7361cf
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions docs/admin.rst
Expand Up @@ -124,6 +124,52 @@ the :py:meth:`~ModelAdmin.get_query` method:
Now a user will only be able to see and edit their own messages.

Nicer display for Foreign Key fields
------------------------------------

If you have a model that foreign keys to another, by default the related model
instances are displayed in a <select> input.

This can be problematic if you have a large list of models to search (causes slow
load time, hurts the database). To mitigate this pain, foreign key lookups can
be done using a paginated widget that supports type-ahead searching.

Setting this up is very easy:

.. code-block:: python
class MessageAdmin(ModelAdmin):
columns = ('user', 'content', 'pub_date',)
foreign_key_lookups = {'user': 'username'}
When flask-peewee sees the ``foreign_key_lookups`` it will use the special modal
window to select instances. This applies to both filters and model forms:

Filters
^^^^^^^

1. Select a user by clicking the "Select..." button

.. image:: fp-admin-filter.jpg

2. A modal window with a paginated list and typeahead search appers:

.. image:: fp-admin-modal.jpg

3. The button now indicates the selected user, clicking again will reload the dialog:

.. image:: fp-admin-btn.jpg


Admin ModelForms
^^^^^^^^^^^^^^^^

The interface is the same as with the filters, except the foreign key field is
replaced by a simple button:

.. image:: fp-admin-btn-form.jpg


Creating admin panels
---------------------

Expand Down
Binary file added docs/fp-admin-btn-form.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/fp-admin-btn.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/fp-admin-filter.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/fp-admin-modal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b7361cf

Please sign in to comment.