0Pricing
Django Academy · Ders

Üretim için collectstatic

Dağıtım için statik dosyaları toplayın.

Üretim için collectstatic, CoddyKit'te ücretsiz bir Django Academy dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Django Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Django Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Dev vs Production

In development Django finds and serves static files for you. In production that auto-serving is off, so you must gather assets into one place first.

Meet collectstatic

The collectstatic command copies every static file from every app into a single output folder, ready for a web server to serve fast.

python manage.py collectstatic

The STATIC_ROOT Target

collectstatic needs a destination. The STATIC_ROOT setting points to the single folder where all collected files will be written.

STATIC_ROOT = BASE_DIR / 'staticfiles'

Keep Roots Separate

Never set STATIC_ROOT to a folder you edit by hand. It is a generated output directory, rebuilt on every collectstatic run.

What It Gathers

collectstatic pulls from each app's static folder and from STATICFILES_DIRS, merging them all into STATIC_ROOT in one pass.

Skip the Prompt

By default it asks before overwriting. In a deploy script add --noinput so it runs unattended without waiting for you.

python manage.py collectstatic --noinput

When to Run It

Run collectstatic on every deploy, after pulling new code. New or changed CSS and JS only reach users once they are collected.

Cache Busting

The ManifestStaticFilesStorage backend adds a content hash to each filename, so browsers always fetch the newest version after a deploy.

STATICFILES_STORAGE = (
  'django.contrib.staticfiles.storage'
  '.ManifestStaticFilesStorage')

Who Serves Them

Django itself does not serve STATIC_ROOT in production. A web server like Nginx or a tool like WhiteNoise delivers those files instead.

Ignore Build Junk

Add --ignore patterns to skip files you do not want copied, like source maps or scratch files left in a static folder.

python manage.py collectstatic --ignore=*.scss

Git and STATIC_ROOT

Since STATIC_ROOT is generated, add it to .gitignore. You commit your source assets, not the collected copies.

Quick Check

Let us confirm the role of collectstatic.

Recap

You saw that production needs collectstatic to merge assets into STATIC_ROOT, that you run it each deploy, and that a web server serves the result. 🚀

Sıkça Sorulan Sorular

“Üretim için collectstatic” dersi ücretsiz mi?

Evet — “Üretim için collectstatic” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Django Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Django Academy kursu toplamda 4 dersten oluşur.

“Üretim için collectstatic” dersinde ne öğreneceğim?

Dağıtım için statik dosyaları toplayın. Django Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Django Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Django Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.

“Üretim için collectstatic” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Django Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Django Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. STATICFILES ve static Etiketi
  2. Üretim için collectstatic
  3. MEDIA_ROOT ve Dosya Yüklemeleri
  4. ImageField ve Yüklemeleri Sunma
← Django Academy Sayfasına Dön