I kinda came across an article about creating Proxy Models, that is
what I tried and it really seemed to do what I needed, pretty cool.
Here is what I coded ...(sorry for the formatting, if it looks goofy)
Edit “models.py” file: (create the new Proxy Model)
class RequestTicketCompleted(RequestTicket):
class Meta:
proxy=True
verbose_name = ‘Request Tickets Completed’
verbose_name_plural = ‘Request Tickets Completed’
def days_old(self):
return self.completion_date – self.issued_date
days_old.short_discription = ‘Days Old’
Edit “admin.py” file:
class RequestTicketCompletedAdmin(RequestTicketAdmin):
def queryset(self, request):
qs = super(RequestTicketAdmin, self).queryset(request)
if request.user.is_superuser:
return qs.filter(completion_date__isnull=False)
def save_model(self, request, obj, form, change):
obj.user = request.user
obj.save()
admin.site.register(RequestTicketCompleted,
RequestTicketCompletedAdmin)
now that shows up on my main admin page under the my application
section, the superuser can see it, click on it and it will only
display the completed tickets, with the amount of days it took to
complete, then they can also click on the plain Request Tickets and
see any open tickets by all users/techs and how long they have been
open for, sweet.
I had also read where it could be setup as a default manager on the
proxy to provide custom queryset instead of in the admin class, so i
will try and look into do that.
The only thing is that it will not show up on the list of Permissions
to be able to assign to users who would like to see closed tickets as
well, but that is not a really big deal.
Thanks for all your help
> > - Show quoted text -- Hide quoted text -