Re: [Django] #14018: Introduce class_plural %-substitution placeholder for related_name of ForeignKey/ManyToManyField

2013-04-08 Thread Django
#14018: Introduce class_plural %-substitution placeholder for related_name of
ForeignKey/ManyToManyField
-+-
 Reporter:  puxlit   |Owner:  nobody
 Type:  New feature  |   Status:  closed
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:  wontfix
 Severity:  Normal   | Triage Stage:  Design
 Keywords:  related_name,|  decision needed
  ManyToManyField, ForeignKey,   |  Needs documentation:  0
  abstract base class|  Patch needs improvement:  1
Has patch:  1|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-
Changes (by aaugustin):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 I'm going to close this ticket, because it proposes to hardcode one
 specific case, rather than provide an API to resolve the general problem.

 There are several other [query:?status=!closed&description=~related_name
 tickets about related name] with more general proposals.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #14018: Introduce class_plural %-substitution placeholder for related_name of ForeignKey/ManyToManyField

2010-11-20 Thread Django
#14018: Introduce class_plural %-substitution placeholder for related_name of
ForeignKey/ManyToManyField
---+
  Reporter:  puxlit| Owner:  nobody 
   
Status:  new   | Milestone:  2.0
   
 Component:  Database layer (models, ORM)  |   Version:  SVN
   
Resolution:|  Keywords:  
related_name, ManyToManyField, ForeignKey, abstract base class
 Stage:  Design decision needed| Has_patch:  1  
   
Needs_docs:  0 |   Needs_tests:  0  
   
Needs_better_patch:  1 |  
---+
Changes (by puxlit):

  * milestone:  1.3 => 2.0

Comment:

 Replying to [comment:1 anonymous] and [comment:2 mk]:
 Good point; I hadn't considered `verbose_name_plural`s with multiple
 and/or internationalised words.

 Replying to [comment:3 lrekucki]:
 That's a rather elegant solution. I agree that it's more of a nice touch
 than a must-have feature, but I make use of this patch in my code, and
 don't believe there's any harm in including it.

 Thanks for all the suggestions! I'm presently working on a patch with
 updated documentation and a set of test cases.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #14018: Introduce class_plural %-substitution placeholder for related_name of ForeignKey/ManyToManyField

2010-11-14 Thread Django
#14018: Introduce class_plural %-substitution placeholder for related_name of
ForeignKey/ManyToManyField
---+
  Reporter:  puxlit| Owner:  nobody 
   
Status:  new   | Milestone:  1.3
   
 Component:  Database layer (models, ORM)  |   Version:  SVN
   
Resolution:|  Keywords:  
related_name, ManyToManyField, ForeignKey, abstract base class
 Stage:  Design decision needed| Has_patch:  1  
   
Needs_docs:  0 |   Needs_tests:  0  
   
Needs_better_patch:  1 |  
---+
Changes (by lrekucki):

  * needs_better_patch:  0 => 1
  * stage:  Unreviewed => Design decision needed

Comment:

 The patch "as is" surely needs improvement. A simple solution that comes
 to mind would be adding {{{name_plural}}} to Meta. Then
 {{{%(class_plural)}}} could be replaced with that value or with class'
 name with an "s" added. The example above would then look something like
 this:
 {{{

 class Tag(models.Model):
 slug = models.SlugField(max_length=63, unique=True)

 class Post(models.Model):
 slug = models.SlugField(max_length=127, unique=True)
 tags = models.ManyToManyField(Tag,
 related_name='tagged_%(class_plural)s')

 class Meta:
 abstract = True

 class Entry(Post):
 title = models.CharField(max_length=255)
 content = models.TextField()

 class Meta:
 name_plural = "entries" # related attribute will be
 "tagged_entries"
 verbose_name_plural = _("Journal entries")

 class Event(Post):
 summary = models.CharField(max_length=255)
 start_date = models.DateTimeField()
 # related attribute will be "tagged_events"
 }}}

 I don't think much people care about this that much, so it's mostly a
 "nice to have" feature.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #14018: Introduce class_plural %-substitution placeholder for related_name of ForeignKey/ManyToManyField

2010-10-04 Thread Django
#14018: Introduce class_plural %-substitution placeholder for related_name of
ForeignKey/ManyToManyField
---+
  Reporter:  puxlit| Owner:  nobody 
   
Status:  new   | Milestone:  1.3
   
 Component:  Database layer (models, ORM)  |   Version:  SVN
   
Resolution:|  Keywords:  
related_name, ManyToManyField, ForeignKey, abstract base class
 Stage:  Unreviewed| Has_patch:  1  
   
Needs_docs:  0 |   Needs_tests:  0  
   
Needs_better_patch:  0 |  
---+
Comment (by mk):

 Making code (attribute names) dependent on the result of a translation is
 quite a stupid idea. verbose_name_plural might evaluate to other
 translations depending on settings.LANGUAGE_CODE, might contain special
 chars and whitespace and isn't suitable at all for naming class attributes
 (i.e. related_name).

 I'm quite sure this is "wontfix" material.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #14018: Introduce class_plural %-substitution placeholder for related_name of ForeignKey/ManyToManyField

2010-07-29 Thread Django
#14018: Introduce class_plural %-substitution placeholder for related_name of
ForeignKey/ManyToManyField
---+
  Reporter:  puxlit| Owner:  nobody 
   
Status:  new   | Milestone:  1.3
   
 Component:  Database layer (models, ORM)  |   Version:  SVN
   
Resolution:|  Keywords:  
related_name, ManyToManyField, ForeignKey, abstract base class
 Stage:  Unreviewed| Has_patch:  1  
   
Needs_docs:  0 |   Needs_tests:  0  
   
Needs_better_patch:  0 |  
---+
Changes (by anonymous):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 I don't think using verbose_name_plural as part of the related_name is a
 good idea. If you have a model named SpecialEntry, the default
 verbose_name will be 'special entry' and verbose_name_plural will be
 'special entrys'.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



[Django] #14018: Introduce class_plural %-substitution placeholder for related_name of ForeignKey/ManyToManyField

2010-07-28 Thread Django
#14018: Introduce class_plural %-substitution placeholder for related_name of
ForeignKey/ManyToManyField
+
 Reporter:  puxlit  |   
Owner:  nobody
   Status:  new |   
Milestone:  1.3   
Component:  Database layer (models, ORM)|   
  Version:  SVN   
 Keywords:  related_name, ManyToManyField, ForeignKey, abstract base class  |   
Stage:  Unreviewed
Has_patch:  1   |  
+
 Django 1.2 [http://docs.djangoproject.com/en/dev/topics/db/models/#be-
 careful-with-related-name introduced] two %-substitution placeholders,
 `%(class)s` and `%(app_label)s`, to work around uniqueness issues when a
 custom `related_name` for a `ForeignKey` or `ManyToManyField` defined in
 an abstract base class is inherited by multiple child classes.

 Quoting from [http://docs.djangoproject.com/en/dev/topics/db/models/#many-
 to-many-relationships Django's models documentation], "''It's suggested
 ![...] that the name of a `ManyToManyField` ![...] be a plural describing
 the set of related model objects.''" Given the nature of a
 `ManyToManyField`, it may be preferable to reciprocate this pluralized
 field naming style through `related_name`. By introducing a third
 %-substitution placeholder, `%(class_plural)s`, this can be accomplished.

 Consider the following snippet:

 {{{
 #!python

 class Tag(models.Model):
 slug = models.SlugField(max_length=63, unique=True)

 class Post(models.Model):
 slug = models.SlugField(max_length=127, unique=True)
 tags = models.ManyToManyField(Tag, related_name='%(class_plural)s') #
 docs suggest related_name='%(app_label)s_%(class)s_related'

 class Meta:
 abstract = True

 class Entry(Post):
 title = models.CharField(max_length=255)
 content = models.TextField()

 class Meta:
 verbose_name_plural = 'entries'

 class Event(Post):
 summary = models.CharField(max_length=255)
 start_date = models.DateTimeField()
 }}}

 Arguably, `tag.entries` and `tag.events` are more semantic than either
 `tag.entry_set` and `tag.event_set` or `tag.appname_entry_related` and
 `tag.appname_event_related`.

 Ultimately, the introduction of a `%(class_plural)s` %-substitution
 placeholder provides greater flexibility when designing models with
 abstract base classes and ForeignKeys or ManyToManyFields.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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