Ticket #3987: doc.diff

File doc.diff, 1.3 KB (added by ikse hefem, 16 years ago)

New patch (sorry, fisrt try) , forget/delete the preceding one if possible

  • django/docs/admin.txt

     
    486486    Performs a full-text match. This is like the default search method but uses
    487487    an index. Currently this is only available for MySQL.
    488488
     489``ModelAdmin`` methods 
     490------------------------
     491
     492ModelAdmin subclasses can redefine specific methods in order to customize even more the admin site :
     493
     494``dynamic_XXX_choices``
     495~~~~~~~~~~~~~~~~~~~~~~~~~
     496
     497the ``dynamic_XXX_choices`` method, where XXX is a ForeignKey or ManyToMany field of your model, allows the admin site to filter the available choices for that field.
     498
     499An example usage of it is ::
     500
     501    # Model
     502       
     503    class Book(models.Model):
     504        title = models.CharField(maxlength=100)
     505        author = models.ForeignKey(Author)
     506   
     507    # Admin
     508   
     509    class BookAdmin(ModelAdmin):
     510        def dynamic_author_choices(self, request, model):
     511            # Default implementation:
     512            # return book.author_set.all()
     513            if request.user.is_superuser:
     514                return model.objects.all()
     515            return model.objects.filter(use_in_admin=True) 
     516
     517
    489518``ModelAdmin`` media definitions
    490519--------------------------------
    491520
Back to Top