Thursday, December 24, 2009

2004 Honda Pilot Front License Plate Bracket

Merry Christmas!

Saturday, December 19, 2009

Pctv 150e 55e Problem With Searching Channels

Django - delete logical

To tell the truth may be obvious how to do ... But since I've got bumped my head I want to share with my readers this 'solution fried':) (staying in theme with the book of Mark ).

Building a Model with override on 'delete':

 
class Customer (models.Model): email =
models.EmailField ()
nickname = models.CharField (max_length = 50) = models.BooleanField
deleted (default = False)

def delete (self): = True
self.deleted
self.save ()


Then we create an admin.py in ModelAdmin on our 'Customer':

 
class CustomerAdmin (admin . ModelAdmin):
search_fields = ['nickname']
exclude = ('deleted',) def

queryset (self, request): return super
(CustomerAdmin, self). queryset (request). filter (deleted = False)


Done.
Now in the view in admin will be present only the 'Customer' does not logically deleted, whether they be shown the list, whether it is carried out a search.

I refer you for further documentation to Django and two other interesting links:
Django Trip: Ready, Set, Go
Is there a way to filter in the django admin to queryset?

I put less time to write this post to find the solution! : D

Sani