{"id":471081,"date":"2025-08-18T09:00:41","date_gmt":"2025-08-18T09:00:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=471081"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=471081","title":{"rendered":"<span>\u041a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 Django \u043a S3 \u043e\u0442 Yandex<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u044b\u0431\u0440\u0430\u043b \u0441\u0435\u0440\u0432\u0438\u0441 Yandex Object Storage (S3) \u0434\u043b\u044f \u043c\u0435\u0434\u0438\u0430 (\u0444\u043e\u0442\u043e) \u0438 \u0441\u0442\u0430\u0442\u0438\u043a\u0438. \u041f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043f\u0430\u0440\u0443 \u0434\u043d\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c. \u0421\u0442\u0430\u0442\u044c\u044e \u043e\u0442 \u042f\u043d\u0434\u0435\u043a\u0441\u0430 \u043d\u0435 \u043d\u0430\u0448\u0435\u043b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043f\u0430\u0440\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0441\u0430\u0439\u0442\u043e\u0432 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0441 Chat GPT.  \u0418 \u0432\u043e\u0442 \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u0442\u0430\u0442\u044c\u044e.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 Django.  \u041f\u043e \u0438\u0434\u0435\u0435 \u0432 settings.py \u0443 \u0432\u0430\u0441 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\"># \u043c\u0435\u0434\u0438\u0430 \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 STATIC_URL = \"static\/\" STATICFILES_DIRS = [     os.path.join(BASE_DIR, \"static\"), ] MEDIA_ROOT = f\"{BASE_DIR}\/media\" MEDIA_URL = \"\/media\/\"<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 Yandex Cloud. \u0412\u044b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 Identity and Access Management \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0433\u043e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430. <\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6eb\/b7c\/48c\/6ebb7c48c1fb5f82efa35ce43943782f.png\" alt=\"\" title=\"\" width=\"1298\" height=\"630\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/6eb\/b7c\/48c\/6ebb7c48c1fb5f82efa35ce43943782f.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6eb\/b7c\/48c\/6ebb7c48c1fb5f82efa35ce43943782f.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/670\/a55\/fb4\/670a55fb49211d3f11735c3606f06b22.png\" width=\"1296\" height=\"634\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/670\/a55\/fb4\/670a55fb49211d3f11735c3606f06b22.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/670\/a55\/fb4\/670a55fb49211d3f11735c3606f06b22.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0ee\/174\/52a\/0ee17452a3132bc1f70feea485961673.png\" alt=\"\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0440\u043e\u043b\u044c Admin\" title=\"\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0440\u043e\u043b\u044c Admin\" width=\"1290\" height=\"614\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/0ee\/174\/52a\/0ee17452a3132bc1f70feea485961673.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0ee\/174\/52a\/0ee17452a3132bc1f70feea485961673.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0440\u043e\u043b\u044c Admin<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0439 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u044e\u0447 (\u0437\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: ID \u0438 \u041a\u043b\u044e\u0447)<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/28e\/535\/39b\/28e53539b221b61c2be51cdeaf8d1fa5.png\" width=\"1314\" height=\"642\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/28e\/535\/39b\/28e53539b221b61c2be51cdeaf8d1fa5.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/28e\/535\/39b\/28e53539b221b61c2be51cdeaf8d1fa5.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 Object Storage \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0430\u043a\u0435\u0442. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 (\u0434\u043e\u0441\u0442\u0443\u043f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d, \u043e\u0431\u044a\u0451\u043c \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d)<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e52\/b15\/f05\/e52b15f0534e4a507c60a90472e4e48f.png\" width=\"1294\" height=\"622\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e52\/b15\/f05\/e52b15f0534e4a507c60a90472e4e48f.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e52\/b15\/f05\/e52b15f0534e4a507c60a90472e4e48f.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0431\u0430\u043a\u0435\u0442. \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u041d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0440\u043e\u043b\u0438.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/891\/4ff\/5d8\/8914ff5d81635d50537e92f0f2fa8433.png\" width=\"1294\" height=\"634\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/891\/4ff\/5d8\/8914ff5d81635d50537e92f0f2fa8433.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/891\/4ff\/5d8\/8914ff5d81635d50537e92f0f2fa8433.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u043c\u0443 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0443 \u0440\u043e\u043b\u044c Admin. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a Django (settings.py).<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442\u044b django-storages \u0438 boto3. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 &#8216;storages&#8217; \u0432 INSTALLED_APPS.<\/p>\n<pre><code class=\"python\">INSTALLED_APPS = [     ...,     'storages', ]<\/code><\/pre>\n<pre><code class=\"python\"># \u043c\u0435\u0434\u0438\u0430 \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 # STATIC_URL = \"static\/\" # STATICFILES_DIRS = [ #     os.path.join(BASE_DIR, \"static\"), # ] # MEDIA_ROOT = f\"{BASE_DIR}\/media\" # MEDIA_URL = \"\/media\/\"  # \u0441\u0432\u044f\u0437\u044c \u0441 Yandex S3 (\u0441\u0442\u0430\u0442\u0438\u043a\u0430) AWS_S3_ACCESS_KEY_ID = \"\u0432\u0430\u0448 key_id\" AWS_S3_SECRET_ACCESS_KEY = \"\u0432\u0430\u0448 \u043a\u043b\u044e\u0447\" AWS_STORAGE_BUCKET_NAME = \"\u0438\u043c\u044f \u0431\u0430\u043a\u0435\u0442\u0430\" AWS_S3_ENDPOINT_URL = \"https:\/\/storage.yandexcloud.net\" AWS_S3_CUSTOM_DOMAIN = f\"storage.yandexcloud.net\/{AWS_STORAGE_BUCKET_NAME}\" AWS_S3_OBJECT_PARAMETERS = {     \"CacheControl\": \"max-age=86400\", } STATIC_URL = f\"https:\/\/{AWS_S3_CUSTOM_DOMAIN}\/static\/\" MEDIA_URL = f\"https:\/\/{AWS_S3_CUSTOM_DOMAIN}\/media\/\" DEFAULT_FILE_STORAGE = \"online_store.s3_storage.MediaStorage\" STATICFILES_STORAGE = \"online_store.s3_storage.StaticStorage\" <\/code><\/pre>\n<p>\u0412 \u0442\u043e\u0439 \u0436\u0435 \u043f\u0430\u043f\u043a\u0435, \u0433\u0434\u0435 settings.py \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b s3_storage.py. \u041a\u043e\u0434 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"python\">from storages.backends.s3boto3 import S3Boto3Storage  class MediaStorage(S3Boto3Storage):     location = \"media\" #\u043f\u0430\u043f\u043a\u0430 \u0432 \u0431\u0430\u043a\u0435\u0442\u0435     file_overwrite = False #\u0437\u0430\u043f\u0440\u0435\u0442 \u043d\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044c \u0444\u0430\u0439\u043b\u043e\u0432   class StaticStorage(S3Boto3Storage):     location = \"static\"     file_overwrite = False <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<p>python manage.py collectsatic \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435 \ud83d\ude42<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/938040\/\"> https:\/\/habr.com\/ru\/articles\/938040\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u044b\u0431\u0440\u0430\u043b \u0441\u0435\u0440\u0432\u0438\u0441 Yandex Object Storage (S3) \u0434\u043b\u044f \u043c\u0435\u0434\u0438\u0430 (\u0444\u043e\u0442\u043e) \u0438 \u0441\u0442\u0430\u0442\u0438\u043a\u0438. \u041f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043f\u0430\u0440\u0443 \u0434\u043d\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c. \u0421\u0442\u0430\u0442\u044c\u044e \u043e\u0442 \u042f\u043d\u0434\u0435\u043a\u0441\u0430 \u043d\u0435 \u043d\u0430\u0448\u0435\u043b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043f\u0430\u0440\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0441\u0430\u0439\u0442\u043e\u0432 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0441 Chat GPT.  \u0418 \u0432\u043e\u0442 \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u0442\u0430\u0442\u044c\u044e.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 Django.  \u041f\u043e \u0438\u0434\u0435\u0435 \u0432 settings.py \u0443 \u0432\u0430\u0441 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\"># \u043c\u0435\u0434\u0438\u0430 \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 STATIC_URL = \"static\/\" STATICFILES_DIRS = [     os.path.join(BASE_DIR, \"static\"), ] MEDIA_ROOT = f\"{BASE_DIR}\/media\" MEDIA_URL = \"\/media\/\"<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 Yandex Cloud. \u0412\u044b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 Identity and Access Management \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0433\u043e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430. <\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\">\n<div><figcaption>\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0440\u043e\u043b\u044c Admin<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0439 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u044e\u0447 (\u0437\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: ID \u0438 \u041a\u043b\u044e\u0447)<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 Object Storage \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0430\u043a\u0435\u0442. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 (\u0434\u043e\u0441\u0442\u0443\u043f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d, \u043e\u0431\u044a\u0451\u043c \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d)<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0431\u0430\u043a\u0435\u0442. \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u041d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0440\u043e\u043b\u0438.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u043c\u0443 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0443 \u0440\u043e\u043b\u044c Admin. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a Django (settings.py).<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442\u044b django-storages \u0438 boto3. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 &#8216;storages&#8217; \u0432 INSTALLED_APPS.<\/p>\n<pre><code class=\"python\">INSTALLED_APPS = [     ...,     'storages', ]<\/code><\/pre>\n<pre><code class=\"python\"># \u043c\u0435\u0434\u0438\u0430 \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 # STATIC_URL = \"static\/\" # STATICFILES_DIRS = [ #     os.path.join(BASE_DIR, \"static\"), # ] # MEDIA_ROOT = f\"{BASE_DIR}\/media\" # MEDIA_URL = \"\/media\/\"  # \u0441\u0432\u044f\u0437\u044c \u0441 Yandex S3 (\u0441\u0442\u0430\u0442\u0438\u043a\u0430) AWS_S3_ACCESS_KEY_ID = \"\u0432\u0430\u0448 key_id\" AWS_S3_SECRET_ACCESS_KEY = \"\u0432\u0430\u0448 \u043a\u043b\u044e\u0447\" AWS_STORAGE_BUCKET_NAME = \"\u0438\u043c\u044f \u0431\u0430\u043a\u0435\u0442\u0430\" AWS_S3_ENDPOINT_URL = \"https:\/\/storage.yandexcloud.net\" AWS_S3_CUSTOM_DOMAIN = f\"storage.yandexcloud.net\/{AWS_STORAGE_BUCKET_NAME}\" AWS_S3_OBJECT_PARAMETERS = {     \"CacheControl\": \"max-age=86400\", } STATIC_URL = f\"https:\/\/{AWS_S3_CUSTOM_DOMAIN}\/static\/\" MEDIA_URL = f\"https:\/\/{AWS_S3_CUSTOM_DOMAIN}\/media\/\" DEFAULT_FILE_STORAGE = \"online_store.s3_storage.MediaStorage\" STATICFILES_STORAGE = \"online_store.s3_storage.StaticStorage\" <\/code><\/pre>\n<p>\u0412 \u0442\u043e\u0439 \u0436\u0435 \u043f\u0430\u043f\u043a\u0435, \u0433\u0434\u0435 settings.py \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b s3_storage.py. \u041a\u043e\u0434 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"python\">from storages.backends.s3boto3 import S3Boto3Storage  class MediaStorage(S3Boto3Storage):     location = \"media\" #\u043f\u0430\u043f\u043a\u0430 \u0432 \u0431\u0430\u043a\u0435\u0442\u0435     file_overwrite = False #\u0437\u0430\u043f\u0440\u0435\u0442 \u043d\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044c \u0444\u0430\u0439\u043b\u043e\u0432   class StaticStorage(S3Boto3Storage):     location = \"static\"     file_overwrite = False <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<p>python manage.py collectsatic \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435 \ud83d\ude42<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/938040\/\"> https:\/\/habr.com\/ru\/articles\/938040\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-471081","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/471081","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=471081"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/471081\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=471081"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=471081"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=471081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}