{"title":"Często zadawane pytania: Używanie Django","version":"1.10","locale":"pl","docname":"faq/usage","url":"/pl/1.10/faq/usage/","canonical":"https://djangodocs.dev/pl/1.10/faq/usage/","summary":"Dlaczego otrzymuję błąd dotyczący dołączania DJANGO_SETTINGS_MODULE? Link to this heading # Upewnij się, że: Zmienna środowiskowa DJANGO_SETTINGS_MODULE jest…","html":"<h1>Często zadawane pytania: Używanie Django<a class=\"heading-anchor\" href=\"#faq-using-django\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<section id=\"why-do-i-get-an-error-about-importing-django-settings-module\">\n<h2>Dlaczego otrzymuję błąd dotyczący dołączania DJANGO_SETTINGS_MODULE?<a class=\"heading-anchor\" href=\"#why-do-i-get-an-error-about-importing-django-settings-module\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Upewnij się, że:</p>\n<ul class=\"simple\">\n<li><p>Zmienna środowiskowa DJANGO_SETTINGS_MODULE jest ustawiona na w pełni kwalifikowany moduł Pythona (np. „mysite.settings”).</p></li>\n<li><p>Wspomniany moduł jest na <code class=\"docutils literal notranslate\"><span class=\"pre\">sys.path</span></code> (<code class=\"docutils literal notranslate\"><span class=\"pre\">import</span> <span class=\"pre\">mysite.settings</span></code> powinno zadziałać).</p></li>\n<li><p>Moduł nie zawiera błędów składniowych (oczywiście).</p></li>\n</ul>\n</section>\n<section id=\"i-can-t-stand-your-template-language-do-i-have-to-use-it\">\n<h2>Nie mogę znieść waszego języka szablonów. Czy muszę go używać?<a class=\"heading-anchor\" href=\"#i-can-t-stand-your-template-language-do-i-have-to-use-it\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>We happen to think our template engine is the best thing since chunky bacon,\nbut we recognize that choosing a template language runs close to religion.\nThere’s nothing about Django that requires using the template language, so\nif you’re attached to Jinja2, Mako, or whatever, feel free to use those.</p>\n</section>\n<section id=\"do-i-have-to-use-your-model-database-layer\">\n<h2>Czy muszę używać waszej warstwy modelu/bazy danych?<a class=\"heading-anchor\" href=\"#do-i-have-to-use-your-model-database-layer\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Nie. Tak jak system szablonów, warstwa modelu/bazy danych jest uniezależniona od reszty frameworka.</p>\n<p>The one exception is: If you use a different database library, you won’t get to\nuse Django’s automatically-generated admin site. That app is coupled to the\nDjango database layer.</p>\n</section>\n<section id=\"how-do-i-use-image-and-file-fields\">\n<h2>Jak używać pól grafik i plików?<a class=\"heading-anchor\" href=\"#how-do-i-use-image-and-file-fields\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Użycie klas <a class=\"reference internal\" href=\"/pl/1.10/ref/models/fields/#django.db.models.FileField\" title=\"django.db.models.FileField\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">FileField</span></code></a> lub <a class=\"reference internal\" href=\"/pl/1.10/ref/models/fields/#django.db.models.ImageField\" title=\"django.db.models.ImageField\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">ImageField</span></code></a> w modelu wymaga kilku kroków:</p>\n<ol class=\"arabic simple\">\n<li><p>In your settings file, you’ll need to define <a class=\"reference internal\" href=\"/pl/1.10/ref/settings/#std-setting-MEDIA_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MEDIA_ROOT</span></code></a> as\nthe full path to a directory where you’d like Django to store uploaded\nfiles. (For performance, these files are not stored in the database.)\nDefine <a class=\"reference internal\" href=\"/pl/1.10/ref/settings/#std-setting-MEDIA_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MEDIA_URL</span></code></a> as the base public URL of that directory.\nMake sure that this directory is writable by the Web server’s user\naccount.</p></li>\n<li><p>Add the <a class=\"reference internal\" href=\"/pl/1.10/ref/models/fields/#django.db.models.FileField\" title=\"django.db.models.FileField\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">FileField</span></code></a> or\n<a class=\"reference internal\" href=\"/pl/1.10/ref/models/fields/#django.db.models.ImageField\" title=\"django.db.models.ImageField\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">ImageField</span></code></a> to your model, defining the\n<a class=\"reference internal\" href=\"/pl/1.10/ref/models/fields/#django.db.models.FileField.upload_to\" title=\"django.db.models.FileField.upload_to\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">upload_to</span></code></a> option to specify a\nsubdirectory of <a class=\"reference internal\" href=\"/pl/1.10/ref/settings/#std-setting-MEDIA_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MEDIA_ROOT</span></code></a> to use for uploaded files.</p></li>\n<li><p>All that will be stored in your database is a path to the file\n(relative to <a class=\"reference internal\" href=\"/pl/1.10/ref/settings/#std-setting-MEDIA_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MEDIA_ROOT</span></code></a>). You’ll most likely want to use the\nconvenience <a class=\"reference internal\" href=\"/pl/1.10/ref/models/fields/#django.db.models.fields.files.FieldFile.url\" title=\"django.db.models.fields.files.FieldFile.url\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">url</span></code></a> attribute\nprovided by Django. For example, if your\n<a class=\"reference internal\" href=\"/pl/1.10/ref/models/fields/#django.db.models.ImageField\" title=\"django.db.models.ImageField\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">ImageField</span></code></a> is called <code class=\"docutils literal notranslate\"><span class=\"pre\">mug_shot</span></code>, you can get\nthe absolute path to your image in a template with\n<code class=\"docutils literal notranslate\"><span class=\"pre\">{{</span> <span class=\"pre\">object.mug_shot.url</span> <span class=\"pre\">}}</span></code>.</p></li>\n</ol>\n</section>\n<section id=\"how-do-i-make-a-variable-available-to-all-my-templates\">\n<h2>Jak stworzyć zmienną dostępną we wszystkich moich szablonach?<a class=\"heading-anchor\" href=\"#how-do-i-make-a-variable-available-to-all-my-templates\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Sometimes your templates just all need the same thing. A common example would\nbe dynamically-generated menus. At first glance, it seems logical to simply\nadd a common dictionary to the template context.</p>\n<p>Poprawnym rozwiązaniem jest użycie <code class=\"docutils literal notranslate\"><span class=\"pre\">RequestContext</span></code>. Szczegóły odnośnie jego użycia znajdziesz tutaj: <a class=\"reference internal\" href=\"/pl/1.10/ref/templates/api/#subclassing-context-requestcontext\"><span class=\"std std-ref\">Using RequestContext</span></a>.</p>\n</section>","rootId":"faq-using-django","toc":[{"title":"Dlaczego otrzymuję błąd dotyczący dołączania DJANGO_SETTINGS_MODULE?","anchor":"why-do-i-get-an-error-about-importing-django-settings-module","children":[]},{"title":"Nie mogę znieść waszego języka szablonów. Czy muszę go używać?","anchor":"i-can-t-stand-your-template-language-do-i-have-to-use-it","children":[]},{"title":"Czy muszę używać waszej warstwy modelu/bazy danych?","anchor":"do-i-have-to-use-your-model-database-layer","children":[]},{"title":"Jak używać pól grafik i plików?","anchor":"how-do-i-use-image-and-file-fields","children":[]},{"title":"Jak stworzyć zmienną dostępną we wszystkich moich szablonach?","anchor":"how-do-i-make-a-variable-available-to-all-my-templates","children":[]}],"breadcrumbs":[{"docname":"faq/index","title":"Często zadawane pytania odnośnie Django","url":"/pl/1.10/faq/"}],"prev":{"docname":"faq/install","title":"Często zadawane pytania: Instalacja","url":"/pl/1.10/faq/install/"},"next":{"docname":"faq/help","title":"Często zadawane pytania: Czerpanie pomocy","url":"/pl/1.10/faq/help/"},"formats":{"html":"/pl/1.10/faq/usage/","markdown":"/pl/1.10/faq/usage.md","json":"/pl/1.10/faq/usage.json"},"source":"https://github.com/django/django/blob/stable/1.10.x/docs/faq/usage.txt","official":"https://docs.djangoproject.com/pl/1.10/faq/usage/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10"],"inLocales":["en","fr","ja","id","pt-br","es","el","pl"]}