Re: [Django] #33037: TruncDay error when using offset timezones on MySQL

2021-08-24 Thread Django
#33037: TruncDay error when using offset timezones on MySQL
-+-
 Reporter:  Alan |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  mysql truncdate  | Triage Stage:
  timezone   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * resolution:  duplicate => invalid


Comment:

 `+3` and `-3` (after fixing #32992) both works for me on MySQL. Your issue
 is probably caused by [https://docs.djangoproject.com/en/3.2/ref/databases
 /#time-zone-definitions an empty time zone table in the MySQL database]
 (see also a [https://docs.djangoproject.com/en/3.2/ref/models/querysets
 /#database-time-zone-definitions warning]).

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.0d6ce794120e80f723bd2a8b4ad382e1%40djangoproject.com.


Re: [Django] #33053: How do I get List of values from django form template to form.py Cleaned_data

2021-08-24 Thread Django
#33053: How do I get List of values from django form template to form.py
Cleaned_data
---+--
 Reporter:  Gurveer Singh  |Owner:  nobody
 Type:  Bug|   Status:  closed
Component:  Forms  |  Version:  3.2
 Severity:  Normal |   Resolution:  invalid
 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 Tim Graham):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Please see TicketClosingReasons/UseSupportChannels for ways to get help
 with usage questions. Thanks!

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/070.2c77fac72386d59e03a5e8e9c601c4cb%40djangoproject.com.


Re: [Django] #32992: Reverse time zone conversion in Trunc()/Extract() database functions.

2021-08-24 Thread Django
#32992: Reverse time zone conversion in Trunc()/Extract() database functions.
-+-
 Reporter:  James Beith  |Owner:  Carlton
 |  Gibson
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 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 James Beith):

 This fixes the original issue I encountered, thanks!

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.1ac9239db47844c123cf61de5af29bf2%40djangoproject.com.


Re: [Django] #33053: How do I get List of values from django form template to form.py Cleaned_data

2021-08-24 Thread Django
#33053: How do I get List of values from django form template to form.py
Cleaned_data
---+--
 Reporter:  Gurveer Singh  |Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Forms  |  Version:  3.2
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Description changed by Gurveer Singh:

Old description:

> I am actually try to post a list of values ['good','nice','happy'] to the
> backend.
>
> I have following files in my django app.
>

>
> {{{
> models.py
> class TagModel(models.Model):
> name = models.CharField(max_length=255)
>
> class BlogModel(models.Model):
>   title = models.CharField(max_length=255)
>   tags = models.ManyToManyField(TagModel)
> }}}
>
> 
>
> {{{
>
> forms.py
> class BlogForm(forms.ModelForm):
> title = forms.CharField(widget=forms.TextInput(attrs={
> 'placeholder':_('Enter Blog Title'),
> 'class' : 'form-control border-success'
> }))
>  blog_tags = forms.ChoiceField(widget=forms.TextInput(attrs={
> "name":"blog_tags"
> }))
>
> def clean_title(self):
> title = self.cleaned_data.get('title')
> print(title)
> return title
>
> def clean_blog_tags(self):
> //this line does not get whole list of data
> tags = self.cleaned_data.get('blog_tags')
> print(tags) // problem is here
> return tags
>
> class Meta:
> model = PostModel
> fields = ['title','blog_tags']
> views.py
> class create_blog(CreateView):
> template_name = 'blogbackend/create_blog.html'
> form_class=BlogForm
>
>  def get_form_kwargs(self):
> kwargs = super(create_blog,self).get_form_kwargs()
> print(kwargs)
> return kwargs
> }}}
>
> Html Template
> [[Image('https://i.stack.imgur.com/lzqxO.jpg')]]
>
> What happen on template is :-
>
> I render the title field on the view
>
> I added a JS code on Input box , which gets value a create a hidden input
> with name blog_tags
>
> {{{
> 
> }}}
>

> which is same as the filed name in forms.py file
>
> After user submit the form
>
> I successfully receives the both input values title and blog_tags in my
> views.py file and successfully display on console with helper function
> get_form_kwargs()
>
> Data is look like this
>
> {{{
>
>  {'initial': {}, 'prefix': None, 'data':   {'csrfmiddlewaretoken':
> ['4Cm5mvGFv4skPJNTzRI8fKZKq9i7edQbwNmOgCPbDTtu8JQHqE5cd9rQLA8Kzhpu'],'title':
> ['first'],'blog_tags' : ['good','nice','happy']}>, 'instance':None}
> }}}
>

> Problem
>
> When I am trying to access the value inside function clean_blog_tags() it
> only prints list value "happy" on console
> could anyone please help me to get whole list of values in clean function
>
> Thanks GS

New description:

 I am actually try to post a list of values ['good','nice','happy'] to the
 backend.

 I have following files in my django app.



 {{{
 models.py
 class TagModel(models.Model):
 name = models.CharField(max_length=255)

 class BlogModel(models.Model):
   title = models.CharField(max_length=255)
   tags = models.ManyToManyField(TagModel)
 }}}

 

 {{{

 forms.py
 class BlogForm(forms.ModelForm):
 title = forms.CharField(widget=forms.TextInput(attrs={
 'placeholder':_('Enter Blog Title'),
 'class' : 'form-control border-success'
 }))
  blog_tags = forms.ChoiceField(widget=forms.TextInput(attrs={
 "name":"blog_tags"
 }))

 def clean_title(self):
 title = self.cleaned_data.get('title')
 print(title)
 return title

 def clean_blog_tags(self):
 //this line does not get whole list of data
 tags = self.cleaned_data.get('blog_tags')
 print(tags) // problem is here
 return tags

 class Meta:
 model = PostModel
 fields = ['title','blog_tags']
 views.py
 class create_blog(CreateView):
 template_name = 'blogbackend/create_blog.html'
 form_class=BlogForm

  def get_form_kwargs(self):
 kwargs = super(create_blog,self).get_form_kwargs()
 print(kwargs)
 return kwargs
 }}}

 Html Template
 [[Image('https://i.stack.imgur.com/lzqxO.jpg')]]

 What happen on template is :-

 I render the title field on the view

 I added a JS code on a Input box , which gets the value of input box and
 creates a hidden input with entered value and name blog_tags every time
 when user hit enter

 {{{
 
 }}}


 which is same as the filed name in forms.py file

 After user submit the form

 I successfully receives the both input values title and blog_tags in my
 views.py file and successfully display on console with helper function
 get_form_kwargs()

 Data is look like this

 {{{

  {'initial': {}, 'prefix': None, 'data': , 

Re: [Django] #33053: How do I get List of values from django form template to form.py Cleaned_data

2021-08-24 Thread Django
#33053: How do I get List of values from django form template to form.py
Cleaned_data
---+--
 Reporter:  Gurveer Singh  |Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Forms  |  Version:  3.2
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Description changed by Gurveer Singh:

Old description:

> I am actually try to post a list of values ['good','nice','happy'] to the
> backend.
>
> I have following files in my django app.
>

>
> {{{
> models.py
> class TagModel(models.Model):
> name = models.CharField(max_length=255)
>
> class BlogModel(models.Model):
>   title = models.CharField(max_length=255)
>   tags = models.ManyToManyField(TagModel)
> }}}
>
> 
>
> {{{
>
> forms.py
> class BlogForm(forms.ModelForm):
> title = forms.CharField(widget=forms.TextInput(attrs={
> 'placeholder':_('Enter Blog Title'),
> 'class' : 'form-control border-success'
> }))
>  blog_tags = forms.ChoiceField(widget=forms.TextInput(attrs={
> "name":"blog_tags"
> }))
>
> def clean_title(self):
> title = self.cleaned_data.get('title')
> print(title)
> return title
>
> def clean_blog_tags(self):
> //this line does not get whole list of data
> tags = self.cleaned_data.get('blog_tags')
> print(tags) // problem is here
> return tags
>
> class Meta:
> model = PostModel
> fields = ['title','blog_tags']
> views.py
> class create_blog(CreateView):
> template_name = 'blogbackend/create_blog.html'
> form_class=BlogForm
>
>  def get_form_kwargs(self):
> kwargs = super(create_blog,self).get_form_kwargs()
> print(kwargs)
> return kwargs
> }}}
>
> Html Template
> [[Image('https://i.stack.imgur.com/lzqxO.jpg')]]
>
> What happen on template is :-
>
> I render the title field on the view
>
> I added a JS code on Input box , which gets value a create a hidden input
> with name blog_tags
>
> which is same as the filed name in forms.py file
>
> After user submit the form
>
> I successfully receives the both input values title and blog_tags in my
> views.py file and successfully display on console with helper function
> get_form_kwargs()
>
> Data is look like this
>
> {{{
>
>  {'initial': {}, 'prefix': None, 'data':   {'csrfmiddlewaretoken':
> ['4Cm5mvGFv4skPJNTzRI8fKZKq9i7edQbwNmOgCPbDTtu8JQHqE5cd9rQLA8Kzhpu'],'title':
> ['first'],'blog_tags' : ['good','nice','happy']}>, 'instance':None}
> }}}
>

> Problem
>
> When I am trying to access the value inside function clean_blog_tags() it
> only prints list value "happy" on console
> could anyone please help me to get whole list of values in clean function
>
> Thanks GS

New description:

 I am actually try to post a list of values ['good','nice','happy'] to the
 backend.

 I have following files in my django app.



 {{{
 models.py
 class TagModel(models.Model):
 name = models.CharField(max_length=255)

 class BlogModel(models.Model):
   title = models.CharField(max_length=255)
   tags = models.ManyToManyField(TagModel)
 }}}

 

 {{{

 forms.py
 class BlogForm(forms.ModelForm):
 title = forms.CharField(widget=forms.TextInput(attrs={
 'placeholder':_('Enter Blog Title'),
 'class' : 'form-control border-success'
 }))
  blog_tags = forms.ChoiceField(widget=forms.TextInput(attrs={
 "name":"blog_tags"
 }))

 def clean_title(self):
 title = self.cleaned_data.get('title')
 print(title)
 return title

 def clean_blog_tags(self):
 //this line does not get whole list of data
 tags = self.cleaned_data.get('blog_tags')
 print(tags) // problem is here
 return tags

 class Meta:
 model = PostModel
 fields = ['title','blog_tags']
 views.py
 class create_blog(CreateView):
 template_name = 'blogbackend/create_blog.html'
 form_class=BlogForm

  def get_form_kwargs(self):
 kwargs = super(create_blog,self).get_form_kwargs()
 print(kwargs)
 return kwargs
 }}}

 Html Template
 [[Image('https://i.stack.imgur.com/lzqxO.jpg')]]

 What happen on template is :-

 I render the title field on the view

 I added a JS code on Input box , which gets value a create a hidden input
 with name blog_tags

 {{{
 
 }}}


 which is same as the filed name in forms.py file

 After user submit the form

 I successfully receives the both input values title and blog_tags in my
 views.py file and successfully display on console with helper function
 get_form_kwargs()

 Data is look like this

 {{{

  {'initial': {}, 'prefix': None, 'data': , 'instance':None}
 }}}


 Problem

 When I am trying to access the value inside function 

Re: [Django] #33053: How do I get List of values from django form template to form.py Cleaned_data

2021-08-24 Thread Django
#33053: How do I get List of values from django form template to form.py
Cleaned_data
--+--
 Reporter:  GurveerSaini  |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  Forms |  Version:  3.2
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Description changed by GurveerSaini:

Old description:

> I am actually try to post a list of values ['good','nice','happy'] to the
> backend.
>
> I have following files in my django app.
>

>
> {{{
> models.py
> class TagModel(models.Model):
> name = models.CharField(max_length=255)
>
> class BlogModel(models.Model):
>   title = models.CharField(max_length=255)
>   tags = models.ManyToManyField(TagModel)
> }}}
>
> 
>
> {{{
>
> forms.py
> class BlogForm(forms.ModelForm):
> title = forms.CharField(widget=forms.TextInput(attrs={
> 'placeholder':_('Enter Blog Title'),
> 'class' : 'form-control border-success'
> }))
>  blog_tags = forms.ChoiceField(widget=forms.TextInput(attrs={
> "name":"blog_tags"
> }))
>
> def clean_title(self):
> title = self.cleaned_data.get('title')
> print(title)
> return title
>
> def clean_blog_tags(self):
> //this line does not get whole list of data
> tags = self.cleaned_data.get('blog_tags')
> print(tags) // problem is here
> return tags
>
> class Meta:
> model = PostModel
> fields = ['title','blog_tags']
> views.py
> class create_blog(CreateView):
> template_name = 'blogbackend/create_blog.html'
> form_class=BlogForm
>
>  def get_form_kwargs(self):
> kwargs = super(create_blog,self).get_form_kwargs()
> print(kwargs)
> return kwargs
> }}}
>
> Html Template
> [[Image(https://i.stack.imgur.com/lzqxO.jpg)]]
>
> What happen on template is :-
>
> I render the title field on the view
>
> I added a JS code on Input box , which gets value a create a hidden input
> with name blog_tags
>
> which is same as the filed name in forms.py file
>
> After user submit the form
>
> I successfully receives the both input values title and blog_tags in my
> views.py file and successfully display on console with helper function
> get_form_kwargs()
>
> Data is look like this
>
> {{{
>
>  {'initial': {}, 'prefix': None, 'data':   {'csrfmiddlewaretoken':
> ['4Cm5mvGFv4skPJNTzRI8fKZKq9i7edQbwNmOgCPbDTtu8JQHqE5cd9rQLA8Kzhpu'],'title':
> ['first'],'blog_tags' : ['good','nice','happy']}>, 'instance':None}
> }}}
>

> Problem
>
> When I am trying to access the value inside function clean_blog_tags() it
> only prints list value "happy" on console
> could anyone please help me to get whole list of values in clean function
>
> Thanks GS

New description:

 I am actually try to post a list of values ['good','nice','happy'] to the
 backend.

 I have following files in my django app.



 {{{
 models.py
 class TagModel(models.Model):
 name = models.CharField(max_length=255)

 class BlogModel(models.Model):
   title = models.CharField(max_length=255)
   tags = models.ManyToManyField(TagModel)
 }}}

 

 {{{

 forms.py
 class BlogForm(forms.ModelForm):
 title = forms.CharField(widget=forms.TextInput(attrs={
 'placeholder':_('Enter Blog Title'),
 'class' : 'form-control border-success'
 }))
  blog_tags = forms.ChoiceField(widget=forms.TextInput(attrs={
 "name":"blog_tags"
 }))

 def clean_title(self):
 title = self.cleaned_data.get('title')
 print(title)
 return title

 def clean_blog_tags(self):
 //this line does not get whole list of data
 tags = self.cleaned_data.get('blog_tags')
 print(tags) // problem is here
 return tags

 class Meta:
 model = PostModel
 fields = ['title','blog_tags']
 views.py
 class create_blog(CreateView):
 template_name = 'blogbackend/create_blog.html'
 form_class=BlogForm

  def get_form_kwargs(self):
 kwargs = super(create_blog,self).get_form_kwargs()
 print(kwargs)
 return kwargs
 }}}

 Html Template
 [[Image('https://i.stack.imgur.com/lzqxO.jpg')]]

 What happen on template is :-

 I render the title field on the view

 I added a JS code on Input box , which gets value a create a hidden input
 with name blog_tags

 which is same as the filed name in forms.py file

 After user submit the form

 I successfully receives the both input values title and blog_tags in my
 views.py file and successfully display on console with helper function
 get_form_kwargs()

 Data is look like this

 {{{

  {'initial': {}, 'prefix': None, 'data': , 'instance':None}
 }}}


 Problem

 When I am trying to access the value inside function clean_blog_tags() it
 only prints list 

[Django] #33053: How do I get List of values from django form template to form.py Cleaned_data

2021-08-24 Thread Django
#33053: How do I get List of values from django form template to form.py
Cleaned_data
+
   Reporter:  GurveerSaini  |  Owner:  nobody
   Type:  Bug   | Status:  new
  Component:  Forms |Version:  3.2
   Severity:  Normal|   Keywords:
   Triage Stage:  Unreviewed|  Has patch:  0
Needs documentation:  0 |Needs tests:  0
Patch needs improvement:  0 |  Easy pickings:  0
  UI/UX:  0 |
+
 I am actually try to post a list of values ['good','nice','happy'] to the
 backend.

 I have following files in my django app.



 {{{
 models.py
 class TagModel(models.Model):
 name = models.CharField(max_length=255)

 class BlogModel(models.Model):
   title = models.CharField(max_length=255)
   tags = models.ManyToManyField(TagModel)
 }}}

 

 {{{

 forms.py
 class BlogForm(forms.ModelForm):
 title = forms.CharField(widget=forms.TextInput(attrs={
 'placeholder':_('Enter Blog Title'),
 'class' : 'form-control border-success'
 }))
  blog_tags = forms.ChoiceField(widget=forms.TextInput(attrs={
 "name":"blog_tags"
 }))

 def clean_title(self):
 title = self.cleaned_data.get('title')
 print(title)
 return title

 def clean_blog_tags(self):
 //this line does not get whole list of data
 tags = self.cleaned_data.get('blog_tags')
 print(tags) // problem is here
 return tags

 class Meta:
 model = PostModel
 fields = ['title','blog_tags']
 views.py
 class create_blog(CreateView):
 template_name = 'blogbackend/create_blog.html'
 form_class=BlogForm

  def get_form_kwargs(self):
 kwargs = super(create_blog,self).get_form_kwargs()
 print(kwargs)
 return kwargs
 }}}

 Html Template
 [[Image(https://i.stack.imgur.com/lzqxO.jpg)]]

 What happen on template is :-

 I render the title field on the view

 I added a JS code on Input box , which gets value a create a hidden input
 with name blog_tags

 which is same as the filed name in forms.py file

 After user submit the form

 I successfully receives the both input values title and blog_tags in my
 views.py file and successfully display on console with helper function
 get_form_kwargs()

 Data is look like this

 {{{

  {'initial': {}, 'prefix': None, 'data': , 'instance':None}
 }}}


 Problem

 When I am trying to access the value inside function clean_blog_tags() it
 only prints list value "happy" on console
 could anyone please help me to get whole list of values in clean function

 Thanks GS

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/055.42cba91a53fc1ea65870c96e4a333473%40djangoproject.com.


Re: [Django] #32797: model_ngettext incorrectly tries to translate already translated words

2021-08-24 Thread Django
#32797: model_ngettext incorrectly tries to translate already translated words
-+-
 Reporter:  Maciej Olko  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  3.2
 Severity:  Normal   |   Resolution:
 Keywords:  i18n, gettext,   | Triage Stage:  Accepted
  ngettext   |
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  1
-+-

Comment (by Maciej Olko):

 Hi Carlton,

 I've added a test – sorry for my low response rate.

 Technically we can fix those missing plural forms without touching
 `model_ngettext()` function. We can also "just" simplify it as I mentioned
 previously.

 Nevertheless I am proposing removal of `model_ngettext()` function.
 * The pluralization should happen on message level, not on a parameter
 level (as for `object_name`), please refer to [1] [2].
 * Moreover the function implementation is broken. Internal `ngettext()`
 call is using already translated messages and even if we fix that, there
 will be no translations for the calls in messages catalog (we are missing
 so-called gettext noops for plurals of verbose names). Please let me know
 if I should elaborate more on that.

 Thanks.

 PS. I plan to publish proposals, I think in a form of DEPs, about
 admin/Django internationalization – first one about bringing verbose
 names' grammatical gender for inflection in parametrized messages, and
 second one about adding an ability to select a verbose name grammatical
 case inside translated messages. The selection of variable in a message,
 like proposed in my PR potentially is required by the proposed
 implementation of the second of those DEPs.

 [1] https://github.com/projectfluent/fluent/wiki/Good-Practices-for-
 Developers#prefer-wet-over-dry
 [2] https://code.djangoproject.com/ticket/11688#comment:21

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.cdc4302c3ec7767deb67bdb3fa8bc351%40djangoproject.com.


Re: [Django] #33022: main-random test failures (build #8): field_deconstruction.tests.FieldDeconstructionTests and migrations.test_commands.MigrateTests

2021-08-24 Thread Django
#33022: main-random test failures (build #8):
field_deconstruction.tests.FieldDeconstructionTests and
migrations.test_commands.MigrateTests
+
 Reporter:  Chris Jerdonek  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  dev
 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
+

Comment (by Chris Jerdonek):

 > Can be produced with:

 FYI, once you have specific tests to reproduce with, you can dispense with
 the `--shuffle` argument and just provide the order manually (not needing
 `-k`, etc):

 {{{
 ./tests/runtests.py
 migrations.test_executor.ExecutorTests.test_custom_user
 
migrations.test_commands.MigrateTests.test_migrate_partially_applied_squashed_migration
 }}}

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.09328e6e9c495d709f6c8ae9ea13bb84%40djangoproject.com.


Re: [Django] #33051: Model names with special characters don't highlight in admin site

2021-08-24 Thread Django
#33051: Model names with special characters don't highlight in admin site
--+
 Reporter:  ꯸ ꬰ ꝛ⼻ↇ |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.admin |  Version:  3.2
 Severity:  Normal|   Resolution:
 Keywords:  accents, unicode  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Matthias Kestenholz):

 I have never used model names with umlauts or accents; I knew that Python
 3 supports using unicode codepoints in class names too but I've never had
 a reason for using anything but `[A-Za-z0-9_]` when naming Django model
 classes (or any Python identifiers, for that matter)

 I don't know that area of the Django admin very well but the fix looks
 correct to me. At least if Django even wants to support umlauts/accents in
 model names (and therefore also database table names, maybe?) at all.

 `request.path` only exists in the `admin/app_list.html` template in
 `django/contrib/admin/templates/` so I'd assume that the proposed patch
 fixes this problem.

 TLDR: LGTM but I wouldn't ever use accents or umlauts in class names.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.dc7602a4fee147858e1864836b129fe1%40djangoproject.com.


Re: [Django] #26142: Provide a way for model formsets to disallow new object creation

2021-08-24 Thread Django
#26142: Provide a way for model formsets to disallow new object creation
-+
 Reporter:  Tim Graham   |Owner:  Vlad
 Type:  New feature  |   Status:  assigned
Component:  Forms|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  1|UI/UX:  0
-+
Changes (by Jacob Walls):

 * needs_better_patch:  0 => 1


Comment:

 I agree with [https://github.com/django/django/pull/14725/files#r690721475
 David's suggestion] to include the new argument in
 `modelformset_factory()`.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.09ca19420c3b9a176e145a581cd32203%40djangoproject.com.


Re: [Django] #33051: Model names with special characters don't highlight in admin site

2021-08-24 Thread Django
#33051: Model names with special characters don't highlight in admin site
--+
 Reporter:  ꯸ ꬰ ꝛ⼻ↇ |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.admin |  Version:  3.2
 Severity:  Normal|   Resolution:
 Keywords:  accents, unicode  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Mariusz Felisiak):

 * cc: Tom Carrick, Matthias Kestenholz (added)
 * stage:  Unreviewed => Accepted


Comment:

 Thanks for the report! Adding `urlencode` fixes this issue for me:
 {{{
 diff --git a/django/contrib/admin/templates/admin/app_list.html
 b/django/contrib/admin/templates/admin/app_list.html
 index ea4a85bd0b..e7517ea698 100644
 --- a/django/contrib/admin/templates/admin/app_list.html
 +++ b/django/contrib/admin/templates/admin/app_list.html
 @@ -2,15 +2,15 @@

  {% if app_list %}
{% for app in app_list %}
 -
 +

  
{{ app.name }}
  
  {% for model in app.models %}
 -  
 +
  {% if model.admin_url %}
 -  {{
 model.name }}
 +  {{ model.name }}
  {% else %}
{{ model.name }}
  {% endif %}
 }}}

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.ce5065fe873995f4bbb97a335f2d4b4c%40djangoproject.com.


Re: [Django] #33022: main-random test failures (build #8): field_deconstruction.tests.FieldDeconstructionTests and migrations.test_commands.MigrateTests

2021-08-24 Thread Django
#33022: main-random test failures (build #8):
field_deconstruction.tests.FieldDeconstructionTests and
migrations.test_commands.MigrateTests
+
 Reporter:  Chris Jerdonek  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  dev
 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
+

Comment (by Jacob Walls):

 Reiterating from above PR:

 The pair of migrations tests that produces a failure is:
 - `test_custom_user`
 - `test_migrate_partially_applied_squashed_migration`

 Can be produced with:
 {{{
 ./tests/runtests.py migrations.test_commands.MigrateTests
 migrations.test_executor.ExecutorTests -k test_custom_user -k
 test_migrate_partially --shuffle 1022528553
 }}}

 The failure occurs during the `migrate` (to zero) command in the `finally`
 block with:

 {{{
 raise ValueError("\n".join(error.msg for error in errors))
 ValueError: The field migrations.Book.author was declared with a lazy
 reference to 'auth.user', but app 'auth' isn't installed.
 }}}

 `test_custom_user` overrides the `AUTH_USER_MODEL` setting like so:
 {{{
 AUTH_USER_MODEL="migrations.Author",
 }}}

 [https://docs.djangoproject.com/en/3.2/topics/auth/customizing/#changing-
 to-a-custom-user-model-mid-project Documentation] for the setting says
 that it's cumbersome to change this after migrations have been made:

 > Changing AUTH_USER_MODEL after you’ve created database tables is
 significantly more difficult since it affects foreign keys and many-to-
 many relationships, for example. This change can’t be done automatically
 and requires manually fixing your schema, moving your data from the old
 user table, and possibly manually reapplying some migrations. See #25313
 for an outline of the steps.

 This makes sense, because in the ordinary test execution order, the
 squashed migration in `test_migrate_partially_applied_squashed_migration `
 creates a `Book.Author` field like this:

 `('author', models.ForeignKey(null=True,
 on_delete=django.db.models.deletion.SET_NULL, to='migrations.author')),`

 But in the failing test order, instead creates this:

 `('author', models.ForeignKey(null=True,
 on_delete=django.db.models.deletion.SET_NULL,
 to=settings.AUTH_USER_MODEL)),`

 Since the documentation mentions this is cumbersome to address, the
 thought in the PR was just to keep all tests running on the app
 "migrations" with the same `AUTH_USER_MODEL`, but if that's not
 satisfactory, is the idea that we should rewrite
 `test_migrate_partially_applied_squashed_migration` to use a different app
 to run the test cases? Otherwise I'm not sure how to prevent
 `squashmigrations` from picking up the swappable user model.

 Thanks, and happy to keep digging if helpful.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.371e578bda0b83920ef923f240ef2ce2%40djangoproject.com.


Re: [Django] #33052: save() on object with pk with default and existing value results in error and not update. (was: calling save on object with p_key as UUIDField and value already present in db resu

2021-08-24 Thread Django
#33052: save() on object with pk with default and existing value results in 
error
and not update.
-+-
 Reporter:  Vikash Singh |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.74f780988f33bc7b9b474a22751383ab%40djangoproject.com.


Re: [Django] #33052: calling save on object with p_key as UUIDField and value already present in db results in error and not update

2021-08-24 Thread Django
#33052: calling save on object with p_key as UUIDField and value already 
present in
db results in error and not update
-+-
 Reporter:  Vikash Singh |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  wontfix
 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 Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 This is an intended and
 [https://docs.djangoproject.com/en/stable/releases/3.0/#model-save-when-
 providing-a-default-for-the-primary-key documented] change in the previous
 behavior.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.beb879bb593e09cdf830330fbe58aa7a%40djangoproject.com.


Re: [Django] #33049: TabularInline doesn't render properly MultiPolygonField in Django Admin

2021-08-24 Thread Django
#33049: TabularInline doesn't render properly MultiPolygonField in Django Admin
-+-
 Reporter:  Vladyslav Krylasov   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  GIS  |  Version:  2.2
 Severity:  Normal   |   Resolution:  duplicate
 Keywords:  gis, admin,  | Triage Stage:
  MultiPolygonField, TabularInline   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  1
-+-
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * needs_docs:  1 => 0
 * resolution:   => duplicate
 * needs_tests:  1 => 0
 * type:  Uncategorized => Bug


Comment:

 Have you tried to use `ModelAdmin` instead of `GeoModelAdmin`? It seems to
 be a duplicate of #16417.

 Moreover, we're going to deprecate `GeoModelAdmin` and `OSMGeoAdmin`
 (probably in Django 4.0), see #27674.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/070.53463c5a150721cf8ff949afe1b93eaf%40djangoproject.com.


Re: [Django] #33052: calling save on object with p_key as UUIDField and value already present in db results in error and not update

2021-08-24 Thread Django
#33052: calling save on object with p_key as UUIDField and value already 
present in
db results in error and not update
-+-
 Reporter:  Vikash Singh |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 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 Vikash Singh):

 * cc: Vikash Singh (added)


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.bb0d8bb1d3172e2de0b5c25fc1337e3e%40djangoproject.com.


[Django] #33052: calling save on object with p_key as UUIDField and value already present in db results in error and not update

2021-08-24 Thread Django
#33052: calling save on object with p_key as UUIDField and value already 
present in
db results in error and not update
-+-
   Reporter:  Vikash |  Owner:  nobody
  Singh  |
   Type:  Bug| Status:  new
  Component:  Database   |Version:  3.2
  layer (models, ORM)|
   Severity:  Normal |   Keywords:
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 [https://github.com/django/django/blob/main/tests/basic/tests.py file with
 Test case]
 {{{
 # This test case works fine.
 def test_save_primary_with_default(self):
 # An UPDATE attempt is skipped when a primary key has default.
 with self.assertNumQueries(1):
 PrimaryKeyWithDefault().save()

 # This new test case fails.
 def test_update_primary_with_default(self):
 obj = PrimaryKeyWithDefault()
 obj.save()
 obj_2 = PrimaryKeyWithDefault(uuid=obj.uuid)
 obj_2.save()
 }}}

 Error stack trace:

 {{{
 Traceback (most recent call last):
   File "/Users/vikash/Documents/django3.2/tests/basic/tests.py", line 165,
 in test_update_primary_with_default
 obj_2.save()
   File "/Users/vikash/Documents/django3.2/django/db/models/base.py", line
 802, in save
 self.save_base(
   File "/Users/vikash/Documents/django3.2/django/db/models/base.py", line
 853, in save_base
 updated = self._save_table(
   File "/Users/vikash/Documents/django3.2/django/db/models/base.py", line
 1006, in _save_table
 results = self._do_insert(
   File "/Users/vikash/Documents/django3.2/django/db/models/base.py", line
 1047, in _do_insert
 return manager._insert(
   File "/Users/vikash/Documents/django3.2/django/db/models/manager.py",
 line 85, in manager_method
 return getattr(self.get_queryset(), name)(*args, **kwargs)
   File "/Users/vikash/Documents/django3.2/django/db/models/query.py", line
 1426, in _insert
 return query.get_compiler(using=using).execute_sql(returning_fields)
   File
 "/Users/vikash/Documents/django3.2/django/db/models/sql/compiler.py", line
 1630, in execute_sql
 cursor.execute(sql, params)
   File "/Users/vikash/Documents/django3.2/django/db/backends/utils.py",
 line 66, in execute
 return self._execute_with_wrappers(
   File "/Users/vikash/Documents/django3.2/django/db/backends/utils.py",
 line 79, in _execute_with_wrappers
 return executor(sql, params, many, context)
   File "/Users/vikash/Documents/django3.2/django/db/backends/utils.py",
 line 92, in _execute
 return self.cursor.execute(sql, params)
   File "/Users/vikash/Documents/django3.2/django/db/utils.py", line 90, in
 __exit__
 raise dj_exc_value.with_traceback(traceback) from exc_value
   File "/Users/vikash/Documents/django3.2/django/db/backends/utils.py",
 line 92, in _execute
 return self.cursor.execute(sql, params)
   File
 "/Users/vikash/Documents/django3.2/django/db/backends/mysql/base.py", line
 73, in execute
 return self.cursor.execute(query, args)
   File "/Users/vikash/.virtualenvs/django3.2/lib/python3.9/site-
 packages/MySQLdb/cursors.py", line 206, in execute
 res = self._query(query)
   File "/Users/vikash/.virtualenvs/django3.2/lib/python3.9/site-
 packages/MySQLdb/cursors.py", line 319, in _query
 db.query(q)
   File "/Users/vikash/.virtualenvs/django3.2/lib/python3.9/site-
 packages/MySQLdb/connections.py", line 259, in query
 _mysql.connection.query(self, query)
 django.db.utils.IntegrityError: (1062, "Duplicate entry
 '3023cab946d44309a1bdfa8237705ee7' for key
 'basic_primarykeywithdefault.PRIMARY'")
 }}}




 A workaround is present if we fetch the entry from the db first and then
 update the values and save it.

 Another workaround is to set the value of _state.adding as False.
 {{{
 # This new test case passes.
 def test_update_primary_with_default(self):
 obj = PrimaryKeyWithDefault()
 obj.save()
 obj_2 = PrimaryKeyWithDefault(uuid=obj.uuid)
 obj_2._state.adding = False
 obj_2.save()
 }}}

 before calling save on it.

 This issue is not present in django version = 2.2. The error occurs
 because additional check was introduced in
 
[https://github.com/django/django/commit/85458e94e38c20e57939947ee515a1a53689659f
 commit] to resolve [https://code.djangoproject.com/ticket/29260 ticket].

 Django test suit has a bunch of tests
 [https://github.com/django/django/blob/stable/3.2.x/tests/empty/tests.py
 Example_1],
 
[https://github.com/django/django/blob/ca9872905559026af82000e46cde6f7dedc897b6/tests/view_tests/tests/test_defaults.py#L43
 Example_2] (At 

Re: [Django] #33050: calling count on union of queries having select_related results in error.

2021-08-24 Thread Django
#33050: calling count on union of queries having select_related results in 
error.
-+-
 Reporter:  Sunkyue-Kim  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  orm, count, union,   | Triage Stage:
  select_related |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Description changed by Sunkyue-Kim:

Old description:

> test case:
> {{{
> class ModelA(models.Model):
> value = models.IntegerField()
>
> class ModelB(models.Model):
>model_a = models.ForeignKey("ModelA", on_delete=models.CASCADE)
> }}}
> ->
> {{{
> ModelB.objects.select_related('model_a').union(ModelB.objects.select_related('model_a')).count()
> }}}
> results in error.
>
> {{{
>  File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\query.py", line 412, in count
> return self.query.get_count(using=self.db)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\query.py", line 521, in get_count
> number = obj.get_aggregation(using, ['__count'])['__count']
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\query.py", line 506, in get_aggregation
> result = compiler.execute_sql(SINGLE)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\compiler.py", line 1175, in execute_sql
> cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 98, in execute
> return super().execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 66, in execute
> return self._execute_with_wrappers(sql, params, many=False,
> executor=self._execute)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 75, in _execute_with_wrappers
> return executor(sql, params, many, context)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 84, in _execute
> return self.cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\utils.py", line 90, in __exit__
> raise dj_exc_value.with_traceback(traceback) from exc_value
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 84, in _execute
> return self.cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\mysql\base.py", line 73, in execute
> return self.cursor.execute(query, args)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\cursors.py", line 206, in execute
> res = self._query(query)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\cursors.py", line 319, in _query
> db.query(q)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\connections.py", line 259, in query
> _mysql.connection.query(self, query)
> django.db.utils.OperationalError: (1060, "Duplicate column name 'id'")
> }}}
>
> suggested fix:
> on django.db.models.sql.query.py -> Query.get_aggregation, from
> {{{
> inner_query.select_for_update = False
> inner_query.select_related = False
> inner_query.set_annotation_mask(self.annotation_select)
> }}}
> to
> {{{
> inner_query.select_for_update = False
> inner_query.select_related = False
> for combined_query in inner_query.combined_queries:
> combined_query.select_related = False
> inner_query.set_annotation_mask(self.annotation_select)
>
> }}}
> can solve the problem I think.
>
> my current monkey-patching code is,
> {{{
> from django.db.models.sql.query import Query
>
> old_get_aggregation = Query.get_aggregation
>
> def get_aggregation(self, using, added_aggregate_names):
> original_select_related_values = {}
> for combined_query in self.combined_queries:
> original_select_related_values[combined_query] =
> combined_query.select_related
> combined_query.select_related = False
> result = 

[Django] #33051: Model names with special characters don't highlight in admin site

2021-08-24 Thread Django
#33051: Model names with special characters don't highlight in admin site
-+-
   Reporter:  ꯸ ꬰ ꝛ⼻ↇ  |  Owner:  nobody
   Type:  Bug| Status:  new
  Component: |Version:  3.2
  contrib.admin  |
   Severity:  Normal |   Keywords:  accents, unicode
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 Create two models, one without special characters `Hello` and another with
 `Héllo`, register both with the admin website.

 Then, when you click on Hello in the admin website it highlights in yellow
 in the sidebar, but it is not the case for Héllo, which remains
 white/gray. This is true for any number of models in any order, only those
 with an accent will exhibit this behaviour.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.c858392906de67e726486b77a8e0a4a2%40djangoproject.com.


Re: [Django] #33050: calling count on union of queries having select_related results in error.

2021-08-24 Thread Django
#33050: calling count on union of queries having select_related results in 
error.
-+-
 Reporter:  Sunkyue-Kim  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  orm, count, union,   | Triage Stage:
  select_related |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Description changed by Sunkyue-Kim:

Old description:

> test case:
> {{{
> class ModelA(models.Model):
> value = models.IntegerField()
>
> class ModelB(models.Model):
>model_a = models.ForeignKey("ModelA", on_delete=models.CASCADE)
> }}}
> ->
> {{{
> ModelB.objects.select_related('model_a').union(ModelB.objects.select_related('model_a')).count()
> }}}
> results in error.
>
> {{{
>  File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\query.py", line 412, in count
> return self.query.get_count(using=self.db)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\query.py", line 521, in get_count
> number = obj.get_aggregation(using, ['__count'])['__count']
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\query.py", line 506, in get_aggregation
> result = compiler.execute_sql(SINGLE)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\compiler.py", line 1175, in execute_sql
> cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 98, in execute
> return super().execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 66, in execute
> return self._execute_with_wrappers(sql, params, many=False,
> executor=self._execute)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 75, in _execute_with_wrappers
> return executor(sql, params, many, context)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 84, in _execute
> return self.cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\utils.py", line 90, in __exit__
> raise dj_exc_value.with_traceback(traceback) from exc_value
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 84, in _execute
> return self.cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\mysql\base.py", line 73, in execute
> return self.cursor.execute(query, args)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\cursors.py", line 206, in execute
> res = self._query(query)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\cursors.py", line 319, in _query
> db.query(q)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\connections.py", line 259, in query
> _mysql.connection.query(self, query)
> django.db.utils.OperationalError: (1060, "Duplicate column name 'id'")
> }}}
>
> suggested fix:
> on django.db.models.sql.query.py -> Query.get_aggregation, from
> {{{
> inner_query.select_for_update = False
> inner_query.select_related = False
> inner_query.set_annotation_mask(self.annotation_select)
> }}}
> to
> {{{
> inner_query.select_for_update = False
> inner_query.select_related = False
> for combined_query in inner_query.combined_queries:
> combined_query.select_related = False
> inner_query.set_annotation_mask(self.annotation_select)
>
> }}}
> can solve the problem I think.
>
> reproduced on on 3.2.5/3.2.6

New description:

 test case:
 {{{
 class ModelA(models.Model):
 value = models.IntegerField()

 class ModelB(models.Model):
model_a = models.ForeignKey("ModelA", on_delete=models.CASCADE)
 }}}
 ->
 {{{
 
ModelB.objects.select_related('model_a').union(ModelB.objects.select_related('model_a')).count()
 }}}
 results in error.

 {{{
  File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 

Re: [Django] #33050: calling count on union of queries having select_related results in error.

2021-08-24 Thread Django
#33050: calling count on union of queries having select_related results in 
error.
-+-
 Reporter:  Sunkyue-Kim  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  orm, count, union,   | Triage Stage:
  select_related |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Description changed by Sunkyue-Kim:

Old description:

> test case:
> {{{
> class ModelA(models.Model):
> value = models.IntegerField()
>
> class ModelB(models.Model):
>model_a = models.ForeignKey("ModelA", on_delete=models.CASCADE)
> }}}
> ->
> {{{
> ModelB.objects.select_related('model_a').union(ModelB.objects.select_related('model_a')).count()
> }}}
> results in error.
>
> {{{
>  File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\query.py", line 412, in count
> return self.query.get_count(using=self.db)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\query.py", line 521, in get_count
> number = obj.get_aggregation(using, ['__count'])['__count']
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\query.py", line 506, in get_aggregation
> result = compiler.execute_sql(SINGLE)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\compiler.py", line 1175, in execute_sql
> cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 98, in execute
> return super().execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 66, in execute
> return self._execute_with_wrappers(sql, params, many=False,
> executor=self._execute)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 75, in _execute_with_wrappers
> return executor(sql, params, many, context)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 84, in _execute
> return self.cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\utils.py", line 90, in __exit__
> raise dj_exc_value.with_traceback(traceback) from exc_value
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 84, in _execute
> return self.cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\mysql\base.py", line 73, in execute
> return self.cursor.execute(query, args)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\cursors.py", line 206, in execute
> res = self._query(query)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\cursors.py", line 319, in _query
> db.query(q)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\connections.py", line 259, in query
> _mysql.connection.query(self, query)
> django.db.utils.OperationalError: (1060, "Duplicate column name 'id'")
> }}}
>
> suggested fix:
> on django.db.models.sql.query.py -> Query.get_aggregation, from
> {{{
> inner_query.select_for_update = False
> inner_query.select_related = False
> inner_query.set_annotation_mask(self.annotation_select)
> }}}
> to
> {{{
> inner_query.select_for_update = False
> inner_query.select_related = False
> for combined_query in inner_query.combined_queries:
> combined_query.select_related = False
> inner_query.set_annotation_mask(self.annotation_select)
>
> }}}
> can solve the problem I think.
>
> reproduced on on 3.2.5

New description:

 test case:
 {{{
 class ModelA(models.Model):
 value = models.IntegerField()

 class ModelB(models.Model):
model_a = models.ForeignKey("ModelA", on_delete=models.CASCADE)
 }}}
 ->
 {{{
 
ModelB.objects.select_related('model_a').union(ModelB.objects.select_related('model_a')).count()
 }}}
 results in error.

 {{{
  File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 

Re: [Django] #33050: calling count on union of queries having select_related results in error.

2021-08-24 Thread Django
#33050: calling count on union of queries having select_related results in 
error.
-+-
 Reporter:  Sunkyue-Kim  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  orm, count, union,   | Triage Stage:
  select_related |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Description changed by Sunkyue-Kim:

Old description:

> test case:
> {{{
> class ModelA(models.Model):
> value = models.IntegerField()
>
> class ModelB(models.Model):
>model_a = models.ForeignKey("ModelA", on_delete=models.CASCADE)
> }}}
> ->
> {{{
> ModelB.objects.select_related('model_a').union(ModelB.objects.select_related('model_a')).count()
> }}}
> results in error.
>
> {{{
>  File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\query.py", line 412, in count
> return self.query.get_count(using=self.db)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\query.py", line 521, in get_count
> number = obj.get_aggregation(using, ['__count'])['__count']
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\query.py", line 506, in get_aggregation
> result = compiler.execute_sql(SINGLE)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\models\sql\compiler.py", line 1175, in execute_sql
> cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 98, in execute
> return super().execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 66, in execute
> return self._execute_with_wrappers(sql, params, many=False,
> executor=self._execute)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 75, in _execute_with_wrappers
> return executor(sql, params, many, context)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 84, in _execute
> return self.cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\utils.py", line 90, in __exit__
> raise dj_exc_value.with_traceback(traceback) from exc_value
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\utils.py", line 84, in _execute
> return self.cursor.execute(sql, params)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\django\db\backends\mysql\base.py", line 73, in execute
> return self.cursor.execute(query, args)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\cursors.py", line 206, in execute
> res = self._query(query)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\cursors.py", line 319, in _query
> db.query(q)
>   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
> packages\MySQLdb\connections.py", line 259, in query
> _mysql.connection.query(self, query)
> django.db.utils.OperationalError: (1060, "Duplicate column name 'id'")
> }}}
>
> suggested fix:
> on django.db.models.sql.query.py -> Query.get_aggregation, from
> {{{
> inner_query.select_for_update = False
> inner_query.select_related = False
> inner_query.set_annotation_mask(self.annotation_select)
> }}}
> to
> {{{
> inner_query.select_for_update = False
> inner_query.select_related = False
> for combined_query in inner_query.combined_queries:
> combined_query.select_related = False
> inner_query.set_annotation_mask(self.annotation_select)
>
> }}}
> can solve the problem I think.

New description:

 test case:
 {{{
 class ModelA(models.Model):
 value = models.IntegerField()

 class ModelB(models.Model):
model_a = models.ForeignKey("ModelA", on_delete=models.CASCADE)
 }}}
 ->
 {{{
 
ModelB.objects.select_related('model_a').union(ModelB.objects.select_related('model_a')).count()
 }}}
 results in error.

 {{{
  File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\models\query.py", 

Re: [Django] #33050: calling count on union of queries having select_related results in error.

2021-08-24 Thread Django
#33050: calling count on union of queries having select_related results in 
error.
-+-
 Reporter:  Sunkyue-Kim  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  orm, count, union,   | Triage Stage:
  select_related |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Sunkyue-Kim):

 * easy:  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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.37c1fd3fa92be42dc0581a293d022fb2%40djangoproject.com.


[Django] #33050: calling count on union of queries having select_related results in error.

2021-08-24 Thread Django
#33050: calling count on union of queries having select_related results in 
error.
-+-
   Reporter:  Sunkyue-   |  Owner:  nobody
  Kim|
   Type:  Bug| Status:  new
  Component:  Database   |Version:  3.2
  layer (models, ORM)|   Keywords:  orm, count, union,
   Severity:  Normal |  select_related
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 test case:
 {{{
 class ModelA(models.Model):
 value = models.IntegerField()

 class ModelB(models.Model):
model_a = models.ForeignKey("ModelA", on_delete=models.CASCADE)
 }}}
 ->
 {{{
 
ModelB.objects.select_related('model_a').union(ModelB.objects.select_related('model_a')).count()
 }}}
 results in error.

 {{{
  File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\models\query.py", line 412, in count
 return self.query.get_count(using=self.db)
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\models\sql\query.py", line 521, in get_count
 number = obj.get_aggregation(using, ['__count'])['__count']
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\models\sql\query.py", line 506, in get_aggregation
 result = compiler.execute_sql(SINGLE)
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\models\sql\compiler.py", line 1175, in execute_sql
 cursor.execute(sql, params)
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\backends\utils.py", line 98, in execute
 return super().execute(sql, params)
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\backends\utils.py", line 66, in execute
 return self._execute_with_wrappers(sql, params, many=False,
 executor=self._execute)
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\backends\utils.py", line 75, in _execute_with_wrappers
 return executor(sql, params, many, context)
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\backends\utils.py", line 84, in _execute
 return self.cursor.execute(sql, params)
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\utils.py", line 90, in __exit__
 raise dj_exc_value.with_traceback(traceback) from exc_value
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\backends\utils.py", line 84, in _execute
 return self.cursor.execute(sql, params)
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\django\db\backends\mysql\base.py", line 73, in execute
 return self.cursor.execute(query, args)
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\MySQLdb\cursors.py", line 206, in execute
 res = self._query(query)
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\MySQLdb\cursors.py", line 319, in _query
 db.query(q)
   File "c:\Users\user\Documents\workspace\realclass2-api\.venv\lib\site-
 packages\MySQLdb\connections.py", line 259, in query
 _mysql.connection.query(self, query)
 django.db.utils.OperationalError: (1060, "Duplicate column name 'id'")
 }}}

 suggested fix:
 on django.db.models.sql.query.py -> Query.get_aggregation, from
 {{{
 inner_query.select_for_update = False
 inner_query.select_related = False
 inner_query.set_annotation_mask(self.annotation_select)
 }}}
 to
 {{{
 inner_query.select_for_update = False
 inner_query.select_related = False
 for combined_query in inner_query.combined_queries:
 combined_query.select_related = False
 inner_query.set_annotation_mask(self.annotation_select)

 }}}
 can solve the problem I think.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/054.95d543f134c52eae590da12c9d4c3909%40djangoproject.com.


Re: [Django] #33049: TabularInline doesn't render properly MultiPolygonField in Django Admin

2021-08-24 Thread Django
#33049: TabularInline doesn't render properly MultiPolygonField in Django Admin
-+-
 Reporter:  Vladyslav Krylasov   |Owner:  nobody
 Type:  Uncategorized|   Status:  new
Component:  GIS  |  Version:  2.2
 Severity:  Normal   |   Resolution:
 Keywords:  gis, admin,  | Triage Stage:
  MultiPolygonField, TabularInline   |  Unreviewed
Has patch:  0|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  1
-+-
Description changed by Vladyslav Krylasov:

Old description:

> I have a Django model that contains `MultiPolygonField`, so wanted to
> render it through the admin dashboard as an inline field.
> {{{
> #!div style="font-size: 80%"
> models.py
>   {{{#!python
>   class Geometry(models.Model):
> zone = models.ForeignKey(to=Zone, on_delete=models.CASCADE)
> mpoly = models.MultiPolygonField(null=True, blank=True)
>   }}}
> admin.py
>   {{{#!python
>   class GeometryInline(admin.TabularInline):
> model = Geometry
> max_num = 1
>
>   class ZoneAdmin(admin.GeoModelAdmin):
> model = Zone
> ...
> inlines = (GeometryInline,)
>
>   }}}
> }}}
> This renders such result:
> [[Image(https://i.ibb.co/njML4CP/Screenshot-
> from-2021-08-20-13-27-32.png)]]
>
> But when I make `django.contrib.gis.admin.GeoModelAdmin` as a mixin it
> works just fine.
> {{{
> #!div style="font-size: 80%"
> admin.py
>   {{{#!python
> from django.contrib.gis import admin
> from django.contrib.gis.admin.widgets import OpenLayersWidget
> from django.contrib.gis.db import models
> from django.contrib.gis.gdal import OGRGeomType
> from django.forms import Media
>

> class GeoAdminMixin:
> """
> Copied over from django.contrib.gis.admin.GeoModelAdmin
>
> The administration options class for Geographic models. Map settings
> may be overloaded from their defaults to create custom maps.
> """
>
> # The default map settings that may be overloaded -- still subject
> # to API changes.
> default_lon = 0
> default_lat = 0
> default_zoom = 4
> display_wkt = False
> display_srid = False
> extra_js = []
> num_zoom = 18
> max_zoom = False
> min_zoom = False
> units = False
> max_resolution = False
> max_extent = False
> modifiable = True
> mouse_position = True
> scale_text = True
> layerswitcher = True
> scrollable = True
> map_width = 600
> map_height = 400
> map_srid = 4326
> map_template = 'gis/admin/openlayers.html'
> openlayers_url =
> 'https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js'
> point_zoom = num_zoom - 6
> wms_url = 'http://vmap0.tiles.osgeo.org/wms/vmap0'
> wms_layer = 'basic'
> wms_name = 'OpenLayers WMS'
> wms_options = {'format': 'image/jpeg'}
> debug = False
> widget = OpenLayersWidget
>
> @property
> def media(self):
> "Injects OpenLayers JavaScript into the admin."
> return super().media + Media(js=[self.openlayers_url] +
> self.extra_js)
>
> def formfield_for_dbfield(self, db_field, request, **kwargs):
> """
> Overloaded from ModelAdmin so that an OpenLayersWidget is used
> for viewing/editing 2D GeometryFields (OpenLayers 2 does not
> support
> 3D editing).
> """
> if isinstance(db_field, models.GeometryField) and db_field.dim <
> 3:
> # Setting the widget with the newly defined widget.
> kwargs['widget'] = self.get_map_widget(db_field)
> return db_field.formfield(**kwargs)
> else:
> return super().formfield_for_dbfield(db_field, request,
> **kwargs)
>
> def get_map_widget(self, db_field):
> """
> Return a subclass of the OpenLayersWidget (or whatever was
> specified
> in the `widget` attribute) using the settings from the attributes
> set
> in this class.
> """
> is_collection = db_field.geom_type in (
> 'MULTIPOINT',
> 'MULTILINESTRING',
> 'MULTIPOLYGON',
> 'GEOMETRYCOLLECTION',
> )
> if is_collection:
> if db_field.geom_type == 'GEOMETRYCOLLECTION':
> collection_type = 'Any'
> else:
> collection_type =
> OGRGeomType(db_field.geom_type.replace('MULTI', ''))
> else:
> collection_type = 'None'
>
> class OLMap(self.widget):
> template_name = self.map_template
> geom_type = db_field.geom_type
>
> wms_options = ''
> if self.wms_options:
> 

Re: [Django] #33049: TabularInline doesn't render properly MultiPolygonField in Django Admin

2021-08-24 Thread Django
#33049: TabularInline doesn't render properly MultiPolygonField in Django Admin
-+-
 Reporter:  Vladyslav Krylasov   |Owner:  nobody
 Type:  Uncategorized|   Status:  new
Component:  GIS  |  Version:  2.2
 Severity:  Normal   |   Resolution:
 Keywords:  gis, admin,  | Triage Stage:
  MultiPolygonField, TabularInline   |  Unreviewed
Has patch:  0|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  1
-+-
Changes (by Vladyslav Krylasov):

 * cc: Vladyslav Krylasov (added)
 * needs_docs:  0 => 1
 * needs_tests:  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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/070.97d136a314f5f723666fe929f2bf9721%40djangoproject.com.


[Django] #33049: TabularInline doesn't render properly MultiPolygonField in Django Admin

2021-08-24 Thread Django
#33049: TabularInline doesn't render properly MultiPolygonField in Django Admin
-+-
   Reporter:  Vladyslav  |  Owner:  nobody
  Krylasov   |
   Type: | Status:  new
  Uncategorized  |
  Component:  GIS|Version:  2.2
   Severity:  Normal |   Keywords:  gis, admin,
   Triage Stage: |  MultiPolygonField, TabularInline
  Unreviewed |  Has patch:  0
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  1  |
-+-
 I have a Django model that contains `MultiPolygonField`, so wanted to
 render it through the admin dashboard as an inline field.
 {{{
 #!div style="font-size: 80%"
 models.py
   {{{#!python
   class Geometry(models.Model):
 zone = models.ForeignKey(to=Zone, on_delete=models.CASCADE)
 mpoly = models.MultiPolygonField(null=True, blank=True)
   }}}
 admin.py
   {{{#!python
   class GeometryInline(admin.TabularInline):
 model = Geometry
 max_num = 1

   class ZoneAdmin(admin.GeoModelAdmin):
 model = Zone
 ...
 inlines = (GeometryInline,)

   }}}
 }}}
 This renders such result:
 [[Image(https://i.ibb.co/njML4CP/Screenshot-
 from-2021-08-20-13-27-32.png)]]

 But when I make `django.contrib.gis.admin.GeoModelAdmin` as a mixin it
 works just fine.
 {{{
 #!div style="font-size: 80%"
 admin.py
   {{{#!python
 from django.contrib.gis import admin
 from django.contrib.gis.admin.widgets import OpenLayersWidget
 from django.contrib.gis.db import models
 from django.contrib.gis.gdal import OGRGeomType
 from django.forms import Media


 class GeoAdminMixin:
 """
 Copied over from django.contrib.gis.admin.GeoModelAdmin

 The administration options class for Geographic models. Map settings
 may be overloaded from their defaults to create custom maps.
 """

 # The default map settings that may be overloaded -- still subject
 # to API changes.
 default_lon = 0
 default_lat = 0
 default_zoom = 4
 display_wkt = False
 display_srid = False
 extra_js = []
 num_zoom = 18
 max_zoom = False
 min_zoom = False
 units = False
 max_resolution = False
 max_extent = False
 modifiable = True
 mouse_position = True
 scale_text = True
 layerswitcher = True
 scrollable = True
 map_width = 600
 map_height = 400
 map_srid = 4326
 map_template = 'gis/admin/openlayers.html'
 openlayers_url =
 'https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js'
 point_zoom = num_zoom - 6
 wms_url = 'http://vmap0.tiles.osgeo.org/wms/vmap0'
 wms_layer = 'basic'
 wms_name = 'OpenLayers WMS'
 wms_options = {'format': 'image/jpeg'}
 debug = False
 widget = OpenLayersWidget

 @property
 def media(self):
 "Injects OpenLayers JavaScript into the admin."
 return super().media + Media(js=[self.openlayers_url] +
 self.extra_js)

 def formfield_for_dbfield(self, db_field, request, **kwargs):
 """
 Overloaded from ModelAdmin so that an OpenLayersWidget is used
 for viewing/editing 2D GeometryFields (OpenLayers 2 does not
 support
 3D editing).
 """
 if isinstance(db_field, models.GeometryField) and db_field.dim <
 3:
 # Setting the widget with the newly defined widget.
 kwargs['widget'] = self.get_map_widget(db_field)
 return db_field.formfield(**kwargs)
 else:
 return super().formfield_for_dbfield(db_field, request,
 **kwargs)

 def get_map_widget(self, db_field):
 """
 Return a subclass of the OpenLayersWidget (or whatever was
 specified
 in the `widget` attribute) using the settings from the attributes
 set
 in this class.
 """
 is_collection = db_field.geom_type in (
 'MULTIPOINT',
 'MULTILINESTRING',
 'MULTIPOLYGON',
 'GEOMETRYCOLLECTION',
 )
 if is_collection:
 if db_field.geom_type == 'GEOMETRYCOLLECTION':
 collection_type = 'Any'
 else:
 collection_type =
 OGRGeomType(db_field.geom_type.replace('MULTI', ''))
 else:
 collection_type = 'None'

 class OLMap(self.widget):
 template_name = self.map_template
 geom_type = db_field.geom_type

 wms_options = ''
 if self.wms_options:
 wms_options = ["%s: '%s'" % pair for pair in
 self.wms_options.items()]
 wms_options = ', %s' % ', '.join(wms_options)

 params = {
 

Re: [Django] #24900: KeyError when trying to migrate backward to a replaced migration (was: KeyError when trying to migrate to a replaced migration)

2021-08-24 Thread Django
#24900: KeyError when trying to migrate backward to a replaced migration
+---
 Reporter:  Carl Meyer  |Owner:  Jacob Walls
 Type:  Bug |   Status:  assigned
Component:  Migrations  |  Version:  dev
 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
+---

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.e267de9a3fb7b658d67cc14a4827d2d4%40djangoproject.com.


Re: [Django] #29026: Make makemigrations scriptable / script-friendly

2021-08-24 Thread Django
#29026: Make makemigrations scriptable / script-friendly
-+-
 Reporter:  Chris Jerdonek   |Owner:  Jacob
 Type:   |  Walls
  Cleanup/optimization   |   Status:  assigned
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  makemigrations,scripting,stderr,stdout|
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Jacob Walls):

 * needs_better_patch:  1 => 0


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.fd4039c05d63c5f7ad692c850cc64146%40djangoproject.com.


Re: [Django] #24900: KeyError when trying to migrate to a replaced migration

2021-08-24 Thread Django
#24900: KeyError when trying to migrate to a replaced migration
+---
 Reporter:  Carl Meyer  |Owner:  Jacob Walls
 Type:  Bug |   Status:  assigned
Component:  Migrations  |  Version:  dev
 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 Jacob Walls):

 * needs_better_patch:  1 => 0


Comment:

 Updated implementation to reduce complexity.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.6e056314a52afabb76536930f44e4d8b%40djangoproject.com.


Re: [Django] #32552: Allow DiscoverRunner to use a logger instead of printing to stdout

2021-08-24 Thread Django
#32552: Allow DiscoverRunner to use a logger instead of printing to stdout
-+-
 Reporter:  Chris Jerdonek   |Owner:  Chris
 |  Jerdonek
 Type:  New feature  |   Status:  closed
Component:  Testing framework|  Version:  4.0
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
  DiscoverRunner,print,logging,stdout,stderr|  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

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


Comment:

 In [changeset:"b263f4b69db4093847ccc3b85e51cc7f3759e42c" b263f4b6]:
 {{{
 #!CommitTicketReference repository=""
 revision="b263f4b69db4093847ccc3b85e51cc7f3759e42c"
 Fixed #32552 -- Added logger argument to DiscoverRunner.
 }}}

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.3f1da725a06d9c7caefa56c6b33de4f1%40djangoproject.com.


Re: [Django] #33048: Documentation doesn't mention that using staticfiles' runserver doesn't use the middleware chain.

2021-08-24 Thread Django
#33048: Documentation doesn't mention that using staticfiles' runserver doesn't 
use
the middleware chain.
--+
 Reporter:  Keryn Knight  |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Documentation |  Version:  dev
 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 Carlton Gibson):

 * stage:  Unreviewed => Accepted


Comment:

 Hey Keryn. 

 Having been confused on #32891, I agree that this is confusing. (X
 weeks/months/years since I thought about this, why doesn't it work the
 same as everything else… 樂. Repeat.)

 If you want to document this, super. …

 > Of course, I'm also open to changing it to go through the middleware
 chain like a normal request ...

 Sketching that up as a proposal would likely be worth a discussion on the
 DevelopersMailingList (I mean that's on the road to #27325 no...? )

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.dd818755eb692479f7dd5b9805b75345%40djangoproject.com.


[Django] #33048: Documentation doesn't mention that using staticfiles' runserver doesn't use the middleware chain.

2021-08-24 Thread Django
#33048: Documentation doesn't mention that using staticfiles' runserver doesn't 
use
the middleware chain.
+
   Reporter:  Keryn Knight  |  Owner:  nobody
   Type:  Cleanup/optimization  | Status:  new
  Component:  Documentation |Version:  dev
   Severity:  Normal|   Keywords:
   Triage Stage:  Unreviewed|  Has patch:  0
Needs documentation:  0 |Needs tests:  0
Patch needs improvement:  0 |  Easy pickings:  0
  UI/UX:  0 |
+
 I'm not sure ''why'' it doesn't use the middleware chain (but then I don't
 really know why it's not a middleware itself), because it makes a certain
 class of development tooling (ie: tracking responses which are assets)
 more difficult (I think I might have to monkeypatch? ugh), but hey ho.

 It would be nice if there were an admonition in
 [https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-
 files-during-development the Serving static files during development docs]
 to say as much, especially given that if you ''don't'' have
 `django.contrib.staticfiles` in your `INSTALLED_APPS` and instead have
 opted for using `+= static(settings.STATIC_URL,
 document_root=settings.STATIC_ROOT)` for whatever reason, those requests
 **do** go through the middleware chain.

 Perhaps worth noting that the subject came up independently in #32891 and
 despite reading that thread, I'd entirely forgotten that `staticfiles` was
 abnormal in that respect, in just 8 weeks...

 Of course, I'm also open to changing it to go through the middleware chain
 like a normal request (which would look to involve removing `get_response`
 in favour of `resolve_request` ... or just changing it to be a middleware)
 ;)

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.c4117c0d9dd9d831f62413067a54361c%40djangoproject.com.


Re: [Django] #33047: CheckConstraint crashes with GIS lookup and PostGIS backend. (was: str decode error when applying migration with a CheckConstraint using a GEOS geometry and PostGISAdapter)

2021-08-24 Thread Django
#33047: CheckConstraint crashes with GIS lookup and PostGIS backend.
-+-
 Reporter:  Daniel Swain |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  GIS  |  Version:  3.2
 Severity:  Normal   |   Resolution:
 Keywords:  constraint,  | Triage Stage:  Accepted
  postgres, postgis, geos,   |
  attributeerror, migration, |
  schema_editor, getquoted,  |
  quote_value|
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * owner:  (none) => nobody
 * component:  contrib.postgres => GIS
 * stage:  Unreviewed => Accepted


Comment:

 Thanks for the report.

 Reproduced at 022d29c934107c515dd6d3181945146a2077bdf0.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.70efae6cae7b4b94b83ac8bcdeffd4cf%40djangoproject.com.


Re: [Django] #29899: Adapt the auto-detector to detect changes from model states instead of model classes

2021-08-24 Thread Django
#29899: Adapt the auto-detector to detect changes from model states instead of
model classes
-+-
 Reporter:  Simon Charette   |Owner:  David
 Type:   |  Wobrock
  Cleanup/optimization   |   Status:  closed
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Chris Jerdonek):

 > I was also thinking about changing this structure to a dict.

 

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.fae8ec98c9ad61b3f41094d70090cc07%40djangoproject.com.


Re: [Django] #29899: Adapt the auto-detector to detect changes from model states instead of model classes

2021-08-24 Thread Django
#29899: Adapt the auto-detector to detect changes from model states instead of
model classes
-+-
 Reporter:  Simon Charette   |Owner:  David
 Type:   |  Wobrock
  Cleanup/optimization   |   Status:  closed
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak):

 Replying to [comment:14 Chris Jerdonek]:
 > On this issue, does anyone remember if there was a reason that
 `self.relations`
 
[https://github.com/django/django/commit/aa4acc164d1247c0de515c959f7b09648b57dc42
 #diff-
 5dd147e9e978e645313dd99eab3a7bab1f1cb0a53e256843adb68aeed71e61dcR93-R94
 was defined] to have this form--
 >
 > * `{remote_model_key: {model_key: [(field_name, field)]}}`
 >
 > as opposed to this form?
 >
 > * `{remote_model_key: {model_key: {field_name: field}}}`
 >
 > While reviewing [https://github.com/django/django/pull/14587 PR #14587]
 for #29898, I noticed the code would be a bit simpler in parts if it were
 the latter as opposed to the former, but I wasn't sure if there was a
 reason for a using a list of pairs instead of a dict.

 Probably because there was no need to update the list of fields. I was
 also thinking about changing this structure to a dict.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.2fb29c61bdf88075c9e316c77a59cc2a%40djangoproject.com.


Re: [Django] #33043: method_decorator() should preserve wrapper assignments

2021-08-24 Thread Django
#33043: method_decorator() should preserve wrapper assignments
---+--
 Reporter:  vinay karanam  |Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Utilities  |  Version:  dev
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Unreviewed
Has patch:  1  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by Chris Jerdonek):

 * has_patch:  0 => 1


Comment:

 PR: https://github.com/django/django/pull/14787

 > Chris, can you take a look?

 OK.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.b6c8c7888fc14eeec928309e226e4bdb%40djangoproject.com.


Re: [Django] #29899: Adapt the auto-detector to detect changes from model states instead of model classes

2021-08-24 Thread Django
#29899: Adapt the auto-detector to detect changes from model states instead of
model classes
-+-
 Reporter:  Simon Charette   |Owner:  David
 Type:   |  Wobrock
  Cleanup/optimization   |   Status:  closed
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Chris Jerdonek):

 On this issue, does anyone remember if there was a reason that
 `self.relations`
 
[https://github.com/django/django/commit/aa4acc164d1247c0de515c959f7b09648b57dc42
 #diff-
 5dd147e9e978e645313dd99eab3a7bab1f1cb0a53e256843adb68aeed71e61dcR93-R94
 was defined] to have this form--

 * `{remote_model_key: {model_key: [(field_name, field)]}}`

 as opposed to this form?

 * `{remote_model_key: {model_key: {field_name: field}}}`

 While reviewing [https://github.com/django/django/pull/14587 PR #14587]
 for #29898, I noticed the code would be a bit simpler in parts if it were
 the latter as opposed to the former, but I wasn't sure if there was a
 reason for a using a list of pairs instead of a dict.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.d358fee3e0ee5f0241c33db739375dcd%40djangoproject.com.


[Django] #33047: str decode error when applying migration with a CheckConstraint using a GEOS geometry and PostGISAdapter

2021-08-24 Thread Django
#33047: str decode error when applying migration with a CheckConstraint using a
GEOS geometry and PostGISAdapter
-+-
   Reporter:  Daniel |  Owner:  (none)
  Swain  |
   Type:  Bug| Status:  new
  Component: |Version:  3.2
  contrib.postgres   |   Keywords:  constraint,
   Severity:  Normal |  postgres, postgis, geos,
 |  attributeerror, migration,
 |  schema_editor, getquoted,
   Triage Stage: |  quote_value
  Unreviewed |  Has patch:  0
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 Trying to apply a migration adding a `CheckConstraint` with a spatial
 lookup (within) fails with: `AttributeError: 'str' object has no attribute
 'decode'.` when creating the SQL statement.

 == Traceback:
 {{{
 File "/usr/local/lib/python3.9/site-
 packages/django/db/migrations/operations/models.py", line 858, in
 database_forwards
 schema_editor.add_constraint(model, self.constraint)
 File "/usr/local/lib/python3.9/site-
 packages/django/db/backends/base/schema.py", line 379, in add_constraint
 sql = constraint.create_sql(model, self)
 File "/usr/local/lib/python3.9/site-
 packages/django/db/models/constraints.py", line 54, in create_sql
 check = self._get_check_sql(model, schema_editor)
 File "/usr/local/lib/python3.9/site-
 packages/django/db/models/constraints.py", line 47, in _get_check_sql
 return sql % tuple(schema_editor.quote_value(p) for p in params)
 File "/usr/local/lib/python3.9/site-
 packages/django/db/models/constraints.py", line 47, in 
 return sql % tuple(schema_editor.quote_value(p) for p in params)
 File "/usr/local/lib/python3.9/site-
 packages/django/db/backends/postgresql/schema.py", line 45, in quote_value
 return adapted.getquoted().decode()
 }}}

 == Investigation
 Looking at the `DatabaseSchemaEditor` class in the `postgresql` backend,
 it looks like `quote_value` expects `adapted.getquoted()` to return a
 `bytestring`:

 {{{#!python
 def quote_value(self, value):
 ...
 # getquoted() returns a quoted bytestring of the adapted value.
 return adapted.getquoted().decode()
 }}}

 The adaper used in this migration, `PostGISAdapter` returns a `str` from
 `getquoted`, not a `bytestring`:

 {{{#!python
 class PostGISAdapter:
 def getquoted(self):
 """
 Return a properly quoted string for use in PostgreSQL/PostGIS.
 """
 if self.is_geometry:
 # Psycopg will figure out whether to use E'\\000' or '\000'.
 return '%s(%s)' % (
 'ST_GeogFromWKB' if self.geography else 'ST_GeomFromEWKB',
 self._adapter.getquoted().decode()
 )
 else:
 # For rasters, add explicit type cast to WKB string.
 return "'%s'::raster" % self.ewkb
 }}}

 == Example model.
 We have a model definition similar to:

 {{{#!python
 from django.contrib.gis.db import models

 class Example(models.Model):
 location = models.models.PointField(null=True, blank=True)
 }}}

 We are trying to add a `CheckConstraint` that checks that the location is
 within a bounding box: `(x0, y0, x1, y1)` (The rest of these examples will
 use a bounding box for Australia).

 {{{#!python
 from django.contrib.gis.geos import Polygon


 class Example(models.Model):
 location = models.models.PointField(null=True, blank=True)

 class Meta:
 constraints = [
 models.CheckConstraint(
 check=models.Q(location__within=Polygon.from_bbox((96.816941, -43.740510,
 167.998035, -9.142176)),
 name="location_in_australia",
 ),
 ]
 }}}

 A migration is successfully created:

 {{{#!python
 class Migration(migration.Migration):
 operations = [
 migrations.AddConstraint(
 model_name='example',
 constraint=models.CheckConstraint(check=models.Q(('location__within',
 django.contrib.gis.geos.polygon.Polygon(((96.816941, -43.74051),
 (96.816941, -9.142176), (167.998035, -9.142176), (167.998035, -43.74051),
 (96.816941, -43.74051), name='location_in_australia'),
 ),
 ]
 }}}

 However, trying to run that migration gives the traceback shown at the
 top.

 == Potential fix/workaround.
 We were able to run the migration by editing the file
 `django/contrib/gis/db/backends/postgis/adapter.py` to make
 `PostGISAdapter.getquoted()` return a `bytestring`, but we don't know what
 effect this will have elsewhere.

 Example:
 {{{#!python
 def getquoted(self):
 if self.is_geometry:
 # Psycopg will 

Re: [Django] #24900: KeyError when trying to migrate to a replaced migration

2021-08-24 Thread Django
#24900: KeyError when trying to migrate to a replaced migration
+---
 Reporter:  Carl Meyer  |Owner:  Jacob Walls
 Type:  Bug |   Status:  assigned
Component:  Migrations  |  Version:  dev
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  1   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  1
Easy pickings:  0   |UI/UX:  0
+---
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1
 * stage:  Ready for checkin => Accepted


Comment:

 I'd like to discuss alternatives before moving forward, see
 [https://github.com/django/django/pull/14495#pullrequestreview-737044138
 comment].

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.01cf5764f1ab50a8aff996dc79958299%40djangoproject.com.


Re: [Django] #32992: Reverse time zone conversion in Trunc()/Extract() database functions.

2021-08-24 Thread Django
#32992: Reverse time zone conversion in Trunc()/Extract() database functions.
-+-
 Reporter:  James Beith  |Owner:  Carlton
 |  Gibson
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Release blocker  |   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 Carlton Gibson):

 * 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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.2e40433321b9ac85e9e1d442e0021b0f%40djangoproject.com.


Re: [Django] #32992: Reverse time zone conversion in Trunc()/Extract() database functions.

2021-08-24 Thread Django
#32992: Reverse time zone conversion in Trunc()/Extract() database functions.
-+-
 Reporter:  James Beith  |Owner:  Carlton
 |  Gibson
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Carlton Gibson):

 [https://github.com/django/django/pull/14792 PR] — Alan and James, it
 would be good if you could confirm this addresses your issues.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.3b8283a38a5a0b358d9b92b8bde94b47%40djangoproject.com.


[Django] #33046: Fully cached result approach of the QuerySet.count is not documented.

2021-08-24 Thread Django
#33046: Fully cached result approach of the QuerySet.count is not documented.
-+
   Reporter:  Can Sarıgöl|  Owner:  nobody
   Type:  Uncategorized  | Status:  new
  Component:  Uncategorized  |Version:  3.2
   Severity:  Normal |   Keywords:
   Triage Stage:  Unreviewed |  Has patch:  0
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+
 there is no document for count function docstring.


 {{{
 def count(self):
 """
 ...

 If the QuerySet is already fully cached, return the length of the
 cached results set to avoid multiple SELECT COUNT(*) calls.
 """
 }}}

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.ce6b0741c93f0398e55ae37fd38e8b86%40djangoproject.com.


Re: [Django] #32552: Allow DiscoverRunner to use a logger instead of printing to stdout

2021-08-24 Thread Django
#32552: Allow DiscoverRunner to use a logger instead of printing to stdout
-+-
 Reporter:  Chris Jerdonek   |Owner:  Chris
 |  Jerdonek
 Type:  New feature  |   Status:  assigned
Component:  Testing framework|  Version:  4.0
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
  DiscoverRunner,print,logging,stdout,stderr|  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * stage:  Accepted => Ready for checkin


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.bb365568dfb5051d9b07b4bde2249728%40djangoproject.com.


Re: [Django] #10929: Support a default value for Sum (and possibly other aggregation functions)

2021-08-24 Thread Django
#10929: Support a default value for Sum (and possibly other aggregation 
functions)
-+-
 Reporter:  nolan|Owner:  Nick Pope
 Type:  New feature  |   Status:  closed
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  aggregate annotate   | Triage Stage:  Ready for
  default|  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by GitHub ):

 In [changeset:"022d29c934107c515dd6d3181945146a2077bdf0" 022d29c9]:
 {{{
 #!CommitTicketReference repository=""
 revision="022d29c934107c515dd6d3181945146a2077bdf0"
 Refs #10929 -- Allowed NowUTC SQL customization for third-party backends.
 }}}

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.fb7a211e5c095618d19fddb495cc7cc4%40djangoproject.com.


Re: [Django] #33045: Out-of-the box support for React JS

2021-08-24 Thread Django
#33045: Out-of-the box support for React JS
-+--
 Reporter:  yopknopixx   |Owner:  nobody
 Type:  New feature  |   Status:  closed
Component:  Template system  |  Version:  dev
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:  React| Triage Stage:  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+--
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 > What I have in mind is some functionality that could render React
 directly from a view.

 I'm not really sure how this could work and  even if it's feasible I don't
 think there would be consensus to add that complexity. You can raise the
 idea on the DevelopersMailingList to reach a wider audience and see what
 other think. See some previous [https://groups.google.com/g/django-
 developers/c/OkW9X3E_Nlo/m/7HQibaTQAwAJ threads].

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.403beb8aa457b0451da1776d1450f32b%40djangoproject.com.