Re: Spaces between argument separator and argument in template filter generate error

2018-06-01 Thread Alasdair Nicol
On Friday, 1 June 2018 03:06:01 UTC+1, Collin Anderson wrote:

> Maybe it would be worth having a more friendly error message?
>
>
I agree, it would be good to improve the message.

I've also seen users confused by the "could not parse the remainder" 
message when they forget the spaces around boolean operators, for example:

{% if foo=='bar' %}

On Thu, May 31, 2018 at 8:59 PM, > wrote:
>
>> Thank you for your reply.
>> I understand your opinion well
>>
>> 2018년 5월 31일 목요일 오전 11시 41분 22초 UTC+9, oli...@kidsnote.com 님의 말:
>>>
>>> In the template filter system now,
>>>
>>> spaces between augment separator and augments generate error.
>>> For example, the following template code generates the following error.
>>>
>>> {{ value | filter: "arg"}}
>>>
>>> TemplateSyntaxError at /
>>> Could not parse the remainder: ': "arg"' from 'value | filter: "arg"'
>>>
>>> https://code.djangoproject.com/ticket/29457
>>>
>>>
>>> What do you think of this ticket?
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-develop...@googlegroups.com .
>> To post to this group, send email to django-d...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-developers.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/b133457b-e474-47b6-b37f-cdab3fa6ee2f%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/4747632d-4b1e-43f5-a99f-11b2efbaa49f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Spaces between argument separator and argument in template filter generate error

2018-06-01 Thread Curtis Maloney

On 05/31/2018 06:39 PM, oli...@kidsnote.com wrote:

Are there any reasons that not allow spaces between separator and arg?


My first thought would be that it starts making the syntax looser, 
meaning more things that are currently error cases would be accepted as 
valid.


Which means mistakes will no longer raise errors.

--
Curtis


2018년 5월 31일 목요일 오전 11시 41분 22초 UTC+9, oli...@kidsnote.com 님 
의 말:


In the template filter system now,

spaces between augment separator and augments generate error.
For example, the following template code generates the following error.

{{ value | filter: "arg"}}

TemplateSyntaxError at /
Could not parse the remainder: ': "arg"' from 'value | filter: "arg"'

https://code.djangoproject.com/ticket/29457



What do you think of this ticket?

--
You received this message because you are subscribed to the Google 
Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-developers+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-developers@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/131b5095-c5b7-4492-92fa-e58912ac842a%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/ab2d6097-51e4-56a2-e096-3a8189cdc6eb%40tinbrain.net.
For more options, visit https://groups.google.com/d/optout.


Django bugfix release 2.0.6

2018-06-01 Thread Carlton Gibson
Details are available on the Django project weblog: 
https://www.djangoproject.com/weblog/2018/jun/01/bugfix-release/ 


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/E35B0A2E-B45C-41F6-BC8F-2838C5683B64%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Humanize naturaltime alternative phrasing

2018-06-01 Thread Gregory Kaleka
Django Humanize's naturaltime filter currently uses the phrasing "5 hours 
from now". In some contexts, I find the phrasing "in 5 hours" more natural.

Here's a diff in the naturaltime definition that would allow this 
alternative phrasing as an option. Any thoughts from the community on this?

Also, where are the unittests for the humanize filters? I couldn't readily 
find them.

Thanks all!


@@ -209,10 +209,12 @@ def naturalday(value, arg=None):
 # This filter doesn't require expects_localtime=True because it deals 
properly
 # with both naive and aware datetimes. Therefore avoid the cost of 
conversion.
 @register.filter
-def naturaltime(value):
+def naturaltime(value, use_in_phrasing=False):
 """
 For date and time values show how many seconds, minutes, or hours ago
-compared to current timestamp return representing string.
+compared to current timestamp return representing string. If 
use_in_phrasing
+is True, returns a string like 'in 5 hours' for future times, rather 
than
+'5 hours from now'.
 """
 if not isinstance(value, date):  # datetime is a subclass of date
 return value
@@ -271,22 +273,45 @@ def naturaltime(value):
 elif delta.seconds == 0:
 return _('now')
 elif delta.seconds < 60:
-return ngettext(
-# Translators: please keep a non-breaking space (U+00A0)
-# between count and time unit.
-'a second from now', '%(count)s seconds from now', delta.
seconds
-) % {'count': delta.seconds}
+if use_in_phrasing:
+# Note 'in a second' is not used because it has an 
idiomatic connotation of 'about'
+return ngettext(
+# Translators: please keep a non-breaking space 
(U+00A0)
+# between count and time unit.
+'in 1 second', 'in %(count)s seconds', delta.seconds
+) % {'count': delta.seconds}
+else:
+return ngettext(
+# Translators: please keep a non-breaking space 
(U+00A0)
+# between count and time unit.
+'a second from now', '%(count)s seconds from now', 
delta.seconds
+) % {'count': delta.seconds}
 elif delta.seconds // 60 < 60:
 count = delta.seconds // 60
-return ngettext(
-# Translators: please keep a non-breaking space (U+00A0)
-# between count and time unit.
-'a minute from now', '%(count)s minutes from now', count
-) % {'count': count}
+if use_in_phrasing:
+# Note 'in a minute' is not used because it has an 
idiomatic connotation of 'about'
+return ngettext(
+# Translators: please keep a non-breaking space 
(U+00A0)
+# between count and time unit.
+'in 1 minute', 'in %(count)s minutes', count
+) % {'count': count}
+else:
+return ngettext(
+# Translators: please keep a non-breaking space 
(U+00A0)
+# between count and time unit.
+'a minute from now', '%(count)s minutes from now', 
count
+) % {'count': count}
 else:
 count = delta.seconds // 60 // 60
-return ngettext(
-# Translators: please keep a non-breaking space (U+00A0)
-# between count and time unit.
-'an hour from now', '%(count)s hours from now', count
-) % {'count': count}
+if use_in_phrasing:
+return ngettext(
+# Translators: please keep a non-breaking space 
(U+00A0)
+# between count and time unit.
+'in an hour', 'in %(count)s hours', count
+) % {'count': count}
+else:
+return ngettext(
+# Translators: please keep a non-breaking space 
(U+00A0)
+# between count and time unit.
+'an hour from now', '%(count)s hours from now', count
+) % {'count': count}

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/ea7eb308-abac-4a37-8e31-c6d862729949%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.