<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Matúš Kočik</title>
    <description>The latest articles on Forem by Matúš Kočik (@matus-kocik).</description>
    <link>https://forem.com/matus-kocik</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2829187%2Fb77756e0-3ea6-4e69-ae81-f36f3de6b7f5.jpg</url>
      <title>Forem: Matúš Kočik</title>
      <link>https://forem.com/matus-kocik</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/matus-kocik"/>
    <language>en</language>
    <item>
      <title>My Preconfigured Django Template: Part 4 - Python-Decouple</title>
      <dc:creator>Matúš Kočik</dc:creator>
      <pubDate>Fri, 14 Feb 2025 18:21:04 +0000</pubDate>
      <link>https://forem.com/matus-kocik/my-preconfigured-django-template-part-4-python-decouple-1bg0</link>
      <guid>https://forem.com/matus-kocik/my-preconfigured-django-template-part-4-python-decouple-1bg0</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;What is Python-Decouple?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Python-Decouple is a simple yet powerful tool that helps manage Django configuration settings securely. Instead of hardcoding secrets like SECRET_KEY or database credentials in settings.py, it allows you to store them in environment variables or a .env file, keeping your codebase clean and safe.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why Use Python-Decouple?&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Better security&lt;/strong&gt; – Keeps sensitive data out of your code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy environment switching&lt;/strong&gt; – Quickly adapt configurations for development, staging, and production.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Less clutter in settings.py&lt;/strong&gt; – Keeps settings organized and modular.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic type conversion&lt;/strong&gt; – Easily manage strings, integers, and lists.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Seamless integration&lt;/strong&gt; – Works with Django, CI/CD pipelines, and containerized deployments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Quick Commands&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install Python-Decouple&lt;/span&gt;

uv add python-decouple
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create a .env file and store secrets

SECRET_KEY=mysecretkey
DEBUG=True
DATABASE_NAME=mydatabase
DATABASE_USER=myuser
DATABASE_PASSWORD=mypassword
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Use Python-Decouple in settings.py
&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;decouple&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;

&lt;span class="n"&gt;SECRET_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SECRET_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;DEBUG&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DEBUG&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cast&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;DATABASES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;default&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ENGINE&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;django.db.backends.postgresql&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;NAME&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DATABASE_NAME&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;USER&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DATABASE_USER&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;PASSWORD&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DATABASE_PASSWORD&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HOST&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;localhost&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;PORT&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5432&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;📖 &lt;strong&gt;&lt;a href="https://medium.com/@matus-kocik/my-preconfigured-django-template-part-4-python-decouple-6c3c7c3a5144" rel="noopener noreferrer"&gt;Read the full article on Medium&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  🔗 &lt;strong&gt;Follow me on:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;🌍 &lt;a href="https://www.matuskocik.com" rel="noopener noreferrer"&gt;My Website&lt;/a&gt;&lt;br&gt;&lt;br&gt;
💻 &lt;a href="https://github.com/matus-kocik" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;br&gt;&lt;br&gt;
🤝 &lt;a href="https://www.linkedin.com/in/matuskocik/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;&lt;br&gt;
✍️ &lt;a href="https://medium.com/@matus-kocik" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;  &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>python</category>
      <category>django</category>
    </item>
    <item>
      <title>My Preconfigured Django Template: Part 3 - Django Extensions</title>
      <dc:creator>Matúš Kočik</dc:creator>
      <pubDate>Fri, 07 Feb 2025 10:31:39 +0000</pubDate>
      <link>https://forem.com/matus-kocik/my-preconfigured-django-template-part-3-django-extensions-452k</link>
      <guid>https://forem.com/matus-kocik/my-preconfigured-django-template-part-3-django-extensions-452k</guid>
      <description>&lt;p&gt;Django Extensions is a powerful package that provides &lt;strong&gt;extra management commands&lt;/strong&gt; to improve development efficiency. It adds features that make debugging, scripting, and database management much easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why Use Django Extensions?&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Generate a secret key&lt;/strong&gt; instantly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced Django shell&lt;/strong&gt; (&lt;code&gt;shell_plus&lt;/code&gt;) for faster model imports&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visualize models&lt;/strong&gt; with &lt;code&gt;graph_models&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run custom scripts&lt;/strong&gt; easily with &lt;code&gt;runscript&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Quick Commands&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install Django Extensions&lt;/span&gt;
uv add django-extensions

&lt;span class="c"&gt;# Generate a secret key&lt;/span&gt;
uv run python manage.py generate_secret_key

&lt;span class="c"&gt;# Open improved shell&lt;/span&gt;
uv run python manage.py shell_plus

&lt;span class="c"&gt;# Create a model graph&lt;/span&gt;
uv run python manage.py graph_models &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; models.png
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Django Extensions &lt;strong&gt;saves time and simplifies development&lt;/strong&gt;, making it a great addition to any Django project.&lt;/p&gt;

&lt;p&gt;📖 &lt;strong&gt;&lt;a href="https://medium.com/@matus-kocik/my-preconfigured-django-template-part-3-django-extensions-7aea559ecbb9" rel="noopener noreferrer"&gt;Read the full article on Medium&lt;/a&gt;&lt;/strong&gt;  &lt;/p&gt;




&lt;h3&gt;
  
  
  🔗 &lt;strong&gt;Follow me on:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;🌍 &lt;a href="https://www.matuskocik.com" rel="noopener noreferrer"&gt;My Website&lt;/a&gt;&lt;br&gt;&lt;br&gt;
💻 &lt;a href="https://github.com/matus-kocik" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;br&gt;&lt;br&gt;
🤝 &lt;a href="https://www.linkedin.com/in/matuskocik/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;&lt;br&gt;
✍️ &lt;a href="https://medium.com/@matus-kocik" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;  &lt;/p&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>My Preconfigured Django Template: Part 2 - UV Astral</title>
      <dc:creator>Matúš Kočik</dc:creator>
      <pubDate>Fri, 07 Feb 2025 10:29:01 +0000</pubDate>
      <link>https://forem.com/matus-kocik/my-preconfigured-django-template-part-2-uv-astral-5b0n</link>
      <guid>https://forem.com/matus-kocik/my-preconfigured-django-template-part-2-uv-astral-5b0n</guid>
      <description>&lt;p&gt;Dependency management in Python can sometimes be a hassle, especially when working across different environments. &lt;strong&gt;UV Astral&lt;/strong&gt; simplifies this by providing a &lt;strong&gt;faster and more reliable&lt;/strong&gt; way to handle dependencies and Python versions.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What Makes UV Astral Special?&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;10-100x faster&lt;/strong&gt; than &lt;code&gt;pip&lt;/code&gt; 🚀&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manages Python versions&lt;/strong&gt; easily&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Locks dependencies&lt;/strong&gt; for consistency&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Creates virtual environments automatically&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replaces multiple tools&lt;/strong&gt; like &lt;code&gt;pip&lt;/code&gt;, &lt;code&gt;virtualenv&lt;/code&gt;, and &lt;code&gt;poetry&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Practical UV Astral Commands&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install dependencies&lt;/span&gt;
uv &lt;span class="nb"&gt;sync&lt;/span&gt;

&lt;span class="c"&gt;# Run the Django server&lt;/span&gt;
uv run python manage.py runserver

&lt;span class="c"&gt;# Install a new package&lt;/span&gt;
uv add django

&lt;span class="c"&gt;# Export dependencies&lt;/span&gt;
uv &lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nt"&gt;--output-file&lt;/span&gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;strong&gt;UV Astral&lt;/strong&gt; in my Django template has made my projects &lt;strong&gt;faster and easier to manage&lt;/strong&gt;. If you want to learn more, check out the full article.&lt;/p&gt;

&lt;p&gt;📖 &lt;strong&gt;&lt;a href="https://medium.com/@matus-kocik/my-preconfigured-django-template-01b0f445a9fa" rel="noopener noreferrer"&gt;Read the full article on Medium&lt;/a&gt;&lt;/strong&gt;  &lt;/p&gt;




&lt;h3&gt;
  
  
  🔗 &lt;strong&gt;Follow me on:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;🌍 &lt;a href="https://www.matuskocik.com" rel="noopener noreferrer"&gt;My Website&lt;/a&gt;&lt;br&gt;&lt;br&gt;
💻 &lt;a href="https://github.com/matus-kocik" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;br&gt;&lt;br&gt;
🤝 &lt;a href="https://www.linkedin.com/in/matuskocik/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;&lt;br&gt;
✍️ &lt;a href="https://medium.com/@matus-kocik" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;  &lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>My Preconfigured Django Template: Part 1 - Introduction</title>
      <dc:creator>Matúš Kočik</dc:creator>
      <pubDate>Fri, 07 Feb 2025 10:25:04 +0000</pubDate>
      <link>https://forem.com/matus-kocik/my-preconfigured-django-template-part-1-introduction-5f9f</link>
      <guid>https://forem.com/matus-kocik/my-preconfigured-django-template-part-1-introduction-5f9f</guid>
      <description>&lt;p&gt;Setting up a new Django project often involves repetitive steps: installing dependencies, configuring settings, and ensuring the right tools are in place. To simplify this, I created my own &lt;strong&gt;Django Template&lt;/strong&gt; - a lightweight starting point for my projects.  &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why Did I Create This Template?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Every time I started a project, I had to set up environments, install tools, and configure everything manually. Instead of doing it from scratch every time, I built a &lt;strong&gt;preconfigured template&lt;/strong&gt; that includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pre-commit hooks&lt;/strong&gt; to ensure clean code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Black &amp;amp; Ruff&lt;/strong&gt; for formatting and linting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UV Astral&lt;/strong&gt; for better dependency management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker support&lt;/strong&gt; for database consistency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Actions&lt;/strong&gt; for automated workflows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This template saves time, keeps my projects organized, and ensures a consistent setup.&lt;/p&gt;

&lt;p&gt;📖 &lt;strong&gt;&lt;a href="https://medium.com/@matus-kocik/my-preconfigured-django-template-3965a54205e4" rel="noopener noreferrer"&gt;Read the full article on Medium&lt;/a&gt;&lt;/strong&gt;  &lt;/p&gt;




&lt;h3&gt;
  
  
  🔗 &lt;strong&gt;Follow me on:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;🌍 &lt;a href="https://www.matuskocik.com" rel="noopener noreferrer"&gt;My Website&lt;/a&gt;&lt;br&gt;&lt;br&gt;
💻 &lt;a href="https://github.com/matus-kocik" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;br&gt;&lt;br&gt;
🤝 &lt;a href="https://www.linkedin.com/in/matuskocik/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;&lt;br&gt;
✍️ &lt;a href="https://medium.com/@matus-kocik" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;  &lt;/p&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
