Django sitemap.xml throwing Server Error (500) in production










0














My app is throwing ERROR 500 while accessing example.com/sitemap.xml
Additional server configurations = Nginx+Gunicorn+postgres



Here are my files



sitemap.py

from django.contrib.sitemaps import Sitemap
from .models import Post, Status

class PostSitemap(Sitemap):
changefreq = 'daily'
priority = 0.9

def items(self):
return Post.objects.filter(status=0)

def lastmod(self, obj):
return obj.created_on

class StatusSitemap(Sitemap):
changefreq='daily'
priority = 0.9

def item(self):
return Status.objects.filter(status=0)

def lastmod(self, obj):


url.py



sitemaps = 
'posts': PostSitemap,
'status': StatusSitemap

urlpatterns = [ path('sitemap.xml/', sitemap, 'sitemaps': sitemaps,
name='sitemaps'),]


Don't know why is this showing error 500



UPDATE
Tarckbacks -
enter image description here










share|improve this question























  • Show us the full traceback for the error. If you haven't configured django to log the error to a file, do that first. You should always have an error log on your production machine.
    – dirkgroten
    Nov 12 at 13:09











  • Currently, the site is live, I noticed one thing in my local computer when the debug = False it's generating the site map, but when Debug is True it throws ERROR 500
    – Abhijeet Pal
    Nov 12 at 13:12










  • It doesn't matter that the site is live, you should still log your errors to disk (or use a service like Sentry) so you can view them. There's always going to be situations where something happens on a live site that you didn't plan for (because live data is different than local data) and then you'll want to have a trace of the error. Otherwise there's no way to debug.
    – dirkgroten
    Nov 12 at 13:13











  • First of all thanks a ton for that awesome suggestion okay I got this error ` raise TemplateDoesNotExist(template_name, chain=chain)` How to resolve it?
    – Abhijeet Pal
    Nov 12 at 15:17










  • can you post the full trace here? (not in a comment but in your question, otherwise it'll be impossible to read)
    – dirkgroten
    Nov 12 at 15:18















0














My app is throwing ERROR 500 while accessing example.com/sitemap.xml
Additional server configurations = Nginx+Gunicorn+postgres



Here are my files



sitemap.py

from django.contrib.sitemaps import Sitemap
from .models import Post, Status

class PostSitemap(Sitemap):
changefreq = 'daily'
priority = 0.9

def items(self):
return Post.objects.filter(status=0)

def lastmod(self, obj):
return obj.created_on

class StatusSitemap(Sitemap):
changefreq='daily'
priority = 0.9

def item(self):
return Status.objects.filter(status=0)

def lastmod(self, obj):


url.py



sitemaps = 
'posts': PostSitemap,
'status': StatusSitemap

urlpatterns = [ path('sitemap.xml/', sitemap, 'sitemaps': sitemaps,
name='sitemaps'),]


Don't know why is this showing error 500



UPDATE
Tarckbacks -
enter image description here










share|improve this question























  • Show us the full traceback for the error. If you haven't configured django to log the error to a file, do that first. You should always have an error log on your production machine.
    – dirkgroten
    Nov 12 at 13:09











  • Currently, the site is live, I noticed one thing in my local computer when the debug = False it's generating the site map, but when Debug is True it throws ERROR 500
    – Abhijeet Pal
    Nov 12 at 13:12










  • It doesn't matter that the site is live, you should still log your errors to disk (or use a service like Sentry) so you can view them. There's always going to be situations where something happens on a live site that you didn't plan for (because live data is different than local data) and then you'll want to have a trace of the error. Otherwise there's no way to debug.
    – dirkgroten
    Nov 12 at 13:13











  • First of all thanks a ton for that awesome suggestion okay I got this error ` raise TemplateDoesNotExist(template_name, chain=chain)` How to resolve it?
    – Abhijeet Pal
    Nov 12 at 15:17










  • can you post the full trace here? (not in a comment but in your question, otherwise it'll be impossible to read)
    – dirkgroten
    Nov 12 at 15:18













0












0








0







My app is throwing ERROR 500 while accessing example.com/sitemap.xml
Additional server configurations = Nginx+Gunicorn+postgres



Here are my files



sitemap.py

from django.contrib.sitemaps import Sitemap
from .models import Post, Status

class PostSitemap(Sitemap):
changefreq = 'daily'
priority = 0.9

def items(self):
return Post.objects.filter(status=0)

def lastmod(self, obj):
return obj.created_on

class StatusSitemap(Sitemap):
changefreq='daily'
priority = 0.9

def item(self):
return Status.objects.filter(status=0)

def lastmod(self, obj):


url.py



sitemaps = 
'posts': PostSitemap,
'status': StatusSitemap

urlpatterns = [ path('sitemap.xml/', sitemap, 'sitemaps': sitemaps,
name='sitemaps'),]


Don't know why is this showing error 500



UPDATE
Tarckbacks -
enter image description here










share|improve this question















My app is throwing ERROR 500 while accessing example.com/sitemap.xml
Additional server configurations = Nginx+Gunicorn+postgres



Here are my files



sitemap.py

from django.contrib.sitemaps import Sitemap
from .models import Post, Status

class PostSitemap(Sitemap):
changefreq = 'daily'
priority = 0.9

def items(self):
return Post.objects.filter(status=0)

def lastmod(self, obj):
return obj.created_on

class StatusSitemap(Sitemap):
changefreq='daily'
priority = 0.9

def item(self):
return Status.objects.filter(status=0)

def lastmod(self, obj):


url.py



sitemaps = 
'posts': PostSitemap,
'status': StatusSitemap

urlpatterns = [ path('sitemap.xml/', sitemap, 'sitemaps': sitemaps,
name='sitemaps'),]


Don't know why is this showing error 500



UPDATE
Tarckbacks -
enter image description here







django django-2.1






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 15:34

























asked Nov 12 at 12:16









Abhijeet Pal

3619




3619











  • Show us the full traceback for the error. If you haven't configured django to log the error to a file, do that first. You should always have an error log on your production machine.
    – dirkgroten
    Nov 12 at 13:09











  • Currently, the site is live, I noticed one thing in my local computer when the debug = False it's generating the site map, but when Debug is True it throws ERROR 500
    – Abhijeet Pal
    Nov 12 at 13:12










  • It doesn't matter that the site is live, you should still log your errors to disk (or use a service like Sentry) so you can view them. There's always going to be situations where something happens on a live site that you didn't plan for (because live data is different than local data) and then you'll want to have a trace of the error. Otherwise there's no way to debug.
    – dirkgroten
    Nov 12 at 13:13











  • First of all thanks a ton for that awesome suggestion okay I got this error ` raise TemplateDoesNotExist(template_name, chain=chain)` How to resolve it?
    – Abhijeet Pal
    Nov 12 at 15:17










  • can you post the full trace here? (not in a comment but in your question, otherwise it'll be impossible to read)
    – dirkgroten
    Nov 12 at 15:18
















  • Show us the full traceback for the error. If you haven't configured django to log the error to a file, do that first. You should always have an error log on your production machine.
    – dirkgroten
    Nov 12 at 13:09











  • Currently, the site is live, I noticed one thing in my local computer when the debug = False it's generating the site map, but when Debug is True it throws ERROR 500
    – Abhijeet Pal
    Nov 12 at 13:12










  • It doesn't matter that the site is live, you should still log your errors to disk (or use a service like Sentry) so you can view them. There's always going to be situations where something happens on a live site that you didn't plan for (because live data is different than local data) and then you'll want to have a trace of the error. Otherwise there's no way to debug.
    – dirkgroten
    Nov 12 at 13:13











  • First of all thanks a ton for that awesome suggestion okay I got this error ` raise TemplateDoesNotExist(template_name, chain=chain)` How to resolve it?
    – Abhijeet Pal
    Nov 12 at 15:17










  • can you post the full trace here? (not in a comment but in your question, otherwise it'll be impossible to read)
    – dirkgroten
    Nov 12 at 15:18















Show us the full traceback for the error. If you haven't configured django to log the error to a file, do that first. You should always have an error log on your production machine.
– dirkgroten
Nov 12 at 13:09





Show us the full traceback for the error. If you haven't configured django to log the error to a file, do that first. You should always have an error log on your production machine.
– dirkgroten
Nov 12 at 13:09













Currently, the site is live, I noticed one thing in my local computer when the debug = False it's generating the site map, but when Debug is True it throws ERROR 500
– Abhijeet Pal
Nov 12 at 13:12




Currently, the site is live, I noticed one thing in my local computer when the debug = False it's generating the site map, but when Debug is True it throws ERROR 500
– Abhijeet Pal
Nov 12 at 13:12












It doesn't matter that the site is live, you should still log your errors to disk (or use a service like Sentry) so you can view them. There's always going to be situations where something happens on a live site that you didn't plan for (because live data is different than local data) and then you'll want to have a trace of the error. Otherwise there's no way to debug.
– dirkgroten
Nov 12 at 13:13





It doesn't matter that the site is live, you should still log your errors to disk (or use a service like Sentry) so you can view them. There's always going to be situations where something happens on a live site that you didn't plan for (because live data is different than local data) and then you'll want to have a trace of the error. Otherwise there's no way to debug.
– dirkgroten
Nov 12 at 13:13













First of all thanks a ton for that awesome suggestion okay I got this error ` raise TemplateDoesNotExist(template_name, chain=chain)` How to resolve it?
– Abhijeet Pal
Nov 12 at 15:17




First of all thanks a ton for that awesome suggestion okay I got this error ` raise TemplateDoesNotExist(template_name, chain=chain)` How to resolve it?
– Abhijeet Pal
Nov 12 at 15:17












can you post the full trace here? (not in a comment but in your question, otherwise it'll be impossible to read)
– dirkgroten
Nov 12 at 15:18




can you post the full trace here? (not in a comment but in your question, otherwise it'll be impossible to read)
– dirkgroten
Nov 12 at 15:18












1 Answer
1






active

oldest

votes


















0














Okay In case someone was dumb enough to repeat this silly mistake like me!



Dear, you have forgotten to add 'django.contrib.sitemaps', in you INSTALLED APPS.






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262018%2fdjango-sitemap-xml-throwing-server-error-500-in-production%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Okay In case someone was dumb enough to repeat this silly mistake like me!



    Dear, you have forgotten to add 'django.contrib.sitemaps', in you INSTALLED APPS.






    share|improve this answer

























      0














      Okay In case someone was dumb enough to repeat this silly mistake like me!



      Dear, you have forgotten to add 'django.contrib.sitemaps', in you INSTALLED APPS.






      share|improve this answer























        0












        0








        0






        Okay In case someone was dumb enough to repeat this silly mistake like me!



        Dear, you have forgotten to add 'django.contrib.sitemaps', in you INSTALLED APPS.






        share|improve this answer












        Okay In case someone was dumb enough to repeat this silly mistake like me!



        Dear, you have forgotten to add 'django.contrib.sitemaps', in you INSTALLED APPS.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 15:48









        Abhijeet Pal

        3619




        3619



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262018%2fdjango-sitemap-xml-throwing-server-error-500-in-production%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Barbados

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3