Thursday, August 27, 2015

Possible bug - defer in a Model Manager

Hello,

I had a use case where I wanted to defer a field by default. I used the get_queryset function in the manger like this to make it always happen.

def get_queryset(self):
        return super().get_queryset().defer('bigfield')

It seems to work, however it introduces some very strange side effects by changing the class name as described here. I would get errors like 

TemplateDoesNotExist: my_app/my_model_deferred_bigfield_detail.html

Clearly class based views are getting confused by the Model class name. Before I report a bug I wanted some general thoughts on the matter. Am I abusing the get_queryset method in my manager? 

I had some issues from other apps too like django-activity-stream. Presumably a common way of generates model names isn't working with defer.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOs54SQt4BMEfQahiaTYb%3DqDFHF685JrO-PzoXqWNyL%2BMGdp_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment