Inline Formsets Again

2009-10-28 Thread John Debs
I realize the voting for 1.2 features has passed and that the collective
attention will be focused on that list, but I'm hoping to get a core
developer interested enough to look at potential implementations for this
and suggest improvements. The thread I'm resurrecting is this one:
http://groups.google.com/group/django-developers/browse_thread/thread/f9aae709a7fda689
.

Without further ado:

On Aug 20, 9:01 am, Russell Keith-Magee 
wrote:
> On Sun, Aug 16, 2009 at 5:45 AM, mrts wrote:
>
> > At HTML level, a form is a set of fields that gets submitted when
> > a the form submit button is pressed.
>
> > However, this is not the case with model forms and inline formsets
> > (e.g. an admin page with inlines) -- inline formsets are
> > disparate from the model form.
>
> > This creates at least two problems:
> > 1) it's impossible to display inline formsets in between ordinary
> > form fields (although they may logically belong to a particular
> > fieldset and not to the end of the form),
>
> This is only true if you consider {{ form }} to be the only way to
> render a form. Remember - you can modify your template to render
> individual fields on a form. If you're looking for sophisticated
> layout options, you should be looking at customizing your template,
> not trying to turn Django's Form.as_ul into the One True Form
> Rendering Tool (tm).

I don't buy this. IMO, the real problem with keeping formsets and
forms separate is that developers really should handle forms with
inlines as a single unit, but can't. Consider the example of a
Business model that may have multiple PhoneNumbers, EmailAddresses,
etc:

class Business(models.Model):
   owner = models.ForeignKey(User)
   name = models.CharField(max_length=50)
   address = models.CharField(max_length=100)

class EmailAddress(models.Model):
   email = models.EmailField()
   details = models.CharField(max_length=50)
   business = models.ForeignKey(Business)

class PhoneNumber(models.Model):
   number = PhoneNumberField()
   details = models.CharField(max_length=50)
   business = models.ForeignKey(Business)

In order to present this, I have to create, initialize, pass, and
display a BusinessForm - which Django makes very easy on its own. I
have to do the same with the formsets for EmailAddress and PhoneNumber
- not as easy. As if it weren't bad enough to handle them separately,
they also need to handled /differently/. My nice, encapsulated, atomic
form has been shattered into three parts and my URLConf, views, and
templates all have to deal with that now.

While {{ form }} should obviously not be the only way to render a
form, it should _always_ be an option. It doesn't stop anyone from
customizing templates for more sophisticated layouts. Getting the
example I gave up and running requires entirely customized views (or
separate pages) and far too deep an understanding of Django to be
possible for beginners. And it's annoying for everyone else.

> > 2) it's impossible to create nested (recursive) inlines.
>
> This is true, but not necessarily a bad thing. I'm willing to be
> convinced otherwise, but I'm yet to see a case where nested inlines
> would yield a positive user experience. Forms inside forms inside
> forms is a recipe for  UI disaster.

In my experience this is a /very/ common use case - which is even used
in Django admin itself - that's being overlooked. If some developers
want to create awful UIs who are we to stop them? Other devs trying to
quickly prototype code or who just don't need prettier layouts hit
major roadblocks here. Django should easily handle the common cases,
not try to enforce good web design.

I've written a creaky hack to work around the issue in my own projects
but after seeing this thread I'm going to take a shot at implementing
FormSetField (or something like it) myself. If anyone has any code -
or more arguments for or against that haven't been covered - I'd love
to hear them before diving in.

John Debs

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: Ticket #5025 - truncate filter, why hasn't it been accepted?

2009-12-29 Thread John Debs


On Dec 29, 9:08 pm, James Bennett  wrote:

> It is built in, though, it's just called "slice". The only thing
> people seem to offer to differentiate this proposal from the existing
> filter is that the proposed "truncate" would add an ellipsis at the
> end, and honestly I'm not really convinced that's a significant enough
> use case to warrant adding another built-in filter.

For what it's worth, it's something I've wanted (and wondered about)
for several of my projects, and I've heard the same from others. It
seems to me that more often than not, developers want an ellipsis when
truncating strings like that.

I thought about suggesting adding an option to the existing slice
filter but I really think that's its own use case and that there
should be a new truncatestring filter that matches the syntax of
truncatewords.

It's especially unclear to new developers that they should accomplish
this with slice (and an if statement checking the length of the
string) - and it's not very DRY. The convenience of having slice is
undermined by the fact that many aren't clever enough to use it this
way - it certainly didn't occur to me.

So, +1 to this idea.

John

--

You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.




Re: Ticket #5025 - truncate filter, why hasn't it been accepted?

2009-12-30 Thread John Debs
On Dec 30, 7:06 am, Russell Keith-Magee 
wrote:

> Secondly, IMHO raw truncation based on characters is bad practice for
> human readable text. A sentence is composed of words, not characters.
> Truncating a sentence mid-word isn't a typographical practice that I
> particularly want to encourage.

I think the question that needs to be asked now is: What would it take
to convince the core members that this belongs in core?

There are obviously a *lot* of django developers that want this, best
practice or not, and web development is often about making trade-offs
that work best for your scenario. Two of Django's core philosophies
(correct me if I'm wrong...) are making common developer tasks easy,
and keeping things DRY, and the current state of string truncation in
Django is neither of those things.

I've seen a few +1's but no -1's, despite some resistance. Can we get
the opinions of a few more core developers so that this has a chance
of slipping in before the Jan. 5 feature deadline?

--

You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.




Re: Default project layout / directory structure

2011-03-13 Thread John Debs
I like the idea too, since I've run into a lot of situations where
some more convention here would make a decision much easier to make.
However, it isn't clear what exactly should be better defined and I
think the first step to a serious proposal would be to figure that
out.

The only example that comes to mind is Pinax's apps/ directory for a
project's internal apps – it's a good convention that many people
already follow. My other gripe has already been taken care of, with
the integration of django-staticfiles.

What other things did you have in mind?

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.