On Thu, Sep 15, 2016 at 12:56:16AM -0700, Sjoerd Job Postmus wrote: > I'm not sure if I agree. > > On the one hand I would like to say: > > "I agree. For instance, if the type is `hex`, it would be really weird if > it were to be cast to an int. For `uuid`, would you expect a `UUID` > instance, or just a string?" > > but alternatively, ... > > "Wouldn't it be really cool if you could specify like > `<model(myapp.Blog):post>`, and it does a `get_object_or_404(myapp.Blog, > post)`, and passing the actual **instance** to the view?"
As cool as this idea sounds, I really don't think the URL dispatcher is a correct component to make database queries. FWIW, I've seen similar magic implemented in view decorators, and the thing I remember the most from this experience was that it made it a lot harder to follow what was happening where. Moreover, I can imagine this turning into a complicated mess of a syntax to allow query customizations using a weird DSL really quickly. After all, if we allow PK lookups, it's not that unreasonable to also want to be able to lookup by other keys, and it all goes downhill from here. Cheers, Michal -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to firstname.lastname@example.org. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/20160915083755.GU6601%40koniiiik.org. For more options, visit https://groups.google.com/d/optout.
Description: Digital signature