How to fix with a Django based website the AdSense: Earnings at risk - One or more of your sites does not have an ads.txt file ?


Example of quickly fix with a django based web site the google Adsense warning message: "Earnings at risk - One or more of your sites does not have an ads.txt file". Just add the following url:

url(r'^ads\.txt$', views.authorized_digital_sellers_view, name='authorized_digital_sellers'),

and add the view:

def authorized_digital_sellers_view(request):
    return HttpResponse('google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0')

replace pub-0000000000000000 by your publisher id that can be found on the google adsense account in the menu: Account -> Account Information.

Note: It take about 24 hours to be taken into account.

References