How to upload any files to the root of the site on Django?

those. For example, I need now in the root lay verification html file from YouTube, then you need robots.txt and a site map.

Suppose this is all text files and I can do this using the view and url settings in urls.py. But somehow I want it to be just static files.

In addition, what if you need to have an archive, a picture, or any other file in the root?

Now in my settings: STATIC_URL = '/ static /' this would be left unchanged ..

    1 answer 1

    You put robots.txt in /static/ and in the settings of the web server you set the redirect from /robots.txt to /static/robots.txt

    Stackoverflow English replies to the topic: Where to put the root files? and Django serving robots.txt efficiently

    • Thanks for the answer! but I also don’t like the solution with editing the web server settings .. and the server is not mine, and I’ll have to constantly write something there .. in the link provided by you (1) I found a solution via urls.py to configure the redirect to the desired file. I did this: created a static / root_dir folder in the main urls.py added: url(r'^(?P<file_name>[a-zA-Z0-9_]*)\.(?P<file_type>.*)$', RedirectView.as_view( url=settings.STATIC_URL + 'root_dir/%(file_name)s.%(file_type)s/')), Normal solution? those. we get a universal option for any files - Vladimir
    • and is this, in principle, normal? when redirecting to another address is used. Yandex \ Google will react to this normally by referring redirects to robot.txt? - Vladimir
    • The normal solution and the normal should be: developers.google.com/webmasters/control-crawl-index/docs/… see the Forwarding section. You can test here support.google.com/webmasters/answer/6062598?hl=en and here webmaster.yandex.ru/robots.xml - Pavel Karateev