Django Sitemap XML error in Google and cannot submit to Google

I have successfully created an index sitemap.xml with other sitemap sections.
BUT when I try to submit my sitemap.xml to google it is not fetched and page speed insights: https://pagespeed.web.dev/ gives the error: Error!
The page provided is not HTML (served as MIME type application/xml).

I can see fine my sitemaps on my webiste but Google and Pagespeed do not like them.

After some digging I checked the headers of sitemap.xml and they are wrong - I do not understand how they came from:

curl -IA "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.175 Mobile Safari/537.36 Chrome-Lighthouse" 'https://WEBSITE/sitemap.xml'

Here is the result of previous command:

HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 04 Sep 2023 10:31:03 GMT
Content-Type: application/xml
Content-Length: 1035
Connection: keep-alive
X-Robots-Tag: noindex, noodp, noarchive
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin
Cross-Origin-Opener-Policy: same-origin

Here is my urls.py for sitemap:

# SITEMAPS - a main sitemap with sections for sub-sitemaps.
    path("sitemap.xml", views.index, {"sitemaps": sitemaps}, name="django.contrib.sitemaps.views.index",),
    path("sitemap-<section>.xml",sitemap,
         {"sitemaps": sitemaps},
         name="django.contrib.sitemaps.views.sitemap",
    ),

I use nginx and the sitemaps are xml sitemaps that are generated on the fly from django.
My robots.txt allows everything and does not block my sitemap.xml

Any ideas what is going wrong here?!

Best

The Django sitemap framework is working exactly as intended.

The sitemap.xml file is exactly that - an xml file.

If you wish to generate some other kind of output, such as a web page, you need to provide a template and configure the view. See the docs for views.sitemap.

You may need to do some research on what google is expecting in order to provide what it needs.

Thank you for your suggestion - it appears that Google Pagespeed has a bug because I tested and with no django sitemaps.xml and it returned the same error. Now, Google search console, accepted the submitted sitemaps despite the fact of the pagespeed error…