rails-girls-summer-of-code / projects

24 stars 7 forks source link

[Django] Improve Formsets to allow customized Form construction #32

Closed freakboy3742 closed 8 years ago

freakboy3742 commented 9 years ago

Name and Contact of the Project Mentor: Russell Keith-Magee (@freakboy3742, russell@keith-magee.com) Name of the Project: Improve Formsets to allow customized Form construction URL: http://djangoproject.com About the Project:

One of the big problems in web programming is making a request object available everywhere that it might be needed. Some frameworks tackle this problem by using a threadlocal. A threadlocal is essentially a global variable that allows you to access stateful information, such as the currently active request.

Django takes a more structured approach, and encourages you to use function arguments and class attributes to pass around stateful information. This requires more discipline on the developer, but ultimately leads to more robust, less error-prone code that is easier to test.

The counterargument to Django's approach is that passing the request around everywhere that it might be needed is difficult. Formsets are one example given in support of this - Django's formsets are a classic example where you might want to pass a request down to an internal form - but this is surprisingly difficult to do with Django's FormSet infrastructure.

The problem isn't just about requests, either - there's a general problem in Django's Formset, ModelFormset and InlineModelFormset objects that makes it difficult to pass in arguments to the Forms that are on them, or otherwise control the save process. This could be a request, the user that is making a particular change, or some other "ownership" related information.

While it is possible to work around this problem, it should be a well documented, easy to use capability.

Suitable for beginners? Yes

What are issues/features students may work on? The purpose of this project will be to modify the Formset, ModelFormset, and InlineFormset APIs, plus the matching formset_factory methods, to allow for context to be passed to forms on a formset. This will involve designing an API for passing context information to child forms, writing the code to implement this API, writing tests and documentation for the new feature.

Your output for this project will be a pull request (or possibly several pull requests) against Django's core repository. If accepted, these pull requests will become part of the next version of Django.

cypher commented 9 years ago

Hi Russel,

Thank you for your project proposal. Could you clarify a bit what the concrete goal of this project is? As I understand your description, the students would open a Pull Request/Issue for Django if they successfully complete this project, so their work could eventually end up in Django itself. Is this correct?

best, Markus

freakboy3742 commented 9 years ago

@cypher Hi Markus - you're correct; the output of the project is a PR against Django's core repository; code would end up being a fairly significant feature in the next version of Django. I've just added a comment to this effect in the project description.

cypher commented 9 years ago

Alright, thank you for the clarification. We are happy to let you know that we have accepted this project :) Welcome to RGSoC!

carpodaster commented 9 years ago

:confetti_ball: