Opened 10 years ago

Closed 8 years ago

Last modified 8 years ago

#2553 closed enhancement (wontfix)

Generic views should support serialization

Reported by: James Bennett <ubernostrum@…> Owned by: Jacob
Component: Generic views Version: master
Severity: normal Keywords:
Cc: telenieko@…, john@…, jgelens@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Pretty much what the title says. Given that we have serializers for QuerySets, and that we're shipping simplejson, it'd be nice if generic views could respond in formats other than HTML; perhaps an additional format keyword argument (defaulting to 'html') could be used to control this.

Change History (10)

comment:1 Changed 10 years ago by anonymous

Hi James.
don't generic views take a template, and a mimetype already?

are you after a quick way to dump a queryset out?
what about foreign keys, and 'protected' fields like passwords and API-keys.. would you want some kind of protection there?

comment:2 Changed 10 years ago by James Bennett <ubernostrum@…>

They do, but one of the great things about the serialization framework is that you don't have to do things like setting up a template to output JSON anymore -- Django can generate the output in the correct format for you automatically (also, it's probably safer to let Django do it this way -- libraries like simplejson reduce the risk of things blowing up due to a typo in a template).

comment:3 Changed 10 years ago by zenx

I agree with James, generic views returning xml or json would be great!

comment:4 Changed 10 years ago by Marc Fargas

Cc: telenieko@… added

+1! addding me to CC

comment:5 Changed 10 years ago by mir@…

Triage Stage: UnreviewedDesign decision needed

Hi James--this looks as if you already have an idea how such a generic view would be used in code. Can you add it to the ticket, if you have?

comment:6 Changed 10 years ago by Jacob

Resolution: wontfix
Status: newclosed

I'd actually prefer *not* to tack this onto generic views, and instead create a REST-friendly Resource implementation similar to djangocollection. Accordingly I'm marking this wontfix, but anyone who wants to give a shot at RESTful-ness has my fondest blessing.

comment:7 Changed 10 years ago by john@…

Cc: john@… added

I've written a RESTful API (similar urls to the 'oldforms' Admin), it needs a bit of a tidy up, and a few more tweaks but I'm more than happy for it to be incorporated in to Django in any way.

comment:8 Changed 8 years ago by Jeffrey Gelens

Cc: jgelens@… added
Resolution: wontfix
Status: closedreopened

I'm about to implement a serialization option in generic views for my own application. Since there was no effort on the REST-friendly implementation for django-trunk, I would like upload the patch when it's done. Anyway against this?

comment:9 Changed 8 years ago by Michael Radziej

milestone: post-1.0
Resolution: wontfix
Status: reopenedclosed

No worries if you just want to upload the patch, that's fine. But the ticket has been resolved as "wontfix", i.e. the patch won't be integrated into django.

You should not reopen such a ticket. If you want to discuss Jacob's decision, the usual process is to post an email to django-developers.

You probably better try to roll your patch into a normal django application, if possible.

comment:10 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top