Django

Code

Ticket #9303: 9303_hasattr.diff

File 9303_hasattr.diff, 0.8 kB (added by thejaswi_puthraya, 1 year ago)

First method that uses hasattr

  • a/django/contrib/comments/templatetags/comments.py

    old new  
    8080            content_type = ctype, 
    8181            object_pk    = smart_unicode(object_pk), 
    8282            site__pk     = settings.SITE_ID, 
    83             is_public    = True, 
    8483        ) 
    85         if getattr(settings, 'COMMENTS_HIDE_REMOVED', True): 
     84        if hasattr(self.comment_model,'is_public'): 
     85            qs.filter(is_public=True) 
     86        if getattr(settings, 'COMMENTS_HIDE_REMOVED', True) and hasattr(self.comment_model, 'is_removed'): 
    8687            qs = qs.filter(is_removed=False) 
    8788 
    8889        return qs