2 ms·
> mptt First time using mptt might not be straightforward. But I think it's worth because the problem is "difficult". Similarly django-polymorphic. Those are t
by amirouche 13y ago
> mptt
First time using mptt might not be straightforward. But I think it's worth because the problem is "difficult". Similarly django-polymorphic. Those are the two things in Django I would think hard before re-writring.
> one-liner ~ queryset
I don't find the particular comment right now.
> To get all the "upvotes" of an user it's better to start from the user.
I don't know the correct queryset, the one you provide seems good. Don't compute in Python what you can do in the db. In the particular code I'm referring to, several queries were done against the db instead of one.
> 1000-line is ugly
yeah, kind of. But at least you don't use abbreviations. Or 2 spaces for indentation. Seems like valid pep8.
I don't say that there are no mistakes in the code, just skimmed over it.
The file is big because some of the functions are not views.
- get_submission_age: should be template tag cf. https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#simple-tags https://docs.djangoproject.com/en/dev/howto/custom-template-...
- get_submission_set: I wouldn't use such a function. For sure you are iterating two times over the list of submissions, one time in the view, one time in the template so it's a "2n" so O(n) complexity. It's ok but only one iteration over the list is required. But the django template language (DTL) makes it "hard" to do it... DTL was built around the idea that the template writer is stupid and probably also that nobody would read the code the template writer wrote before going into production.