Re: Should ugettext_lazy return instanceof unicode? Or are reusable apps responsible for calling force_text a lot?

2016-10-22 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
> 1. Should the result of ugettext_lazy somehow inherit from unicode? If indeed > the "result of a ugettext_lazy() call can be used wherever you would use a > unicode string" I don't think making isinstance(lazy_str, unicode) return True would really fix things, as it will probably break

Re: Add support for LiveServerTestCase.setUpTestData

2016-04-29 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
Hi, LiveServerTestCase doesn't inherit from django.test.TestCase intentionally, that's why it doesn't call setUpTestData(). If you need that functionality just inherit from both: class MyTestCase(LiveServerTestCase, TestCase): # ... Moritz Am 29.04.2016 um 21:46 schrieb Crono5788: > I am

Re: Proposal on Custom Indexes - Google Summer of Code

2016-03-12 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
What about calling the attribute something like "constraints" similar to how it's done in SQLAlchemy [1]? For now the attribute can just contain a list of Index() instances but that would also lay grounds for supporting check constraints and other related table level options. Moritz [1] http:/

Re: Adding "bits of entropy" argument to crypto.get_random_string

2016-03-05 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
Can't you just define your own function called "get_random_string_entropy" that calculates the length and then calls get_random_string? What would be the benefit of doing that in Django directly? Am 05.03.2016 um 00:15 schrieb Nick Timkovich: > Rather than guess at the appropriate string length to

Re: Proposal: Refactor Form class

2016-03-05 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
Hello, Am 05.03.2016 um 02:57 schrieb Curtis Maloney: > Well, Widgets and Fields are involved in determining how to extract data from > the submitted dict... but they don't actually "parse" the http form data -- > Django does that much further down the stack in the HttpRequest object. > > > As m

Proposal: Refactor Form class

2016-03-03 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
Hello, I want to propose a refactor of the Form class to make it easier to customize and subclass. Motivation: Currently the Form class (combined with Field, Widget and BoundField) has many responsibilities and combines much functionality into a single class. It currently does: - data validati

Re: Improve adding data to forms programmatically

2015-09-17 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
Am 17.09.2015 06:24, schrieb Yo-Yo Ma: > To clarify, are you referring to a state where there are validation errors > and the form is redisplayed, whereupon your change the value back to the > original value? No, there don't have to be validation errors. I want to redisplay the form to the user

Re: Improve adding data to forms programmatically

2015-09-16 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
If the user changes a field "username" for example and then saves his changes form.has_changed() will detect correctly that the username has changed. If the user then goes back and changes the username to the old value, form.has_changed() will return True because the new input differs from the firs

Improve adding data to forms programmatically

2015-09-15 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
Hello, currently you can add data to forms either by passing it into the "initial" or the "data" argument of Form. However sometimes I have the need to add data to a Form that isn't request.POST and doesn't come from an http request. My use case is the following: I have a form where a user can e

Re: Allow custom "BoundFields" on forms and make BoundField public API

2015-08-21 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
I replied to your comment on pr 5123 on github [1] but it seems to be buried under "Show outdated diff" so here it is again: I agree that as_text() and as_textarea() are not needed so I will remove them from the docs. There is a use case for as_widget() though. In one of my projects I have a temp

Re: Allow custom "BoundFields" on forms and make BoundField public API

2015-08-13 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
Yes I know that you can access the Field instance but it wouldn't be possible to do {{ field.field.city }} since a Field is not supposed to have any data stored with it. That exactly is the BoundField's job and the reason there is a distinction between bound and unbound field. An implementation of

Re: Allow custom "BoundFields" on forms and make BoundField public API

2015-08-13 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
My point isn't making accessing choices more easily, that's just the first thing I thought of for a simple example. Whether the current method for accessing the choices is good or not was not intended to be in the scope of my proposal. I want it to be possible to write more complex fields that hav

Re: Allow custom "BoundFields" on forms and make BoundField public API

2015-08-10 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
I split the commit in my branch to make the actual changes more visible and moved the example out of the branch into the gist. I will look into the ticket and work out some documentation. Am 08.08.2015 um 13:42 schrieb Tim Graham: > Here is a ticket for making BoundField a public API: > https://c

Allow custom "BoundFields" on forms and make BoundField public API

2015-08-08 Thread 'Moritz Sichert' via Django developers (Contributions to Django itself)
Hello, I'd like to propose a new feature for forms. Currently if you need a form field with some extra features you can just subclass from django.forms.Field and add all the features you need. However as soon as you're in a template and want to access the field you will get a BoundField instead