Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#14198 closed (fixed)

« None » appears in priority field of sitemaps when using GenericSitemap without specify priority (#14164 related)

Reported by: palkeo Owned by: nobody
Component: Internationalization Version: master
Severity: Keywords: internationalization L10N sitemaps none
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When using GenericSitemap class, and without specifying priority, the template generate an invalid sitemap.
The sitemap contains « <priority>None</priority> »

I think it's because of the #14164 patch : It will apply str() on the priority, even if the priority is None ! Then the priority will be « None ».

To reproduce the problem, apply the #14164 patch and then create a sitemap using GenericSitemap, without specifying priority.

For example :

sitemaps = {
    [...]
    'example': GenericSitemap({
            'queryset': Example.objects.all(),
        },
    ),
    [...]
}

Attachments (1)

patch.diff (278 bytes) - added by palkeo 4 years ago.

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by palkeo

comment:1 Changed 4 years ago by palkeo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Here is the patch, that can be applied to django/contrib/sitemaps/init.py :

72c72
<                 'priority':   str(self.__get('priority', item, ''))
---
>                 'priority':   self.__get('priority', item, None)
73a74,75
>             if type(url_info['priority']) == float:
>                 url_info['priority'] = str(url_info['priority'])

comment:2 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [13676]) Fixed #14198 -- Corrected rendering of generic sitemaps when no priority is specified. Thanks to palkeo for the report.

comment:3 Changed 4 years ago by russellm

(In [13677]) [1.2.X] Fixed #14198 -- Corrected rendering of generic sitemaps when no priority is specified. Thanks to palkeo for the report.

Backport of r13676 from trunk.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.