Re: Proposal: Extend db.models.functions.datetime.Now

2023-03-01 Thread matteo vitali
@ Adam,
thanks to you for your feedback

Il giorno martedì 28 febbraio 2023 alle 21:51:15 UTC+1 Adam Johnson ha 
scritto:

> Hi Matteo,
>
> I agree with Mariusz on the ticket - this is a step beyond what Django 
> should support. You've shown in your proposal that such a function takes 3 
> lines of code for PostgreSQL. I don't think this is a burden on developers 
> to implement when needed.
>
> Also, the TruncDate(Now()) pattern is easily wrapped up in a function:
>
> def Today():
> return TruncDate(Now())
>
> Thanks for the suggestion though.
>
> On Sun, Feb 26, 2023 at 7:13 AM matteo vitali  wrote:
>
>> Hi everyone, 
>> it's my first thread here and sorry in advance for my bad english. 
>> Regarding the topic that I wanted to bring to the attention of the 
>> community, I have already opened a ticket and a thread on discord, but I 
>> was advised to try to open a discussion here to see if it might be of 
>> interest (I hope I won't go into too much length but I try to summarize 
>> my proposal as clearly and exhaustively as possible), so ... 
>>
>> I already know that contributions on ORM changes or improvements don't 
>> have a good reputation for all the reasons I wholeheartedly agree with, but 
>> I noticed that in the db.models.functions.datetime section the date 
>> truncation could be done more natively using database templates. 
>> On the ticket that I had erroneously opened I drafted a snippet of 
>> proposal code that I link below 
>> https://code.djangoproject.com/ticket/34364?replyto=4#comment
>>
>> My proposal is to extend the Now functionality of the ORM with a more 
>> native mode of the database. For example at the moment if we want to 
>> cast a datetime to date it is possible to do so by passing through a 
>> Truncate and then TrunDate(Now()) but the NOW functionality of the db (and 
>> I think it is supported by both postgresql and mysql) offers templates to 
>> format the date at your convenience. 
>>
>> For example, if in one of our projects, where postgresql is used as a 
>> database, we wanted to avoid going through Truncate and take advantage of 
>> this native functionality of the database, we could quite simply extend Now 
>> with something like this: 
>>
>> class Today(Now): 
>> template = "CURRENT_DATE"
>> output_field = DateField() 
>>
>> so we can compare a DateField with Today for example: 
>>
>> MyModel.objects.filter(mydatefiled__lte=Today()) 
>>
>> and not :
>>
>> MyModel.objects.filter(mydatefiled__lte=TruncDate(Now()) 
>>
>> Could it be useful to extend the Now function with native casts by 
>> leveraging database templates? I understand very well that extending the 
>> ORM also means maintaining all the parts of the code and backwards 
>> compatibility must be strongly guaranteed, and I share the approach of 
>> keeping it as minimal as possible. It is probably easier to override Now in 
>> your project when needed but I would like to hear your feedback on this.
>>
>> --
>> Matteo Vitali
>> https://trottomv.me
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/f462dc8a-b53f-4256-b024-2555793ea0f1n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/9c3f7df1-9df3-46d0-9af4-49663d04a3f6n%40googlegroups.com.


Re: Need help for my first Open Source Contribution.

2023-03-01 Thread Durval Carvalho


Hi Siddhiraj,

Welcome to the open-source community! It's great to see you interested in 
contributing to Django. Here are some suggestions on how to get started:

   1. 
   
   Check out the Django Contributing Guide: 
   https://docs.djangoproject.com/en/stable/internals/contributing/. This 
   guide provides an overview of the different ways you can contribute to 
   Django.
   2. 
   
   If you're looking to contribute code, take a look at the "Advice for New 
   Contributors" section in the guide: 
   
https://docs.djangoproject.com/en/stable/internals/contributing/new-contributors/.
 
   This section provides some helpful tips and best practices for getting 
   started.
   3. 
   
   You can also work through the "Writing Your First Patch" tutorial: 
   https://docs.djangoproject.com/en/stable/intro/contributing/. This 
   tutorial walks you through the process of contributing a patch to Django.
   4. 
   
   If you get stuck or have any questions, don't hesitate to post back in 
   the django-developers group or the "Mentorship" section on the forum: 
   https://forum.djangoproject.com/c/internals/mentorship/10.
   
I hope this helps you get started with your first contribution to Django. 
Good luck!

Em quinta-feira, 23 de fevereiro de 2023 às 11:49:21 UTC-3, Siddhiraj R 
Kolwankar escreveu:

> Helllo Everyone!
> Im Siddhiraj R Kolwankar.
> Currently I'm pursuing BE in Artificial Intelligence and Data Science from 
> Terna Engineering College.
> I have more than 2 years of experience in Backend Development. ( 
> Python/Django ).
> Im interested in Open Source Contribution but I don't know anything about 
> it. How to start and what things to follow and I want to contribute as a 
> developer. Can anyone help me for my first Open Source Contribution...?
>
> Thank you!
>
> Linktree: https://linktr.ee/siddhirajkolwankar
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/7614e8fa-ba94-484c-b747-f7d10aed7ab9n%40googlegroups.com.