DRY in Django views

A couple of days ago, a topic came up on the django-users mailinglist where someone asked how to avoid code repetition in views if the views mostly do the same (for instance do some processing on the request parameters or check a certain session variable etc.).

There is one question you have to ask yourself first, though: Does this common processing require request-specific data like session-data or request parameters?

Hi. You solution is pretty and fine. But I'd like to make some additions - e.g. insert more base classes and make some small changes in basic logic. Could I fork you solution, create my and put it into opensource? If so, which license you require?

Thank you

Hotsyk on Sept. 28, 2008 at 22:32 +0200

I'm currently in the process of moving this package out of django-zsutils and into its own standalone library since I plan to keep improving this.

The code currently is and will stay under the BSD license so you're free to fork it if you want. But if you have something great to share, github keeps the attribution in order so a patch would be very welcome if you want to have something in there ;-) I hope I will have the whole move finished by tomorrow (and perhaps with some pypi registration by the day after tomorrow) :-)

zerok on Sept. 29, 2008 at 22:29 +0200

The Class thing is already taking place with the Django built-in generic views: http://code.djangoproject.com/ticket/6735

That should avoid having to wrap generic views, and allow further more customization ;)

Note: If you want to check the code make sure you check the one in GIT (link in one of the comments) as the one attached is not yet up-to-date ;)

Marc Fargas on Oct. 1, 2008 at 23:12 +0200

I never said that my solution was completely new, but IMO it is different enough from the approach taken in the "new" generic views implementation.

And contrary to what everyone out there seems to think: I am aware of that implementation ;-)

zerok on Oct. 1, 2008 at 23:18 +0200

Comment on this

You can use Markdown here.

Please answer the question in this field. It should help keeping spambots out ;-)