<?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>DEV Community: James Timmins</title>
    <description>The latest articles on DEV Community by James Timmins (@jamestimmins).</description>
    <link>https://dev.to/jamestimmins</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%2F102760%2F1bb93970-52c8-4043-8f54-e0ae91c54bcd.jpg</url>
      <title>DEV Community: James Timmins</title>
      <link>https://dev.to/jamestimmins</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jamestimmins"/>
    <language>en</language>
    <item>
      <title>Django Cheat Sheet: Keep Credentials Secure with Environment Variables</title>
      <dc:creator>James Timmins</dc:creator>
      <pubDate>Tue, 17 Sep 2019 17:05:30 +0000</pubDate>
      <link>https://dev.to/jamestimmins/django-cheat-sheet-keep-credentials-secure-with-environment-variables-2ah5</link>
      <guid>https://dev.to/jamestimmins/django-cheat-sheet-keep-credentials-secure-with-environment-variables-2ah5</guid>
      <description>&lt;p&gt;Tl;DR&lt;br&gt;
Hard coding config values and credentials is convenient but makes your code less secure and less portable. Use environment variables to make your code more secure and easy to deploy in different environments.&lt;/p&gt;

&lt;p&gt;Bad:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TWILIO_SECRET_KEY = "iamverysneaky"
twilio_client = Twilio(key=TWILIO_SECRET_KEY)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The problem:&lt;br&gt;
If someone gets access to your code, now they have access to your Twilio account too! Two problems for the price of one!&lt;/p&gt;

&lt;p&gt;Good:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from dotenv import load_dotenv

load_dotenv()

twilio_client = Twilio(key=os.getenv("TWILIO_SECRET_KEY"))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If someone gets access to your code, at least your Twilio account (and user data!) is still safe.&lt;/p&gt;

&lt;p&gt;To illustrate how this works, we'll move the auto-generated &lt;code&gt;SECRET_KEY&lt;/code&gt; value out of &lt;code&gt;settings.py&lt;/code&gt; and into an environment variable.&lt;/p&gt;

&lt;p&gt;From this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SECRET_KEY="thisismyunsecuredsecretkey"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SECRET_KEY=os.getenv("DJANGO_SECRET_KEY")
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Do these things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Download the dotenv package.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pip install python-dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a file named &lt;code&gt;.env&lt;/code&gt; in the same directory as &lt;code&gt;settings.py&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ touch .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the &lt;code&gt;.env&lt;/code&gt; file to your &lt;code&gt;.gitignore&lt;/code&gt;. This is the most important step bc it keeps &lt;code&gt;.env&lt;/code&gt;, and thus your secret values, outside of version control/Git.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ echo .env &amp;gt;&amp;gt; .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add your config values and credentials to .env.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ echo 'DJANGO_SECRET_KEY="thisismyunsecuredsecretkey"' &amp;gt;&amp;gt; .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Import and load&lt;code&gt;os&lt;/code&gt; and &lt;code&gt;dotenv&lt;/code&gt; into &lt;code&gt;settings.py&lt;/code&gt;. This makes the values accessible.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
from dotenv import load_dotenv
...
load_dotenv()
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Replace the original &lt;code&gt;SECRET_KEY&lt;/code&gt; value with an environment variable lookup.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SECRET_KEY=os.getenv("DJANGO_SECRET_KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Profit! By not getting sued by your users for letting their data get stolen. GDPR goodness!&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>python</category>
      <category>learning</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>I'm writing a book about Django -- What do you want to learn?</title>
      <dc:creator>James Timmins</dc:creator>
      <pubDate>Thu, 08 Aug 2019 21:04:56 +0000</pubDate>
      <link>https://dev.to/jamestimmins/i-m-writing-a-book-about-django-what-do-you-want-to-learn-1jgl</link>
      <guid>https://dev.to/jamestimmins/i-m-writing-a-book-about-django-what-do-you-want-to-learn-1jgl</guid>
      <description>&lt;p&gt;Hi folks!&lt;/p&gt;

&lt;p&gt;In my &lt;a href="https://dev.to/jamestimmins/why-we-re-writing-a-django-book-specifically-for-portfolio-projects-and-mvps-463i"&gt;previous post&lt;/a&gt;, I talked about the book I'm working on that covers building and deploying Django APIs for MVPs and portfolio projects.&lt;/p&gt;

&lt;p&gt;Now that I'm a few chapters in, it seems like a good time to check back in with folks to hear their additional thoughts and get feedback on our overall direction.&lt;/p&gt;

&lt;p&gt;If anyone is learning Django, has learned Django, wants to learn Django, or tried and was intimidated, it would be really helpful to hear your thoughts and specifically what was challenging or confusing when you were first starting out.&lt;/p&gt;

&lt;p&gt;If you click &lt;a href="https://jamestimmins.typeform.com/to/sx9t94"&gt;this link for a Typeform feedback form&lt;/a&gt;, you can fill out a few questions and share your thoughts.&lt;/p&gt;

&lt;p&gt;Assuming that enough people respond, in a few weeks I will share the results and my up-to-date outline for the book and how it incorporates that feedback.&lt;/p&gt;

&lt;p&gt;Thank you so much!&lt;/p&gt;




&lt;p&gt;If you're interested in following me you can do so at &lt;a href="https://twitter.com/JamesTimmins"&gt;@jamestimmins&lt;/a&gt;, and if you'd like to hear more about the book you can sign up for updates at &lt;a href="https://www.fullstack.io/fullstack-django"&gt;the official site&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>api</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Why we’re writing a Django book specifically for portfolio projects and MVPs</title>
      <dc:creator>James Timmins</dc:creator>
      <pubDate>Thu, 13 Jun 2019 17:31:57 +0000</pubDate>
      <link>https://dev.to/jamestimmins/why-we-re-writing-a-django-book-specifically-for-portfolio-projects-and-mvps-463i</link>
      <guid>https://dev.to/jamestimmins/why-we-re-writing-a-django-book-specifically-for-portfolio-projects-and-mvps-463i</guid>
      <description>&lt;p&gt;TLDR: The hardest part of building web applications is rarely using the framework itself or even the “business logic”. It’s cleanly integrating your app into all of the other tools involved in a modern web app. So we’re writing a book specifically about building and deploying a production-ready Django API that you can be proud of.&lt;/p&gt;

&lt;p&gt;I remember feeling stupid while I was first learning about web programming. I picked Django because I liked Python, and while there were great resources online, it never felt like I knew &lt;em&gt;quite&lt;/em&gt; enough to put a project I was proud of onto Github or Hacker News.&lt;/p&gt;

&lt;p&gt;Most documentation and tutorials only covered building something that you could run safely on your own computer, or they were &lt;em&gt;way&lt;/em&gt; too technical for me. Every time I tried to integrate with a new tool or service there were new headaches and problems that slowed my progress. It took years for me to feel confident showing off the apps I built.&lt;/p&gt;

&lt;p&gt;I didn’t want to build toy applications. I wanted to build production apps that were safe and scalable enough to release onto the open web.&lt;/p&gt;

&lt;p&gt;When my co-author Bryan and I started planning &lt;a href="https://www.fullstack.io/fullstack-django"&gt;Fullstack Django APIs&lt;/a&gt;, we asked what problems existed within the Django ecosystem in general, and Django Rest Framework in particular. We could write a huge reference book on Django, but that seemed like a waste of time. Django already has expansive, mature documentation online. Books like Two Scoops of Django and Test Driven Development with Django are gold standards in their respective domains. We wanted to create something that complemented the existing materials, rather than trying to compete with it.&lt;/p&gt;

&lt;p&gt;So we outlined areas of confusion. They included:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How do I deploy a live production application?&lt;/li&gt;
&lt;li&gt;Where do I put my business logic?&lt;/li&gt;
&lt;li&gt;How do I store configs and credentials in a secure manner?&lt;/li&gt;
&lt;li&gt;How do I handle authentication?&lt;/li&gt;
&lt;li&gt;What type of DB should I use and how do I connect to it on my own computer vs a live, production database.&lt;/li&gt;
&lt;li&gt;How do all of the pieces of Django fit together?&lt;/li&gt;
&lt;li&gt;What are task queues and when should I use them?&lt;/li&gt;
&lt;li&gt;To cache or not to cache?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It eventually became clear that those areas of confusion weren’t unique to just us. Lots of new Djangonauts get excited about the possibility of making and deploying cool projects, but are bogged down by the difficulty of integrating their APIs into a broader development environment. &lt;/p&gt;

&lt;p&gt;So that’s who we’re writing a book to help. Our goal is for junior and intermediate level developers to work through Fullstack Django APIs and leave with the confidence and skills needed to make a production-ready API. Something that they can show to recruiters or clients, and feel comfortable using to build live web services that store data from real users.&lt;/p&gt;

&lt;p&gt;If we’re successful, this is something that every tech company using Django will give to new hires so they’re ready to write production code. We know that’s an ambitious goal, but we’re excited about the progress that we’ve already made in this area. I’ll get more specific with the details as we near the release date, but until then, I’m excited to share more about the process here on Dev.to.&lt;/p&gt;

&lt;p&gt;If you’re interested in the project and would like access to the first chapter once it’s released, you can sign up &lt;a href="https://www.fullstack.io/fullstack-django"&gt;here&lt;/a&gt; to stay in the loop.&lt;/p&gt;

</description>
      <category>django</category>
      <category>showdev</category>
      <category>djangorestframework</category>
      <category>python</category>
    </item>
  </channel>
</rss>
