Re: Proposal to add pre-commit

2020-11-08 Thread Carlton Gibson
I’d be +1 here. I’ve found pre-commit very useful on other projects. 

-- 
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/1e832a6f-82c5-43d8-a0cf-db7c950b7b42n%40googlegroups.com.


Made username validation configurable through AUTH_USERNAME_VALIDATORS setting

2020-11-08 Thread Shekhar Gyanwali


Hi Everyone,

First time contributor here, I have submitted PR 13114 
 for ticket 27807 
to allow customization of 
username validation through global setting similar to password validation.

 I would like to gather some feedback on my implementation/approach. I have 
added a new page under topics/auth for Username Validation to describe the 
solution(similar to password validation page).

Thanks to Carlton and Will, Django Podcast encouraged me to start looking 
into opensource contribution and to Jacob Walls who helped me a lot with 
the review.

Regards

Shekhar Gyanwali



-- 
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/231f0db8-e740-47e5-be31-b64c2620e709n%40googlegroups.com.


Re: Should a queryset avoid using a pk of a deleted object?

2020-11-08 Thread Carles Pina i Estany


Hi Jason,

On Nov/07/2020, Jason Johns wrote:
> Does https://code.djangoproject.com/ticket/22553 cover this case?  It was 
> closed as a documentation update with this commit in the docs: 
> https://github.com/django/django/pull/2974/files

Thanks very much for the links, it's a related case one could say but
not my case.

It says "If the data in the database might have changed, you can get
updated results for the same query by calling ``all()`` on a previously
evaluated ``QuerySet``."

It doesn't cover this case because the queryset has never been evaluated
yet in my case and the first time that the queryset is evaluated is
using a book.id that doesn't exist anymore. The original code:

```
author = Author.objects.create(name='James')
book = Book.objects.create(title='test')

book.authors.add(author)
book.save()

authors = book.authors.all() # No queryset evaluation

book.delete()   # book is deleted from the database

print(authors) # First time that the queryset is evaluated
   # and it uses a book.id that doesn't exist anymore[1]
```

The query launched:
SELECT `modeltest_author`.`id`, `modeltest_author`.`name` FROM 
`modeltest_author` INNER JOIN `modeltest_book_authors` ON 
(`modeltest_author`.`id` = `modeltest_book_authors`.`author_id`) WHERE 
`modeltest_book_authors`.`book_id` = 1 LIMIT 21

If using a field as a primary key, deleting the book, creating a new one
with the same primary key: it's possible to expect (depends on the user
experience) the first set of authors but get the new noe (with the same
primary key).

Thanks again for the pointers,

Carles


> 
> 
> >From your example, re-doing the book.authors.all() call will refresh the 
> queryset's cache.
> On Wednesday, November 4, 2020 at 5:51:36 AM UTC-5 Carles Pina Estany wrote:
> 
> >
> > Hi all,
> >
> > I have a question about Django ORM. I'd like to confirm that the current
> > behaviour is expected (in a way it is!) or find/open an issue if
> > needeed.
> >
> > In this example I've defined two models (see them at the end of the
> > email if needed): one for a Book with a ManyToMany to authors, and a
> > second model of Author.
> >
> > And code like this:
> > ```
> > author = Author.objects.create(name='James')
> > book = Book.objects.create(title='test')
> >
> > book.authors.add(author)
> > book.save()
> >
> > authors = book.authors.all()
> >
> > book.delete()
> >
> > print(authors) # should a user expect all the authors?
> > ```
> >
> > In the `print(authors)` line the book is already deleted and it returns
> > no authors. It executes an SQL query where at that point book.pk does
> > not exist. I think that technically it could return wrong existing data
> > if the book.pk had been reused, AFAIK none of the default database
> > backends would do this but I think that it could happen if doing a field
> > with primary_key=True.
> >
> > If the `authors = book.authors.all()` line was after the
> > `book.delete()`: Django raises a ValueError with the error message
> > ' needs to have a value for field "id" before this
> > many-to-many relationship can be used.'
> >
> > I understand why this happens. In some code I needed something along
> > these lines and I'm doing something like "authors =
> > list(book.authors.all())" to keep the list of authors, delete the book
> > and then do some actions in the authors.
> >
> > I think that this can be confusing. Also, Django prevents the error in
> > one case (get query set after the deletion) but not the other case
> > (execute the query after deletion).
> >
> > Fix idea:
> > If QuerySet was holding a book instance it could enforce that book.pk is
> > set at the time of running the query (or returning the result if the
> > result was cached?)
> >
> > I had a quick look at QuerySet and the book instance is in
> > self._hints['instance']. In `QuerySet._fetch_all` I could do something
> > along the lines of:
> > `
> > if 'instance' in self._hints and self._hints['instance'].pk is None:
> > raise ValueError('Object deleted')
> > `
> >
> > I guess that in
> > create_forward_many_to_many_manager.ManyRelatedManager.__init__ the book
> > instance could be saved in some variable in the QuerySet object (I guess
> > that self._hints['instance'] is not meant to be used like my example) to
> > check this when appropiate. Has this ever been considered? Or is the
> > behaviour as it is now good enough?
> >
> > Thank you very much,
> >
> > PS: Models used in the example:
> > ```
> > class Author(models.Model):
> > name = models.TextField(max_length=64)
> >
> > def __str__(self):
> > return self.name
> >
> >
> > class Book(models.Model):
> > title = models.TextField(max_length=128)
> > authors = models.ManyToManyField(Author)
> >
> > def __str__(self):
> > return self.title
> > ```
> >
> > -- 
> > Carles Pina i Estany
> > https://carles.pina.cat
> >
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers  (Contributions to Django itself)" group.
> To un

Re: Increasing support for Microsoft SQL Server

2020-11-08 Thread Carlton Gibson
HI Warren. 

Thanks for your mail. 

> 1 - How can we best collaborate?

I’d guess the best thing would be to communicate with the existing contributors 
and ask where resource would be best spent. 

I’m not mssql-server user myself, but first question I’d be asking is where is 
the backend not feature-equivalent to the backends in core? (I can’t tell you 
that I’m afraid.) A good test would be whether it passes the django test suite?

Kind Regards,

Carlton




> On 3 Nov 2020, at 21:50, Warren Chu  wrote:
> 
> Hi All,
> 
> Microsoft has commissioned internal resources, of which I'm a member, to 
> drive development and support of an open source Microsoft SQL Server backend 
> solution for Django. This project would exist under the github.com/microsoft 
> organization.
> 
> We recognize there is an existing and active project 
> [https://github.com/ESSolutions/django-mssql-backend], and we'd like to 
> solicit ideas and feedback from the Django community on the best way to 
> proceed.
> 
> Some initial questions we have are:
> 
> 1 - How can we best collaborate?
> 2 - What issues or challenges are most pressing to make MSSQL-Django work 
> better for you?
> 
> Thanks,
> Warren
> 
> -- 
> 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/25102379-5df3-4c55-a786-ac9acda20b13n%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/52921BEA-3ACE-4C49-995A-FD8F3597352C%40gmail.com.


Re: Welcome email

2020-11-08 Thread Carlton Gibson
Hi Tom and Andrew. 

This week has been busy (shall we say) I know — can I assume you two are on 
this between you, or is there anything I can do to facilitate progress here? 

Thanks. 
Carlton.

> On 30 Oct 2020, at 13:25, Tom Forbes  wrote:
> 
> The export finally finished after a whole day running.
> 
> The gzip compressed mbox: 
> https://www.icloud.com/iclouddrive/09XBHCr5L5BNcOBLob_HA2x6g 
> 
> The entire raw output from the tool: 
> https://www.icloud.com/iclouddrive/0LY_ccOgG6VjfV3INexGMXwZQ 
> 
> 
> We’ve got 56,282 total messages. I think the script from Discourse I linked 
> above would be the perfect way to import these as it creates the users on 
> demand and isn’t limited by the external Discourse API. I’ll leave that to 
> anyone who has access and is willing (Andrew?).
> 
> Tom
> 
> On 29 Oct 2020 at 16:43:07, Tom Forbes  > wrote:
> It actually might be simpler than I suggested. Discourse has a script to 
> import an mbox: 
> https://github.com/discourse/discourse/blob/master/script/import_scripts/mbox.rb
>  
> 
> 
> I’m running the box importer script now and it appears to work fine. While 
> some people might have historical mbox files, it might be better to get the 
> source of truth from Google Groups?
> 
> Tom
> 
> On 29 Oct 2020 at 16:11:04, Andrew Godwin  > wrote:
> I'd be more than happy to assist a trial of moving things to the forum; we've 
> had it running for over a year now, and I feel it's a much easier way to run 
> a community.
> 
> Among other things, we can:
> - Move posts to the right forum when they post in the wrong one (rather than 
> emailing back and saying "please post again over here")
> - Delete people's personal information when they accidentally post it
> - Remove CoC-violating posts and not leave any history
> 
> Either I can try the import out if someone pops the right permissions over to 
> me, or I'm happy to supervise enough forum API access for you to try it, Tom.
> 
> Andrew
> 
> On Thursday, October 29, 2020 at 9:23:45 AM UTC-6 carlton...@gmail.com 
>  wrote:
> I don’t have any controls here. I’m pretty sure Florian would be the most 
> likely candidate. (No doubt it’s Jacob.) 
> 
> 
> 
> -- 
> 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/44e041d6-9397-4a73-87a0-e4643c034db0n%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/CAFNZOJOAVFTNe%2BdJBjoJ8MWChswmLAZiGzqRPmPKYuVwuMqqiw%40mail.gmail.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/CF8FD1E3-9E28-4BBF-9C77-880817A7A576%40gmail.com.


Re: Welcome email

2020-11-08 Thread Andrew Godwin
I have been moving house this week (plus, yknow, the election) so I haven't got 
anything done, but hope to poke at it early next week!

Andrew

On Sun, Nov 8, 2020, at 4:34 AM, Carlton Gibson wrote:
> Hi Tom and Andrew. 
> 
> This week has been *busy *(shall we say) I know — can I assume you two are on 
> this between you, or is there anything I can do to facilitate progress here? 
> 
> Thanks. 
> Carlton.
> 
>> On 30 Oct 2020, at 13:25, Tom Forbes  wrote:
>> 
>> The export finally finished after a whole day running.
>> 
>> The gzip compressed mbox: 
>> https://www.icloud.com/iclouddrive/09XBHCr5L5BNcOBLob_HA2x6g 
>> 
>> The entire raw output from the tool: 
>> https://www.icloud.com/iclouddrive/0LY_ccOgG6VjfV3INexGMXwZQ 
>> 
>> 
>> We’ve got 56,282 total messages. I think the script from Discourse I linked 
>> above would be the perfect way to import these as it creates the users on 
>> demand and isn’t limited by the external Discourse API. I’ll leave that to 
>> anyone who has access and is willing (Andrew?).
>> 
>> Tom
>> 
>> On 29 Oct 2020 at 16:43:07, Tom Forbes  wrote:
>>> It actually might be simpler than I suggested. Discourse has a script to 
>>> import an mbox: 
>>> https://github.com/discourse/discourse/blob/master/script/import_scripts/mbox.rb
>>> 
>>> I’m running the box importer script now and it appears to work fine. While 
>>> some people might have historical mbox files, it might be better to get the 
>>> source of truth from Google Groups?
>>> 
>>> Tom
>>> 
>>> 
>>> On 29 Oct 2020 at 16:11:04, Andrew Godwin  wrote:
 I'd be more than happy to assist a trial of moving things to the forum; 
 we've had it running for over a year now, and I feel it's a much easier 
 way to run a community.
 
 Among other things, we can:
 - Move posts to the right forum when they post in the wrong one (rather 
 than emailing back and saying "please post again over here")
 - Delete people's personal information when they accidentally post it
 - Remove CoC-violating posts and not leave any history
 
 Either I can try the import out if someone pops the right permissions over 
 to me, or I'm happy to supervise enough forum API access for you to try 
 it, Tom.
 
 Andrew
 On Thursday, October 29, 2020 at 9:23:45 AM UTC-6 carlton...@gmail.com 
 wrote:
> I don’t have any controls here. I’m pretty sure Florian would be the most 
> likely candidate. (No doubt it’s Jacob.) 
> 
> 
 
 -- 
 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/44e041d6-9397-4a73-87a0-e4643c034db0n%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/CAFNZOJOAVFTNe%2BdJBjoJ8MWChswmLAZiGzqRPmPKYuVwuMqqiw%40mail.gmail.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/CF8FD1E3-9E28-4BBF-9C77-880817A7A576%40gmail.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/6c289804-7c7e-49e3-ace0-6e087586f1a6%40www.fastmail.com.