1๐
โ
I forgot to remove the square brackets in python manage.py ping_google [/sitemap.xml]
which causes the command to not work.
๐คEliot S Winchell
1๐
You can try with requests, which is much easier to understand:
PING_URL = "http://www.google.com/webmasters/tools/ping"
def ping_google(sitemap_url=None, ping_url=PING_URL):
if not sitemap_url:
raise Exception('sitemap url must be given')
current_site = Site.objects.get_current()
url = "http://%s%s" % (current_site.domain, sitemap_url)
requests.get(
ping_url, params={'sitemap': url}
)
the original ping_google function lives here:
...\site-packages\django\contrib\sitemaps\__init__.py
๐คdoniyor
- [Answered ]-Uploading a file does not work properly in Django
- [Answered ]-In Django how do I get code to run after an object is saved and after its many to many relationships are made?
- [Answered ]-Django Templates and drop-down list
0๐
If you want to run the command directly from the view:
from django.core.management import call_command
def daily_crons_view(request):
# Ping Google
return call_command('ping_google [/sitemap.xml]')
๐คYousef Alm
- [Answered ]-Django CMS Aldryn Create Wizard database error
- [Answered ]-Django frontend and backend seperation for security
Source:stackexchange.com