Re: [Django] #18478: Field.get_default will stringify everything that isn't a callable

2012-09-08 Thread Django
#18478: Field.get_default will stringify everything that isn't a callable
--+
 Reporter:  enrico|Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  closed
Component:  Documentation |  Version:  1.4
 Severity:  Normal|   Resolution:  fixed
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Tim Graham ):

 In [cd5181f84c7d4f2002efb777b6cf042771135f7a]:
 {{{
 #!CommitTicketReference repository=""
 revision="cd5181f84c7d4f2002efb777b6cf042771135f7a"
 [1.4.X] Fixed #18478 - Documented how to use a mutable default in a model
 field.

 Backport of 6e2bb344e4 from master
 }}}

-- 
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-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #18478: Field.get_default will stringify everything that isn't a callable

2012-09-08 Thread Django
#18478: Field.get_default will stringify everything that isn't a callable
--+
 Reporter:  enrico|Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  closed
Component:  Documentation |  Version:  1.4
 Severity:  Normal|   Resolution:  fixed
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Tim Graham ):

 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 In [6e2bb344e40dafdf462f6fb660837fa061faf549]:
 {{{
 #!CommitTicketReference repository=""
 revision="6e2bb344e40dafdf462f6fb660837fa061faf549"
 Fixed #18478 - Documented how to use a mutable default in a model field.
 }}}

-- 
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-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #18478: Field.get_default will stringify everything that isn't a callable

2012-09-01 Thread Django
#18478: Field.get_default will stringify everything that isn't a callable
--+
 Reporter:  enrico|Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  reopened
Component:  Documentation |  Version:  1.4
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by timo):

 * cc: timograham@… (added)
 * has_patch:  0 => 1


-- 
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-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #18478: Field.get_default will stringify everything that isn't a callable

2012-07-15 Thread Django
#18478: Field.get_default will stringify everything that isn't a callable
--+
 Reporter:  enrico|Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  reopened
Component:  Documentation |  Version:  1.4
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by aaugustin):

 * status:  closed => reopened
 * resolution:  duplicate =>
 * type:  Uncategorized => Cleanup/optimization
 * component:  Uncategorized => Documentation
 * stage:  Unreviewed => Accepted


Comment:

 Well, it took me a bit of time to find it, and I wasn't aware of this
 reason :)

 Accepting as a documentation issue.

-- 
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-updates@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] #18478: Field.get_default will stringify everything that isn't a callable

2012-07-14 Thread Django
#18478: Field.get_default will stringify everything that isn't a callable
---+--
 Reporter:  enrico |Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.4
 Severity:  Normal |   Resolution:  duplicate
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by enrico):

 Thanks for linking this to #8633, I'm sorry I didn't find it myself.

 I reckon the information in #8633 is rather relevant for people creating
 custom field types. Would it make sense to have it mentioned in the Field
 documentation, rather than hidden in an old bug log?

-- 
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-updates@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] #18478: Field.get_default will stringify everything that isn't a callable

2012-07-14 Thread Django
#18478: Field.get_default will stringify everything that isn't a callable
---+--
 Reporter:  enrico |Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.4
 Severity:  Normal |   Resolution:  duplicate
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by aaugustin):

 * status:  new => closed
 * needs_docs:   => 0
 * resolution:   => duplicate
 * needs_tests:   => 0
 * needs_better_patch:   => 0


Comment:

 Duplicate of #8633, and the reason is explained there.

-- 
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-updates@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] #18478: Field.get_default will stringify everything that isn't a callable

2012-06-15 Thread Django
#18478: Field.get_default will stringify everything that isn't a callable
---+
 Reporter:  enrico |  Owner:  nobody
 Type:  Uncategorized  | Status:  new
Component:  Uncategorized  |Version:  1.4
 Severity:  Normal |   Keywords:
 Triage Stage:  Unreviewed |  Has patch:  0
Easy pickings:  0  |  UI/UX:  0
---+
 I'm using a JSON-encoded field that can take any python data structure as
 default, this way:
 {{{
 info = fields.ContactInfoField("Contact info", blank=True,
 default={"a":u"I ♥ Django"})
 }}}
 and found out that I was getting {{{"{'a': u'I \\u2665 Django'}"}}} as a
 default value in my model objects.

 I tracked it down to Field.get_default, which stringifies all non-
 callables:
 {{{
 def get_default(self):
 """
 Returns the default value for this field.
 """
 if self.has_default():
 if callable(self.default):
 return self.default()
 return force_unicode(self.default, strings_only=True)
 if (not self.empty_strings_allowed or (self.null and
not
 connection.features.interprets_empty_strings_as_nulls)):
 return None
 return ""
 }}}

 Indeed this works as expected:
 {{{
 info = fields.ContactInfoField("Contact info", blank=True,
 default=lambda:{{"a":u"I ♥ Django"})
 }}}

 I cannot understand the reason for the different treatment of values and
 callables, and comments don't help. Field documentation does not mention
 this behaviour either. From what little I can understand, this looks like
 a bug,

-- 
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-updates@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.