Re: django.utils.dateparse

2019-02-03 Thread Aymeric Augustin
Hello Guiseppe,

In which circumstances:

- would this be useful?
- would a Form not be a better choice?

Best regards,

-- 
Aymeric.



> On 4 Feb 2019, at 00:10, Giuseppe De Marco  wrote:
> 
> Hi Aymeric,
> 
> Thank you for the answer and for the tests as well.
> I understand and also agree your vision on all the line, I got the specific 
> purpose of parse_date.
> I'd like to introduce a generalized way to parse date and datetime string 
> based on Django project configuration, in settings.py.
> It could be linked, as reference, to DATE_INPUT_FORMATS or DATE_FORMATS or 
> whatever better choice.
> 
> This is the code example, it works as standalone, I hope that it's easy to 
> read...
> 
> # datetime_euristic_parser.py
> import re
> import datetime
> 
> DATE_FORMATS = ['%Y-%m-%d', 
> '%d/%m/%Y', 
> '%d/%m/%y']
> DATETIME_FORMATS = ['%Y-%m-%d %H:%M:%S', 
> '%d/%m/%Y %H:%M:%S', 
> '%d/%m/%y %H:%M:%S',
> '%Y%m%d%H%M%SZ',
> '%Y%m%d%H%M%S.%fZ']
> # to be extended with all the matching patterns.
> DATETIME_ELEMENTS_REGEXP = {'%Y': '(?P\d{4})',
> '%y': '(?P\d{2})',
> '%m': '(?P\d{1,2})',
> '%d': '(?P\d{1,2})',
> '%H': '(?P\d{1,2})',
> '%M': '(?P\d{1,2})',
> '%S': '(?P\d{1,2})',
> '%f': '(?P\d{6})'} # ...
>  
> def datetime_regexp_builder(formats):
> """
> formats = DATE_FORMAT of DATETIME_FORMAT
> """
> regexp_dict = {}
> for df in formats:
> df_regexp = df
> for k,v in DATETIME_ELEMENTS_REGEXP.items():
> df_regexp = df_regexp.replace(k,v)
> regexp_dict[df] = df_regexp+'$'
> return regexp_dict
> 
> DATE_FORMATS_REGEXP = datetime_regexp_builder(DATE_FORMATS)
> DATETIME_FORMATS_REGEXP = datetime_regexp_builder(DATETIME_FORMATS)
> 
> def dformat_insp(date_str, format_regexp_dict, debug=False):
> """
> Takes a date string and returns a matching date regexp. 
> """
> insp_formats = []
> for f,p in format_regexp_dict.items():
> if debug: print(date_str, f, p)
> match = re.match(p, date_str)
> if match:
> res = (f, p, {k:int(v) for k,v in match.groupdict().items()})
> insp_formats.append(res)
> return insp_formats
> 
> def dateformat_insp(date_str):
> return dformat_insp(date_str, DATE_FORMATS_REGEXP)
> 
> def datetimeformat_insp(date_str):
> return dformat_insp(date_str, DATETIME_FORMATS_REGEXP)
> 
> def datetime_euristic_parser(value):
> """
> value can be a datestring or a datetimestring
> returns all the parsed date or datetime object
> """
> l = []
> res = dateformat_insp(value) or \
>   datetimeformat_insp(value)
> for i in res:
> l.append(datetime.datetime(**i[-1]))
> return l
> 
> # example
> if __name__ == '__main__':
> tests = ['04/12/2018',
>  '04/12/2018 3:2:1',
>  '2018-03-4 09:7:4',
>  '2018-03-04T09:7:4.645194',
>  '20180304121940.948000Z']
> 
> for i in tests: 
> res = dateformat_insp(i) or datetimeformat_insp(i)
> if res:
> print('Parsing succesfull on "{}": {}'.format(i, res))
> #print(datetime_euristic_parser(i))
> else:
> print('Parsing failed on "{}"'.format(i))
> print()
> 
> 
> I also checked these tests:
> python -m timeit -s "from django.utils.dateparse import parse_datetime" 
> "parse_datetime('2019-02-03T17:27:58.645194')"
> 1 loops, best of 3: 32.7 usec per loop
> 
> python -m timeit -s "import datetime" 
> "datetime.datetime.strptime('2019-02-03T17:27:58.645194', 
> '%Y-%m-%dT%H:%M:%S.%f')"
> 1 loops, best of 3: 53.5 usec per loop
> 
> python -m timeit -s "from datetime_euristic_parser. import 
> datetime_euristic_parser; 
> datetime_euristic_parser('2019-02-03T17:27:58.645194')"
> 1000 loops, best of 3: 0.0241 usec per loop
> 
> In other words I'd like to have in Django a magic datetime parser, based on 
> the settings.py global definitions, instead of iterations on try/except  or 
> some other custom code.
> Hope it's fun
> 
> Il giorno dom 3 feb 2019 alle ore 18:44 Aymeric Augustin 
>  > ha scritto:
> Hello Guiseppe,
> 
> django.utils.dateparse provides helpers needed by Django to implement 
> datetime, date and time fields on SQLite. (SQLite doesn't have a native date 
> time type.) Their job is to parse ISO 8601 fast. That's it.
> 
> A utility module should do exactly what Django needs and nothing more. 
> django.utils.dateparse is documented so you can use it if it does what you 
> want. If it doesn't, use something else ;-)
> 
> Django forms try various formats when they receive user 

Re: Show applied datetime in showmigrations

2019-02-03 Thread Ryan Hiebert
I personally like the option better. This seems like a different use-case
than I'd normally expect from a verbosity level.

On Sun, Feb 3, 2019 at 12:45 PM Tim Schilling 
wrote:

> Not changing the default output makes a lot of sense. I initially was
> wondering if it should have its own option. Making it an addition to a
> higher verbosity level will work too.
>
> --
> 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/4f3d3816-94c6-4065-b7ea-8b21bfb3d4e6%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/CABpHFHQSxyRkfuH06d0P7YU0hYdUydWE%3DGxXAQ_y%2BYe7nGigUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.utils.dateparse

2019-02-03 Thread Tom Forbes
I’m pretty sure 0.0241 usec per loop is either a typo or a mistake during
benchmarking. I’ve got no comment what you’re proposing but correct and
valid benchmarks are important, so I would double check that.



On 3 February 2019 at 23:37:14, Giuseppe De Marco (
giuseppe.dema...@unical.it) wrote:

Regarding the previous example,
better to read it here (my fault: I mistaken the format
'%Y-%m-%dT%H:%M:%S.%f'):
https://github.com/peppelinux/Django-snippets/blob/master/datetime_heuristic_parser.py

and also, it should came also with tzinfo regexp and other functions as
well, like parse_date time_duration... it's only an example to share our
experiences.

--
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/CABms%2BYpcU3gbv7MqV1FkwU5mt9xhTRBoPeG6bPoYCnLvTJLGAw%40mail.gmail.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/CAFNZOJPciEjaiXO0oO-UTDCTnbgcSP3Us3D-gOdP4jvMZPGu_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.utils.dateparse

2019-02-03 Thread Giuseppe De Marco
Regarding the previous example,
better to read it here (my fault: I mistaken the format
'%Y-%m-%dT%H:%M:%S.%f'):
https://github.com/peppelinux/Django-snippets/blob/master/datetime_heuristic_parser.py

and also, it should came also with tzinfo regexp and other functions as
well, like parse_date time_duration... it's only an example to share our
experiences.

-- 
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/CABms%2BYpcU3gbv7MqV1FkwU5mt9xhTRBoPeG6bPoYCnLvTJLGAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.utils.dateparse

2019-02-03 Thread Giuseppe De Marco
Hi Aymeric,

Thank you for the answer and for the tests as well.
I understand and also agree your vision on all the line, I got the specific
purpose of parse_date.
I'd like to introduce a generalized way to parse date and datetime string
based on Django project configuration, in settings.py.
It could be linked, as reference, to DATE_INPUT_FORMATS or DATE_FORMATS or
whatever better choice.

This is the code example, it works as standalone, I hope that it's easy to
read...

# datetime_euristic_parser.py
import re
import datetime

DATE_FORMATS = ['%Y-%m-%d',
'%d/%m/%Y',
'%d/%m/%y']
DATETIME_FORMATS = ['%Y-%m-%d %H:%M:%S',
'%d/%m/%Y %H:%M:%S',
'%d/%m/%y %H:%M:%S',
'%Y%m%d%H%M%SZ',
'%Y%m%d%H%M%S.%fZ']
# to be extended with all the matching patterns.
DATETIME_ELEMENTS_REGEXP = {'%Y': '(?P\d{4})',
'%y': '(?P\d{2})',
'%m': '(?P\d{1,2})',
'%d': '(?P\d{1,2})',
'%H': '(?P\d{1,2})',
'%M': '(?P\d{1,2})',
'%S': '(?P\d{1,2})',
'%f': '(?P\d{6})'} # ...

def datetime_regexp_builder(formats):
"""
formats = DATE_FORMAT of DATETIME_FORMAT
"""
regexp_dict = {}
for df in formats:
df_regexp = df
for k,v in DATETIME_ELEMENTS_REGEXP.items():
df_regexp = df_regexp.replace(k,v)
regexp_dict[df] = df_regexp+'$'
return regexp_dict

DATE_FORMATS_REGEXP = datetime_regexp_builder(DATE_FORMATS)
DATETIME_FORMATS_REGEXP = datetime_regexp_builder(DATETIME_FORMATS)

def dformat_insp(date_str, format_regexp_dict, debug=False):
"""
Takes a date string and returns a matching date regexp.
"""
insp_formats = []
for f,p in format_regexp_dict.items():
if debug: print(date_str, f, p)
match = re.match(p, date_str)
if match:
res = (f, p, {k:int(v) for k,v in match.groupdict().items()})
insp_formats.append(res)
return insp_formats

def dateformat_insp(date_str):
return dformat_insp(date_str, DATE_FORMATS_REGEXP)

def datetimeformat_insp(date_str):
return dformat_insp(date_str, DATETIME_FORMATS_REGEXP)

def datetime_euristic_parser(value):
"""
value can be a datestring or a datetimestring
returns all the parsed date or datetime object
"""
l = []
res = dateformat_insp(value) or \
  datetimeformat_insp(value)
for i in res:
l.append(datetime.datetime(**i[-1]))
return l

# example
if __name__ == '__main__':
tests = ['04/12/2018',
 '04/12/2018 3:2:1',
 '2018-03-4 09:7:4',
 '2018-03-04T09:7:4.645194',
 '20180304121940.948000Z']

for i in tests:
res = dateformat_insp(i) or datetimeformat_insp(i)
if res:
print('Parsing succesfull on "{}": {}'.format(i, res))
#print(datetime_euristic_parser(i))
else:
print('Parsing failed on "{}"'.format(i))
print()


I also checked these tests:
python -m timeit -s "from django.utils.dateparse import parse_datetime"
"parse_datetime('2019-02-03T17:27:58.645194')"
1 loops, best of 3: 32.7 usec per loop

python -m timeit -s "import datetime"
"datetime.datetime.strptime('2019-02-03T17:27:58.645194',
'%Y-%m-%dT%H:%M:%S.%f')"
1 loops, best of 3: 53.5 usec per loop

python -m timeit -s "from datetime_euristic_parser. import
datetime_euristic_parser;
datetime_euristic_parser('2019-02-03T17:27:58.645194')"
1000 loops, best of 3: 0.0241 usec per loop

In other words I'd like to have in Django a magic datetime parser, based on
the settings.py global definitions, instead of iterations on try/except  or
some other custom code.
Hope it's fun

Il giorno dom 3 feb 2019 alle ore 18:44 Aymeric Augustin <
aymeric.augus...@polytechnique.org> ha scritto:

> Hello Guiseppe,
>
> django.utils.dateparse provides helpers needed by Django to implement
> datetime, date and time fields on SQLite. (SQLite doesn't have a native
> date time type.) Their job is to parse ISO 8601 fast. That's it.
>
> A utility module should do exactly what Django needs and nothing
> more. django.utils.dateparse is documented so you can use it if it does
> what you want. If it doesn't, use something else ;-)
>
> Django forms try various formats when they receive user input because
> there's uncertainty about the format. If you're parsing user input, then
> you should use a form and you'll get the behavior you want.
>
> To clarify my point about performance, here's the function you're
> proposing, minus support for USE_L10N:
>
> def parse_datetime_alternative(value):
> for format in settings.DATETIME_INPUT_FORMATS:
> try:
> return datetime.datetime.strptime(format, value)
> except (ValueError, TypeError):
> 

Re: django.test: Display tests that succeeded

2019-02-03 Thread Adam Johnson
Django's test runner is based on Python's built-in unittest:
https://docs.python.org/3/library/unittest.html#module-unittest . I believe
you can use the verbose mode (e.g. -v 2) to see the list of all executed
tests.

On Sun, 3 Feb 2019 at 21:56, Jeremy Potter 
wrote:

> The Django test runner currently only displays tests that failed, and not
> those that succeeded. It would be nice if Django were to print out a list
> of tests that succeeded. First of all, it is satisfying to see tests
> succeed. Second of all, it would be easier to debug (if certain tests were
> not being run, for example). IMHO printing out the word "OK" is rather
> cryptic and boring.
>
> For example, Jest:
>
> [image: jest2.png]
> What do you think?
>
> --
> 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/3474db84-4df0-4a03-9472-1ea6bc8c11a2%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Adam

-- 
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/CAMyDDM1mf70hQjt2%3D4zHWacC0LVU-mB8F0ieC%2BxJmQ61JV4MNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django.test: Display tests that succeeded

2019-02-03 Thread Jeremy Potter
The Django test runner currently only displays tests that failed, and not 
those that succeeded. It would be nice if Django were to print out a list 
of tests that succeeded. First of all, it is satisfying to see tests 
succeed. Second of all, it would be easier to debug (if certain tests were 
not being run, for example). IMHO printing out the word "OK" is rather 
cryptic and boring.

For example, Jest:

[image: jest2.png]
What do you think?

-- 
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/3474db84-4df0-4a03-9472-1ea6bc8c11a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Google Summer of Code 2019

2019-02-03 Thread Carlton Gibson
Yes. GSoC wasn't at all on my radar before your post here Tim. 

We've had a few "hello" posts but no even semi-concrete proposals from 
students. (Equally we don't have a list ready to go.) 

I had a look at the process. It seems a moderate commitment, so, for me, I 
think I'd want to be familiar with applicants before we took that on. i.e. 
We need say to students to get involved months before. 
I'll think about messaging for that for next year because GSoC seems good 
overall. 

SO unless someone is going to blow us away with an outline of a proposal 
TOMORROW, we'll have to pass this year. (Deadline being Tuesday.)

On Friday, 1 February 2019 22:32:43 UTC+1, Tim Graham wrote:
>
> As of now, I haven't seen any existing Django contributors who are 
> planning to propose a project, therefore I don't think it's worthwhile for 
> the DSF to apply for this summer. The decision to apply on behalf of the 
> DSF is up to Carlton, Mariusz, or another potential mentor.
>
> On Thursday, January 31, 2019 at 6:24:36 AM UTC-5, gaurav jain wrote:
>>
>> One Idea i have a one command django project maker to instead having 1+n 
>> commands(n number of apps) and linking them in setting we can have command 
>> take the number of apps and app_names in ine do and then later we can add 
>> functionality for heroku ,docker etc
>>
>> On Wednesday, January 16, 2019 at 8:03:55 PM UTC+5:30, Tim Graham wrote:
>>>
>>> Org applications for Google's Summer of Code are now open (deadline 
>>> February 6). Do you think the Django Software Foundation should participate?
>>>
>>> We haven't had any high quality student applications that we could 
>>> accept for the past two years.
>>>
>>> Perhaps it's partly a function of a poor ideas page (
>>> https://code.djangoproject.com/wiki/SummerOfCode2018). Perhaps we don't 
>>> do a great job of publicizing our involvement and attracting high quality 
>>> students. Perhaps it's because the student payment isn't all that much 
>>> (+/-$6000 USD, depending on student's country)* for the amount of work 
>>> involved (also, students have to put in a lot of work up front in their 
>>> application, with no guarantee of being accepted into the program).
>>>
>>> If you have any ideas about mentoring or suggesting a project, or if 
>>> you're serious about being a student (you should start contributing to 
>>> Django now if you don't already), please share.
>>>
>>> * https://developers.google.com/open-source/gsoc/help/student-stipends
>>>
>>

-- 
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/62853b9c-6201-4d13-b788-b807b5348d2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help needed on Django-Guardian.

2019-02-03 Thread Nasir Hussain
Hi,

Thanks for reaching out to the mailing list. I've stared the repo and will
start contributing from now on.

On Mon, Feb 4, 2019, 2:01 AM Carlton Gibson  Hi all.
>
> Adam Dobrawy who runs Django-Guardian, could do with some help maintaining
> there.
>
> The project seems to be in good shape. (It's up to date) But needs a bit
> of help keeping on top of the issues, dropping old-versions, and the rest
> of it.
>
> I see the project has some regular contributors. If you're one of them, do
> you have a small amount extra to help with the maintenance?
>
> If you're not a contributor but use it, would you be able to lend a hand?
>
> As ever, first step if hanging out on the repo and helping with any
> incoming.
>
> https://github.com/django-guardian/django-guardian
>
> Thanks.
>
> Kind Regards,
>
> Carlton
>
> --
> 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/a33b0fcd-61eb-410f-b30b-37a6234e82db%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/CAB5Hk3whmEjb9oST%3DfxsANcoGXsoJ0y2uO9HQJEwcrMX4ex%3DHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Help needed on Django-Guardian.

2019-02-03 Thread Carlton Gibson
Hi all. 

Adam Dobrawy who runs Django-Guardian, could do with some help maintaining 
there. 

The project seems to be in good shape. (It's up to date) But needs a bit of 
help keeping on top of the issues, dropping old-versions, and the rest of 
it. 

I see the project has some regular contributors. If you're one of them, do 
you have a small amount extra to help with the maintenance?

If you're not a contributor but use it, would you be able to lend a hand? 

As ever, first step if hanging out on the repo and helping with any 
incoming.

https://github.com/django-guardian/django-guardian

Thanks. 

Kind Regards,

Carlton

-- 
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/a33b0fcd-61eb-410f-b30b-37a6234e82db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Show applied datetime in showmigrations

2019-02-03 Thread Tim Schilling
Not changing the default output makes a lot of sense. I initially was 
wondering if it should have its own option. Making it an addition to a 
higher verbosity level will work too.

-- 
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/4f3d3816-94c6-4065-b7ea-8b21bfb3d4e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Show applied datetime in showmigrations

2019-02-03 Thread Aymeric Augustin
Hello,

This sounds interesting.

You should think a bit about backwards compatibility because there's a good 
chance that some users are calling django-admin showmigrations in scripts or 
tools. I don't think this is a blocker for changing the output format. However 
you should plan to minimize disruption, perhaps by showing this information 
only a verbosity level higher than the default.

Best regards,

-- 
Aymeric.



> On 3 Feb 2019, at 18:28, Tim Schilling  wrote:
> 
> My idea is to add the applied datetime value to the showmigrations command.
> 
> I've run into the case where I'm working on a branch that involves a number 
> of migrations across various apps, but then have to switch to a different 
> branch which has different migrations. It can be troublesome to determine 
> which migrations are new and need to be rolled back. I've recently started 
> looking at the django_migrations table sorted on the applied column to 
> determine which I've run recently. This would make switching between branches 
> involving conflicting migrations easier.
> 
> Thanks,
> Tim
> 
> -- 
> 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/77e70de0-6418-4294-9135-a30a8a6b4b33%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/835B3F0F-88C5-42E7-9457-5028BA333D98%40polytechnique.org.
For more options, visit https://groups.google.com/d/optout.


Re: django.utils.dateparse

2019-02-03 Thread Aymeric Augustin
Hello Guiseppe,

django.utils.dateparse provides helpers needed by Django to implement datetime, 
date and time fields on SQLite. (SQLite doesn't have a native date time type.) 
Their job is to parse ISO 8601 fast. That's it.

A utility module should do exactly what Django needs and nothing more. 
django.utils.dateparse is documented so you can use it if it does what you 
want. If it doesn't, use something else ;-)

Django forms try various formats when they receive user input because there's 
uncertainty about the format. If you're parsing user input, then you should use 
a form and you'll get the behavior you want.

To clarify my point about performance, here's the function you're proposing, 
minus support for USE_L10N:

def parse_datetime_alternative(value):
for format in settings.DATETIME_INPUT_FORMATS:
try:
return datetime.datetime.strptime(format, value)
except (ValueError, TypeError):
continue

It's 10 times slower than the current implementation of parse_datetime:

$ python -m timeit -s "from django.conf import settings; settings.configured or 
settings.configure(); from django.utils.dateparse import 
parse_datetime_alternative as parse_datetime" 
"parse_datetime('2019-02-03T17:27:58.645194')"
5000 loops, best of 5: 54.2 usec per loop

$ python -m timeit -s "from django.utils.dateparse import parse_datetime" 
"parse_datetime('2019-02-03T17:27:58.645194')"
5 loops, best of 5: 5.48 usec per loop

I implemented parse_datetime with a regex because that's almost twice as fast 
as a single call to datetime.datetime.strptime:

$ python -m timeit -s "import datetime" 
"datetime.datetime.strptime('2019-02-03T17:27:58.645194', 
'%Y-%m-%dT%H:%M:%S.%f')"
2 loops, best of 5: 9.87 usec per loop

Best regards,

-- 
Aymeric.



> On 3 Feb 2019, at 17:10, Giuseppe De Marco  wrote:
> 
> Hi All, it's the first time for me in this ml,
> 
> I'd like to purpose a refactor of django.utils.dateparse functions.
> Currently a function in it, like parse_date for example, extract date time 
> string with a static regexp...
> 
> https://docs.djangoproject.com/pl/2.1/_modules/django/utils/dateparse/ 
> 
> 
> The first time I used It I thought that those functions parses date, time and 
> date time, according to settings.py definitions like DATETIME_INPUT_FORMATS, 
> but It was not this way... Then I read the code.
> 
> Wouldn't It better to use settings.py definitions to manage these formats and 
> django.utils.dateparse behaviour?
> 
> 
> 
> 
> -- 
> 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/CABms%2BYpGtCQ1yzVfGtRKpDv60-4oH_SyGpPQYR6j1cR%2BL5LFRA%40mail.gmail.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/BEAAEDB4-D58E-4CD0-8F1A-11A5F60B556B%40polytechnique.org.
For more options, visit https://groups.google.com/d/optout.


Show applied datetime in showmigrations

2019-02-03 Thread Tim Schilling
My idea is to add the applied datetime value to the showmigrations command.

I've run into the case where I'm working on a branch that involves a number 
of migrations across various apps, but then have to switch to a different 
branch which has different migrations. It can be troublesome to determine 
which migrations are new and need to be rolled back. I've recently started 
looking at the django_migrations table sorted on the applied column to 
determine which I've run recently. This would make switching between 
branches involving conflicting migrations easier.

Thanks,
Tim

-- 
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/77e70de0-6418-4294-9135-a30a8a6b4b33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django.utils.dateparse

2019-02-03 Thread Giuseppe De Marco
Hi All, it's the first time for me in this ml,

I'd like to purpose a refactor of django.utils.dateparse functions.
Currently a function in it, like parse_date for example, extract date time
string with a static regexp...

https://docs.djangoproject.com/pl/2.1/_modules/django/utils/dateparse/

The first time I used It I thought that those functions parses date, time
and date time, according to settings.py definitions like
DATETIME_INPUT_FORMATS, but It was not this way... Then I read the code.

Wouldn't It better to use settings.py definitions to manage these formats
and django.utils.dateparse behaviour?

-- 
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/CABms%2BYpGtCQ1yzVfGtRKpDv60-4oH_SyGpPQYR6j1cR%2BL5LFRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Fellow Reports - January 2019

2019-02-03 Thread Adam Johnson
This mailing list is for the development of Django. itself, not for support
using Django. Please keep such questions to Stack Overflow, or the
django-users mailing list.

On Sun, 3 Feb 2019 at 14:03, hunar techie 
wrote:

>
> https://stackoverflow.com/questions/54503581/python-setup-in-cpanel-file-usr-bin-virtualenv-errno-2-no-such-file-or-dir
>
> please someone can help me to fix this issues
>
> On Sun, Feb 3, 2019 at 12:46 AM Tim Graham  wrote:
>
>> Week ending February 2, 2019
>>
>> Triaged
>>
>> ---
>>
>> https://code.djangoproject.com/ticket/30146 - Move change form fieldset
>> toggle to the right side (wontfix)
>>
>> https://code.djangoproject.com/ticket/30150 - Django 1.11 with MySQL 8:
>> "Unknown system variable 'TX_ISOLATION'" (wontfix)
>>
>> https://code.djangoproject.com/ticket/30151 - QuerySet.last() and []
>> operator give different results (invalid)
>>
>> https://code.djangoproject.com/ticket/30152 - MySQL: "Cannot change
>> column 'id': used in a foreign key constraint" when altering pk of model
>> with ForeignKey to self (accepted)
>>
>> https://code.djangoproject.com/ticket/30153 - ModelAdmin with custom
>> widgets, inlines, and filter_horizontal can merge media in broken order
>> (accepted)
>>
>> Authored
>>
>> --
>>
>> https://github.com/praekelt/django-recaptcha/pull/180 - Add testing for
>> Django 2.2
>>
>> https://github.com/django-haystack/django-haystack/pull/1659 - Add
>> testing for Django 2.2
>>
>> https://github.com/pennersr/django-allauth/pull/2192 - Add testing for
>> Django 2.2
>>
>> https://github.com/SmileyChris/easy-thumbnails/pull/510 - Add testing
>> for Django 2.2
>>
>> Reviewed/committed
>>
>> --
>>
>> https://github.com/django/django/pull/10904 - Fixed #30137 -- Replaced
>> OSError aliases with the canonical OSError.
>>
>> https://github.com/django/django/pull/10851 - Made test table cleanup in
>> OperationTestBase more robust.
>>
>> https://github.com/django/django/pull/10716 - Fixed #29973 -- Added
>> compilemessages --ignore option.
>>
>> https://github.com/django/django/pull/10874 - Fixed #30108 -- Allowed
>> adding foreign key constraints in the same statement that adds a field.
>>
>> https://github.com/django/django/pull/10877 - Fixed #22423 - Added
>> support for MySQL operators on real geometries.
>>
>> https://github.com/django/django/pull/10760 - Fixed #30020 -- Fixed
>> importing nulls with LayerMapping.
>>
>> https://github.com/django/django/pull/10822 - Fixed #30076 -- Added
>> Model.get_FOO_display() even if field's choices are empty.
>>
>> https://github.com/django/django/pull/10919 - Fixed #30147 -- Simplified
>> directory creation with os.makedirs(..., exist_ok=True).
>>
>> https://github.com/django/django/pull/10891 - Refs #28161 -- Doc'd
>> INSTALLED_APPS requirement for ArrayField(CIText).
>>
>> https://github.com/django/django/pull/10918 - Used LoginRequiredMixin in
>> "Models and request.user" example.
>> https://github.com/django/django/pull/10730 - Fixed #29393 -- Prevented
>> infinite loop in ExceptionReporter.get_traceback_frames().
>>
>> --
>> 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/6fa3a54e-c8b0-47fd-a088-48afc41b5318%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/CAKJtO%2BuQ%3DiQ7M__%3DVBUNhJC1oT_kBRZG2%3DGkXeXLZYAVy1kQ4g%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Adam

-- 
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 

Re: Fellow Reports - January 2019

2019-02-03 Thread hunar techie
https://stackoverflow.com/questions/54503581/python-setup-in-cpanel-file-usr-bin-virtualenv-errno-2-no-such-file-or-dir

please someone can help me to fix this issues

On Sun, Feb 3, 2019 at 12:46 AM Tim Graham  wrote:

> Week ending February 2, 2019
>
> Triaged
>
> ---
>
> https://code.djangoproject.com/ticket/30146 - Move change form fieldset
> toggle to the right side (wontfix)
>
> https://code.djangoproject.com/ticket/30150 - Django 1.11 with MySQL 8:
> "Unknown system variable 'TX_ISOLATION'" (wontfix)
>
> https://code.djangoproject.com/ticket/30151 - QuerySet.last() and []
> operator give different results (invalid)
>
> https://code.djangoproject.com/ticket/30152 - MySQL: "Cannot change
> column 'id': used in a foreign key constraint" when altering pk of model
> with ForeignKey to self (accepted)
>
> https://code.djangoproject.com/ticket/30153 - ModelAdmin with custom
> widgets, inlines, and filter_horizontal can merge media in broken order
> (accepted)
>
> Authored
>
> --
>
> https://github.com/praekelt/django-recaptcha/pull/180 - Add testing for
> Django 2.2
>
> https://github.com/django-haystack/django-haystack/pull/1659 - Add
> testing for Django 2.2
>
> https://github.com/pennersr/django-allauth/pull/2192 - Add testing for
> Django 2.2
>
> https://github.com/SmileyChris/easy-thumbnails/pull/510 - Add testing for
> Django 2.2
>
> Reviewed/committed
>
> --
>
> https://github.com/django/django/pull/10904 - Fixed #30137 -- Replaced
> OSError aliases with the canonical OSError.
>
> https://github.com/django/django/pull/10851 - Made test table cleanup in
> OperationTestBase more robust.
>
> https://github.com/django/django/pull/10716 - Fixed #29973 -- Added
> compilemessages --ignore option.
>
> https://github.com/django/django/pull/10874 - Fixed #30108 -- Allowed
> adding foreign key constraints in the same statement that adds a field.
>
> https://github.com/django/django/pull/10877 - Fixed #22423 - Added
> support for MySQL operators on real geometries.
>
> https://github.com/django/django/pull/10760 - Fixed #30020 -- Fixed
> importing nulls with LayerMapping.
>
> https://github.com/django/django/pull/10822 - Fixed #30076 -- Added
> Model.get_FOO_display() even if field's choices are empty.
>
> https://github.com/django/django/pull/10919 - Fixed #30147 -- Simplified
> directory creation with os.makedirs(..., exist_ok=True).
>
> https://github.com/django/django/pull/10891 - Refs #28161 -- Doc'd
> INSTALLED_APPS requirement for ArrayField(CIText).
>
> https://github.com/django/django/pull/10918 - Used LoginRequiredMixin in
> "Models and request.user" example.
> https://github.com/django/django/pull/10730 - Fixed #29393 -- Prevented
> infinite loop in ExceptionReporter.get_traceback_frames().
>
> --
> 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/6fa3a54e-c8b0-47fd-a088-48afc41b5318%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/CAKJtO%2BuQ%3DiQ7M__%3DVBUNhJC1oT_kBRZG2%3DGkXeXLZYAVy1kQ4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


GSoC 2019 Project Idea

2019-02-03 Thread PARTH PATIL
Hey, I had a project idea for GSoC.
I wanted to make a tool which will help to port static projects like Jekyll 
to Django directly.
I am still thinking about the details of the idea.

But I want to know:

   - is this idea feasible/useful?
   - Does there already exist a similar tool for this?
   - Is this a good idea for GSoC?

I got this idea last year when I was working on my club website which was 
written using Jekyll and I had to port it to Django framework since it was 
going to be hosted on our college server which had Django backend.
The problem was we constantly had to update the website with post, so I was 
just left with the option to rewrite all the code natively in Django. 
That's why I thought of making a tool which will take a Jekyll project and 
convert it to Django app, with proper views and models etc.

 

-- 
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/92a5f672-4ab3-41a9-a93c-38422a121794%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: GSoC Idea

2019-02-03 Thread PARTH PATIL
Hey, can you elaborate on what your idea is?

On Thursday, January 31, 2019 at 4:54:36 PM UTC+5:30, gaurav jain wrote:
>
> from django.db import models
> from django.contrib.auth.models import User
>
> class CommenInfo(models.Model):
> archived = models.BooleanField(default=False)
> created_at = models.DateTimeField(auto_now_add=True)
> updated_at = models.DateTimeField(auto_now=True)
>
> def delete(self):
> self.archived = True
> super().save()
>
> class Meta:
> abstract = True
> class Team(CommenInfo):
> pass
>
>
>

-- 
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/02ed1aa7-c22a-4588-8b3e-5815f59a5e74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.