2 ms·
This is silly. First off, an IRC channel does not speak for a whole community of users, and an IRC channel that covers a topic that a subset of a community is
by tvon 17y ago
This is silly.
First off, an IRC channel does not speak for a whole community of users, and an IRC channel that covers a topic that a subset of a community is interested in certainly doesn't cover whole community of users. I mean, Python isn't PHP, it has a lot of uses outside of web development and they don't know or care about the feelings of the #django and they probably don't know what this "magic" thing is either.
Even so, nobody in the world should ever say "Wow" to anything anyone ever does on IRC. It's all happend before, it will all happen again, it's filthy, it's nasty, it's IRC.
Or to paraphrase a great character:
IRC. You will never find a more wretched hive of scum and villainy.
At any rate, so far as I can tell the author doesn't know Django very well, which is fine, I don't know it that well either, but rejecting "simple solution #1" that requires writing:
login_required(some_view)
Instead of
login_required('some_view')
Because you want to specify all your views by module path strings instead of actually importing one... that's just silly. What is wrong with importing a view to pass it to a method? Nothing, as a fan of Python for the past ~8 years, nothing is wrong with that, it's simple, it works, do it. If it offends your sensibilities, well, your sensibilities are silly.
Never mind the "simple solution #2" (in the comments by ez, but someone on IRC should have thought of it):
@login_required
def limited_object_list(*args, **kwargs):
return object_list(*args, **kwargs)
Yes, crazy simple, a tiny, itsy-bitsy wrapper that does exactly what you need it to do and lets you keep your urls.py looking how you want it to. That would have been my route (although once you have to write actual view code you might as well write your own view, after all the generic views are just there to solve common use cases and they are called "generic" views instead of "customizable and flexible" views for a reason.. besides, they are easy to reproduce if you need more complex view logic).
So, instead of the existing, simple and working solutions the author wants to add a login_required argument to every generic view, instead of just using the existing, simple and working solutions?
Yeah, that makes sense.