<?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: Cindy Achieng</title>
    <description>The latest articles on Forem by Cindy Achieng (@cindyachieng).</description>
    <link>https://forem.com/cindyachieng</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%2F61044%2Fc714da88-b078-4437-951b-6e5a19aa2b73.jpeg</url>
      <title>Forem: Cindy Achieng</title>
      <link>https://forem.com/cindyachieng</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cindyachieng"/>
    <language>en</language>
    <item>
      <title>Laughing Blog Tutorial Part 3 - Send Alternative Content Type Emails in Django</title>
      <dc:creator>Cindy Achieng</dc:creator>
      <pubDate>Fri, 14 Jun 2019 06:03:47 +0000</pubDate>
      <link>https://forem.com/cindyachieng/laughing-blog-tutorial-part-3-send-alternative-content-type-emails-in-django-4le2</link>
      <guid>https://forem.com/cindyachieng/laughing-blog-tutorial-part-3-send-alternative-content-type-emails-in-django-4le2</guid>
      <description>&lt;p&gt;Html emails can be formatted well and include pictures, unlike plain text emails. However, some email clients (mostly older ones)  cannot read html. Therefore It may be useful to send &lt;code&gt;plain text&lt;/code&gt; emails a alongside &lt;code&gt;html email&lt;/code&gt; because we want all our subscribers receiving their emails.&lt;/p&gt;

&lt;p&gt;To achieve sending multiple email content, we are going to use Django email library called &lt;code&gt;EmailMultiAlternatives&lt;/code&gt;. For a  much cleaner code, we will create a function.&lt;/p&gt;

&lt;p&gt;We will also cover django &lt;code&gt;message framework&lt;/code&gt; to display user notifications Instead of printing  notification to console &lt;a href="https://docs.djangoproject.com/en/2.0/ref/contrib/messages/" rel="noopener noreferrer"&gt;see documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's get started!&lt;/p&gt;

&lt;p&gt;Create a new file on newsletter app and name it &lt;code&gt;emails.py&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;send_multiple_email&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;subject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Welcome to Laughing Blog Tutorial&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="n"&gt;sender&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;test@achiengcindy.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="n"&gt;text_template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;render_to_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;newsletter/email-subscribe.txt&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;name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="n"&gt;html_template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;render_to_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;newsletter/email-subscribe.html&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;name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;EmailMultiAlternatives&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text_template&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;attach_alternative&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html_template&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;text/html&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, we created a function &lt;code&gt;send_multiple_email&lt;/code&gt; taking two parameters. Define the subject of the email and sender. Use the render_to_string function and pass the templates for the email body.&lt;/p&gt;

&lt;p&gt;We can now create the email template&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;newsletter/templates/email-subscribe.html&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Hello {{name}}&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt; 
Welcome to Laughing Blog Newsletter and thank you for signing up. 
You will find the most exciting news about Python, Django, Programming tips and web development tools that will go along way to see you grow your skills
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;newsletter/templates/email-subscribe.txt&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;Hello {{name}}
Welcome to Laughing Blog  Newsletter and thank you for signing up. 
You will find the most exciting news about Python, Django,Programming tips and web development tools that will go along way to see you grow your skills
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now is a good time to make a few changes in views.py.Change your views to look like this:&lt;/p&gt;

&lt;h3&gt;
  
  
  newsletter/views.py
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;newsletter_subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;POST&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;NewsUserForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_valid&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="n"&gt;instance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;commit&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="c1"&gt;# we dont want to save just yet
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;NewsUsers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;your email Already exists in our database&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;your email has been submitted to our database&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="nf"&gt;send_multiple_email&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;NewsUserForm&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;context&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;form&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;newsletter/subscribe.html&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First ,import the function we just created &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from .emails import send_multiple_email&lt;/code&gt;&lt;/pre&gt;
&lt;br&gt;
Then instead of &lt;code&gt;send_mail&lt;/code&gt; call  &lt;code&gt;send_multiple_email&lt;/code&gt;&lt;br&gt;
Run Server and test
&lt;h3&gt;
  
  
  Django messages Framework
&lt;/h3&gt;

&lt;p&gt;Edit your views with the following:&lt;br&gt;
First import &lt;code&gt;messages framework&lt;/code&gt;  &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from django.contrib import messages &lt;/code&gt;&lt;/pre&gt; and next replace these line of codes&lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;your email Already exists in our database&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;your email has been submitted to our database&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;with these lines respectively&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt; &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;warning&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;your Email Already exists in our database&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
 &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;success&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;your Email has been submitted to our database&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display messages edit subscription template to look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"messages"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
{% for message in messages %}
&lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt;&lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="na"&gt;if&lt;/span&gt; &lt;span class="na"&gt;message.tags&lt;/span&gt; &lt;span class="err"&gt;%}&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"{{ message.tags }}"&lt;/span&gt;&lt;span class="err"&gt;{%&lt;/span&gt; &lt;span class="na"&gt;endif&lt;/span&gt;    &lt;span class="err"&gt;%}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;{{ message }&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
{% endfor %}
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
{% else %}
&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"{% url 'newsletter:subscribe' %}"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"post"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
{% csrf_token %}
{{ form.as_p }}
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
{% endif %}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;We are now able to send alternative emails and have a more readable code.The source code for this tutorial is available on  &lt;a href="https://github.com/achiengcindy/laughing_blog" rel="noopener noreferrer"&gt; Github &lt;/a&gt;.&lt;a href="https://twitter.com/achiengcindy_" rel="noopener noreferrer"&gt;Connect with me on Twitter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post was originally posted on &lt;a href="https://achiengcindy.com/blog/2018/03/23/sending-emails-django-application-using-mailjet/" rel="noopener noreferrer"&gt;achiengcindy.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laughingblog</category>
      <category>pipenv</category>
      <category>pythodecouple</category>
      <category>sendemails</category>
    </item>
    <item>
      <title>Laughing Blog Tutorial Part 1-Project Structure</title>
      <dc:creator>Cindy Achieng</dc:creator>
      <pubDate>Fri, 30 Nov 2018 09:32:45 +0000</pubDate>
      <link>https://forem.com/achiengcindy/laughing-blog-tutorial-part-1-project-structure-21fi</link>
      <guid>https://forem.com/achiengcindy/laughing-blog-tutorial-part-1-project-structure-21fi</guid>
      <description>&lt;p&gt;My journey as a programmer has taught me one valuable lesson: To effectively learn how to write and understand programming concepts, never underestimate the value of building real-life applications. I  remember staying up late trying to grasp the concepts of programming. But to make the concepts stick, I embarked on a journey to create &lt;a href="https://achiengcindy.com" rel="noopener noreferrer"&gt;achiengcindy.com&lt;/a&gt; and share my journey with you all.&lt;/p&gt;

&lt;p&gt;The aim of this tutorial series, &lt;code&gt;The laughing blog&lt;/code&gt;, is to create a fully functional blog in Django.&lt;/p&gt;

&lt;h4&gt;
  
  
  Overview
&lt;/h4&gt;

&lt;p&gt;We will implement functionalities such as :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Registration and Authentication&lt;/li&gt;
&lt;li&gt;Newsletter&lt;/li&gt;
&lt;li&gt;Sending Emails&lt;/li&gt;
&lt;li&gt;Comment system&lt;/li&gt;
&lt;li&gt;Social media share&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code can be found on &lt;a href="https://github.com/achiengcindy/laughing_blog" rel="noopener noreferrer"&gt;github&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;If you follow through, you too can create your own blog or even earn from it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic Git  Knowledge&lt;/li&gt;
&lt;li&gt;A github or bitbucket account.If you dont have,create one for free on &lt;a href="https://github.com" rel="noopener noreferrer"&gt; github&lt;/a&gt; or  &lt;a href="https://github.com" rel="noopener noreferrer"&gt; bitbucket&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Django  basics.If you are new to django check  my previous tutorial on &lt;a href="https://achiengcindy.com/blog/2018/02/27/how-set-django-environment-linux-beginners/" rel="noopener noreferrer"&gt;Django Environment in Linux&lt;/a&gt; .&lt;/li&gt;
&lt;li&gt;Text Editor of choice.I will be using Sublime Text.You can download it &lt;a href="https://www.sublimetext.com/3" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Setting up the laughing-blog project
&lt;/h4&gt;

&lt;p&gt;In this tutorial, you will learn how to create Django project structure, learn &lt;code&gt;git&lt;/code&gt; and some very useful python libraries such as  &lt;code&gt;whitenoise&lt;/code&gt; and &lt;code&gt;python decouple&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I will use &lt;code&gt;pip&lt;/code&gt; and &lt;code&gt;virtualenv&lt;/code&gt; to create the  project structure  however, you can use  &lt;a href="https://achiengcindy.com/blog/2018/04/23/pipenv-new-python-packaging-tool/" rel="noopener noreferrer"&gt;pipenv&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;let's get started&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a folder and name it tutorial where our project will be stored.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; mkdir tutorial &amp;amp;&amp;amp; cd tutorial
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Nice, next we have to create a Virtual Environment for our project &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; virtualenv env -p python3 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;specify the python version .We will use &lt;code&gt;python3&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To use our virtual environment we must &lt;strong&gt;activate&lt;/strong&gt; it&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; source env/bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After activating the virtual environment. Install Django using the command below:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pip3 install django
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We are going to create the project named laughing_blog by using the command below:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; $ django-admin startproject laughing_blog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you change Directory to laughing_blog, you should have a structure like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;laughing_blog&lt;/span&gt;
&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;laughing_blog&lt;/span&gt;
&lt;span class="o"&gt;----&lt;/span&gt;&lt;span class="n"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
&lt;span class="o"&gt;----&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
&lt;span class="o"&gt;----&lt;/span&gt;&lt;span class="n"&gt;urls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
&lt;span class="o"&gt;----&lt;/span&gt;&lt;span class="n"&gt;wsgi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;manage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the outer laughing_blog to &lt;code&gt;src&lt;/code&gt; ( it is just a container that holds our project).&lt;br&gt;
To make sure that django is successfully installed run server using the command &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;python manage.py runserver&lt;/code&gt;&lt;/pre&gt; and if all went well,you should see this page:

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuht26hr18xc567p6m349.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuht26hr18xc567p6m349.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we are all set to start writing codes.However, there are some configurations and libraries I want to introduce. &lt;/p&gt;
&lt;h4&gt;
  
  
  Python-decouple
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;Python Decouple&lt;/code&gt; will help us separate sensitive settings from the project .Storing passwords and other sensitive information such as &lt;code&gt;secret key&lt;/code&gt; in &lt;code&gt;settings.py&lt;/code&gt; is not a great idea and that is why we will use &lt;a href="https://pypi.python.org/pypi/python-decouple" rel="noopener noreferrer"&gt;python-decouple&lt;/a&gt;. Install it using the following command:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pip3 install python-decouple
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;After successfully installing &lt;code&gt;Python-decouple&lt;/code&gt;, create a .env text file on your project's root directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Python Decouple&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;.env&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the file where all  the sensitive information are stored.So far,we need to store our secret key and debug status.It should look like this: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SECRET_KEY = your key&lt;br&gt;
DEBUG = True&lt;/code&gt;&lt;/pre&gt; 

&lt;p&gt;&lt;strong&gt;settings.py&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Import &lt;code&gt;config&lt;/code&gt; object   and place it below &lt;code&gt; import os&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  from decouple import config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;This is a snippet from my &lt;code&gt;settings.py.&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
from decouple import config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Replace the secret key and debug with the following:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SECRET_KEY = config('SECRET_KEY'')
DEBUG = config('DEBUG', cast=bool)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Git
&lt;/h4&gt;

&lt;p&gt;It is important to push your changes to a remote repository. Initialize git using:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; $ git init// Initializes git 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Next, we want git to ignore some files with secret information such as the settings, database, etc.Now,create a gitignore file and add the .env, *.pyc ,db.sqlite3 and any other  text file in it.To create gitignore use the command:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; $ touch .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Next, let's add all our changes, commit and push&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; git add *    //adds all changes
 git commit -m "initial commit"
 git remote add origin https://github.com/&amp;lt;your username&amp;gt;/laughing_blog.git 
 git push -u origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Templates
&lt;/h4&gt;

&lt;p&gt;Html is used to display data on the browser and not python.&lt;br&gt;
Django is a web framework offers a way to display HTML dynamically by using the powerful in-built &lt;strong&gt; template tags&lt;/strong&gt;. Remember HTML is static while python is dynamic. &lt;br&gt;
Django templating enable us to separate the presentation of a document from its data. &lt;br&gt;
We could embed HTML on python code, but it is not a good idea because:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In large projects, it is common to have front-end developers handling HTML and back-end developers handling python. If HTML is hard-coded in python code, it would be difficult for both developers to edit the same file at the same time without interference.&lt;/li&gt;
&lt;li&gt;In a single application, you may need to write many lines of HTML codes and troubleshooting the code can be messy if HTML is hard-coded in the python code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Setting up Django Templates&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We want to create the templates directory in the projects' root directory. We can achieve this by modifying the settings.TEMPLATE-DIRS  by adding this:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"DIRS": [os.path.join(BASE_DIR, 'templates')],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;DIRS&lt;/code&gt; defines a list of directories where Django should look for template source files.&lt;/p&gt;

&lt;p&gt;let's create the templates directory and  then create a file called &lt;strong&gt;base.html &lt;/strong&gt; to include the project's main html structure&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ mkdir templates
$ cd templates
   base.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;snippet for base.html&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    {% load staticfiles %}
    &lt;span class="cp"&gt;&amp;lt;!Doctype html&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt; Laughing blog&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
       {% block content %}{% endblock %}
    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  How to Serve Static Files in Django
&lt;/h4&gt;

&lt;p&gt;Web applications will need additional files like CSS, scripts, and Images for the application and  &lt;code&gt; user-uploaded content&lt;/code&gt; such as profiles pictures. These files  can be categorized as:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Static files: Resource used by the application such as scripts, images&lt;/li&gt;
&lt;li&gt;Media files: These are the content uploaded by the user, say user profile picture. We will talk about this later.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Configuring Static Files&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Managing static files in django  can be complicated especially if you are not familiar with Django.In &lt;code&gt;settings.py&lt;/code&gt; make sure &lt;code&gt; django.contrib.staticfiles&lt;/code&gt; in  &lt;code&gt;INSTALLED_APPS&lt;/code&gt;.In, Most cases,it is already defined.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STATIC_URL&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;settings.py &lt;/code&gt; you will find this line of code&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   STATIC_URL = '/static/'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is where Django serves static files for a particular app in your project. Django allows you to have several static folders in a project. For this project, we will create just one static folder  in the root project directory so let's configure &lt;strong&gt;staticfiles-dirs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STATICFILES_DIRS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's say you have a project and most apps share static assets like styling or images, or in addition to the static files tied to a particular app, you require additional static assets then define&lt;code&gt;STATICFILES_DIRS&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;STATICFILES_DIRS&lt;/code&gt; tuple tells Django where to look for static files that are not tied to a particular app. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  STATICFILES_DIRS = [
 os.path.join(BASE_DIR, "static"),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this case, we just told Django to also look for static files in a folder called &lt;code&gt;static&lt;/code&gt; in our project's root folder, not just in our apps.&lt;/p&gt;

&lt;p&gt;Then create the static directory in the project's root folder&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ mkdir static
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Serving  Static Files in Development
&lt;/h4&gt;

&lt;p&gt;When &lt;code&gt; django.contrib.staticfiles&lt;/code&gt; is installed,running &lt;code&gt;runserver&lt;/code&gt; command automatically serve the static files otherwise serve them manually by:&lt;/p&gt;

&lt;p&gt;Project's &lt;code&gt;urls.py&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
     ... 
 ] 
 + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;STATIC_ROOT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the storage folder for every static files after running the &lt;code&gt;collectstatic &lt;/code&gt; command.It collects all the static files in one place.&lt;br&gt;
Let us tell django to collect all our static files in a folder called &lt;strong&gt; staticfiles&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is very important in production and&lt;code&gt;whitenoise&lt;/code&gt; handles this very well.&lt;/p&gt;

&lt;h4&gt;
  
  
  Whitenoise
&lt;/h4&gt;

&lt;p&gt;Managing static files in production is even more complicated,at-least it was for me! To manage our static files with less hustle,we will  install a 3rd party library &lt;a href="http://whitenoise.evans.io/en/stable/django.html" rel="noopener noreferrer"&gt;whitenoise&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To install whitenoise, run:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; pip3 install whitenoise
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To use whitenoise in Django.We edit &lt;code&gt;settings.py&lt;/code&gt; by adding it to &lt;code&gt;MIDDLEWARE_CLASSES&lt;/code&gt;below the django &lt;code&gt;SecurityMiddleware&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MIDDLEWARE = [
    #'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    ...
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To enable compression to add the following :&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Conclusion&lt;br&gt;
&lt;/h4&gt;

&lt;p&gt;We created Virtual Environment, Installed Django, installed Python-decouple and created our template and static files directory. We also create gitignore file and added the .env text file we created. Meet you in the next tutorial!&lt;/p&gt;

</description>
      <category>laughingblog</category>
      <category>pipenv</category>
      <category>whitenoise</category>
      <category>pythondecouple</category>
    </item>
    <item>
      <title>My journey so far as a Software Developer</title>
      <dc:creator>Cindy Achieng</dc:creator>
      <pubDate>Wed, 11 Jul 2018 20:57:34 +0000</pubDate>
      <link>https://forem.com/achiengcindy/my-journey-so-far-as-a-software-developer-32b4</link>
      <guid>https://forem.com/achiengcindy/my-journey-so-far-as-a-software-developer-32b4</guid>
      <description>&lt;p&gt;This is a story about resilience, determination and passion.&lt;/p&gt;

&lt;p&gt;It started way back  in August 2011 when I got admitted to study Applied Computer Science.To be totally honest,I didn’t know what it was all about.I always saw myself as  a mathematician because numbers make sense but missed the chance to study statistics.&lt;/p&gt;

&lt;p&gt;At the time I had a mini laptop which I had bought with my HELB money(Higher Education Loans Board).I still remember vividly when my favorite  lecturer Oops! not sure if he will appreciate me mentioning his name, but yes  &lt;a href="https://ke.linkedin.com/in/kengerekibwage" rel="noopener noreferrer"&gt;kengere kibwage&lt;/a&gt; saying, "Give that toy to your baby sister”, and continued talking about common java compilers.(Sir, you shaped my skills) &lt;/p&gt;

&lt;p&gt;“what is a compiler?”, I could ask myself but  kept silent to mask my ignorance.The class seemed just fine.I felt stupid and my mind told me to quit.you are not creative enough,you don’t get it like the rest.I wish I asked though.&lt;/p&gt;

&lt;p&gt;Long story short,I managed to graduate and the impostor syndrome still stuck with me. In my mind, programming was for a certain kind of people, way out of this world.&lt;/p&gt;

&lt;p&gt;It was not until I joined &lt;a href="https://andela.com/" rel="noopener noreferrer"&gt;Andela bootcamp&lt;/a&gt; that my dimensions changed.It was the all female bootcamp edition,in that room was 40 intelligent women including 'myself'.I was inspired.The  practicality and relating software to solving real life problems motivated me to go on.I saw a future in solving  problems through writing codes,It was not easy but I knew that I wanted to be programmer more than ever that I did quit my job as an IT technician and embarked on this awesome journey  to becoming a  world class developer as Andeleans like to say it.&lt;/p&gt;

&lt;p&gt;I didn't make it to the end of the bootcamp, but something changed.I came out fierce and I was willing to put in the time and effort and nothing could stop me.I was reborn and left behind the misconceptions. &lt;a href="https://achiengcindy.com/" rel="noopener noreferrer"&gt;Acheng cindy blog&lt;/a&gt; was born  to document my journey  and inspire anyone who wanted to code and didn't know where to start.&lt;/p&gt;

&lt;p&gt;I applied for the google Africa Challenge Scholarship in partnership with   &lt;a&gt;Udacity&lt;/a&gt; and &lt;a href="https://andela.com/alcwithgoogle/" rel="noopener noreferrer"&gt;ALC 3.0&lt;/a&gt; and was lucky to be  enrolled on Intermediate  mobile-web track. The first phase of the scholarship  is a 3 month challenge course and only 500 scholars get selected  for a nanodegree based on many factors such as  participation, completing tasks on time, helping peers among others.&lt;/p&gt;

&lt;p&gt;Andela Learning community brought together all learners across Africa ,interacting with each offer, offering emotional support and collaborating (it's what good programmers do).&lt;/p&gt;

&lt;p&gt;It has been an intriguing journey learning from some of the best developers including &lt;a href="https://twitter.com/jaffathecake" rel="noopener noreferrer"&gt;jakearchibald&lt;/a&gt;.Knowledge gained during the 3 month challenge course is immeasurable. Have you ever imagined having offline first web apps? Saying goodbye to this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FJGRhuL0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FJGRhuL0.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you enjoy the game like I do , on the plus side you will still get to play it when you want to  .Thanks to the  web Technologies &lt;a href="https://achiengcindy.com/2018/05/11/understanding-the-service-worker-lifecycle/" rel="noopener noreferrer"&gt;Service Worker &lt;/a&gt;, Catch API ,Indexed db and  fetch API.&lt;/p&gt;

&lt;p&gt;The climax was 7DaysofCodeChallenge to create a &lt;a href="https://achiengcindy.github.io/currency_converter/main.html" rel="noopener noreferrer"&gt;currency converter app&lt;/a&gt; that can work both online and offline.&lt;/p&gt;

&lt;p&gt;Today (11th july 2018) , I am lucky again to be  among the few 500 scholars to  be offered a nanodegree on Udacity and I cant keep quiet.Thank you to everyone who supported me. &lt;a href="https://ke.linkedin.com/in/mckabue" rel="noopener noreferrer"&gt;mckabue&lt;/a&gt; and all my peers from the scholarship, andela, udacity and googleafrica&lt;/p&gt;

&lt;p&gt;Asanteni sana!&lt;/p&gt;

&lt;h4&gt;
  
  
  More About ALC
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://medium.com/@chimdi2000/andela-and-googles-android-learning-community-alc-the-case-for-investing-in-communities-of-35cda2b276b5" rel="noopener noreferrer"&gt;ALC&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>alc</category>
      <category>cindyachieng</category>
      <category>googlescholar</category>
      <category>udacity</category>
    </item>
    <item>
      <title>Understanding The Service worker LifeCycle</title>
      <dc:creator>Cindy Achieng</dc:creator>
      <pubDate>Thu, 17 May 2018 16:11:10 +0000</pubDate>
      <link>https://forem.com/achiengcindy/understanding-the-service-worker-lifecycle-47d5</link>
      <guid>https://forem.com/achiengcindy/understanding-the-service-worker-lifecycle-47d5</guid>
      <description>&lt;p&gt;The desired user experience  is to access information on the internet without  interruptions.Unfortunately, even with high speed connectivity we still experience delays.&lt;/p&gt;

&lt;p&gt;Let me explain briefly, to get the information we need on our screen we send requests over the network and wait for that response.But what if, just what if the network is busy, or  there is a mis-configured proxy somewhere, or you can't access the internet for whatever reason, It could be anything really, and we have to wait for a very long time?&lt;/p&gt;

&lt;p&gt;This can be frustrating for most users.&lt;/p&gt;

&lt;p&gt;But there is a solution , Building &lt;code&gt;Offline First&lt;/code&gt; web Apps.&lt;/p&gt;

&lt;h5&gt;
  
  
  But How Do achieve Offline Experience ?
&lt;/h5&gt;

&lt;p&gt;To achieve offline experience we need to take care of:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Caching Assets&lt;/strong&gt;. The browser stores static assets such as html,css,Images.Such that when needed next,they are fetched from the browser cache.Big deal when the network fails.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storing data on the client side&lt;/strong&gt;.Html 5 came bearing good news with offline technologies such as Web Storage, indexed databases among others enabling you store data locally on the users device.&lt;a href="https://www.html5rocks.com/en/features/storage"&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;
  
  
  Application Cache
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache"&gt; Application Cache&lt;/a&gt; (Warning: It is being deprecated) &lt;br&gt;
 tried resolving the &lt;strong&gt;caching&lt;/strong&gt; by allowing you to specify the set of resources you'd like the browser to cache and enjoy offline browsing,Improved speed by caching resources  &lt;code&gt;locally&lt;/code&gt;( no need for network trips),  and reduced server load (the browser only downloads resources that have changed from the server.)&lt;/p&gt;

&lt;p&gt;Useful when the user  is disconnected from the network, but did it deliver its promise?  read &lt;a href="http://alistapart.com/article/application-cache-is-a-douchebag"&gt;API is A douchbag&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Service workers
&lt;/h3&gt;

&lt;p&gt;Service worker  is a script (javascript file), that the browser runs in the background, acting like a proxy between  application and the network.&lt;/p&gt;

&lt;p&gt;Service worker enable applications  intercept  requests and then modify response,cache those requests to improve performance and provide offline access to cached data which makes it reliable.&lt;/p&gt;

&lt;p&gt;Service worker is a type of  &lt;a href="https://html.spec.whatwg.org/multipage/workers.html"&gt;web worker&lt;/a&gt;,runs on a separate thread from the web pages and UI ,enabling them to work without an active browser session.&lt;/p&gt;

&lt;p&gt;It has no  access to DOM, instead Communicates with the  pages through &lt;code&gt;post message&lt;/code&gt; ,those pages can then manipulate DOM if needed. &lt;/p&gt;

&lt;p&gt;It  offers you complete control over your app behavior  especially when network is unavailable or slow.&lt;/p&gt;

&lt;p&gt;This kind of control  is the reason service workers run only on https,to avoid man in the middle attacks,though an exception  for local requests-not necessary  during development&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The intended use is to create offline first experiences &lt;/li&gt;
&lt;li&gt;Intercept network requests and handle response based on network availability,&lt;/li&gt;
&lt;li&gt;Great benefits online when experiencing slow connection &lt;/li&gt;
&lt;li&gt; Allow access to push notification and  background sync &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Service workers let you handle network requests differently from caching.&lt;br&gt;
Service worker revolves around recent WebAPI&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fetch
A &lt;strong&gt;fetch&lt;/strong&gt; event is fired when resource is requested over the network. Perform standard request i.e Offers us the ability to look in the cache before making network requests.Inside a service worker,allows for intercepting  requests and then modify the content other than the object requested.Use &lt;code&gt;respondWith()&lt;/code&gt; to tell the browser we will handle the requests&lt;/li&gt;
&lt;li&gt;Cache API.
&lt;strong&gt;Cache API&lt;/strong&gt; is independent from network status or browser cache.
It gives you control on how and when to cache.It will not update items in the cache unless explicitly requested.Items in cache do not expire, they are gone when you delete the old cache.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Service worker lifecycle
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Registration&lt;/li&gt;
&lt;li&gt;Install&lt;/li&gt;
&lt;li&gt;Activate&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Registration
&lt;/h5&gt;

&lt;p&gt;To use a service worker you must register and define  its scope.&lt;/p&gt;

&lt;p&gt;Registration will tell a browser the location of the service worker and start installing it on the background.&lt;/p&gt;

&lt;p&gt;code to register Service worker placed in &lt;code&gt;sw.js&lt;/code&gt;&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;serviceWorker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/sw.js'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Registration worked!'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Registration failed!'&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;A Service Worker returns a promise.If the  Promise resolves,the registration is successful otherwise the registration of the new service worker failed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Browser Support&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since some browsers don't support service workers  yet &lt;a href="https://jakearchibald.github.io/isserviceworkerready/"&gt;Is Service Worker Ready&lt;/a&gt;,perform a feature check   by wrapping the service worker in an &lt;code&gt;if statement&lt;/code&gt; .&lt;/p&gt;

&lt;pre&gt;&lt;code class="javascript"&gt;if (!navigator.serviceWorker) return;
navigator.serviceWorker.register('/sw.js').then(function() {
    console.log('Registration worked!');
}).catch(function() {
    console.log('Registration failed!');
});
};&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Scope&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;The scope define the pages that a service worker controls.The default scope is defined by the location of  a service worker script.&lt;br&gt;
This means if you register a service worker at the root folder,it is not necessary to define its scope because it controls all the pages.&lt;/p&gt;

&lt;pre&gt;&lt;code class="javascript"&gt;navigator.serviceworker.register('/sw.js', {
    scope: '/'
});&lt;/code&gt;&lt;/pre&gt;
    

&lt;blockquote&gt;
&lt;p&gt;The browser wont re-register an existing service worker on call ,but return a promise for existing registration&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;
  
  
  Installation
&lt;/h5&gt;

&lt;p&gt;Once the browser has registered the service worker,it is immediately &lt;code&gt;downloaded&lt;/code&gt;  if the browser considers a  service worker new either by&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Service Worker  has never been registered before. or&lt;/li&gt;
&lt;li&gt;You altered the Service Worker Script,byte differences.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;install event&lt;/code&gt; is fired.&lt;/p&gt;

&lt;p&gt;This is a perfect  opportunity to fetch for resources that make the application shell  from the network and cache them.Ideal for the static resources that our site depends on such as Html,Css,Fonts, Javascript etc.&lt;/p&gt;

&lt;p&gt;If there is a previous version of service worker already running,  it will still continue to serve pages.&lt;br&gt;
The browser wont let the new service worker take control until the installation phase is complete.Instead it  becomes the next version in  &lt;strong&gt;waiting&lt;/strong&gt; .&lt;/p&gt;

&lt;p&gt;To &lt;strong&gt;delay&lt;/strong&gt; the installation process and determine its &lt;strong&gt;success&lt;/strong&gt;,we pass a &lt;strong&gt;promise&lt;/strong&gt; to &lt;code&gt;event.waitUntill&lt;/code&gt; method. &lt;/p&gt;

&lt;p&gt;If the promise resolves,the browser knows the Installation has completed.If it fails,well then it is discarded.No cause of  alarm because the previous version of the service worker is still working.&lt;/p&gt;

&lt;p&gt;This ensures only one version of your script is running at any given time.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;self.addEventListener('install', function(event) {
  event.waitUntil(
     );
   }); &lt;/code&gt;&lt;/pre&gt;

&lt;h5&gt;
  
  
  Activation
&lt;/h5&gt;

&lt;p&gt;Once a service worker has successfully completed the installation phase,it enters activation stage.&lt;/p&gt;

&lt;p&gt;In the case of the browser first encounter with a Service Worker, the  service worker becomes active upon successfully completing the installation phase and  will be able to control new page loads.However,It cannot   control pages that were &lt;strong&gt;already&lt;/strong&gt; loaded.To control  the already loaded pages,a reload is required.&lt;/p&gt;

&lt;p&gt;In the case where  the service worker is updated, (Not the browser first time interacting with a service worker ), the newly installed service worker cannot take control until all the pages the previously installed service worker are closed.&lt;/p&gt;

&lt;p&gt;Once all pages using the old (previously installed) service worker are gone,the new one activates,firing an activate event.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;you can take control of of uncontrolled pages by calling &lt;code&gt;clients.claim()&lt;/code&gt; within your service worker once its activated&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre&gt;&lt;code class="javascript"&gt;self.addEventListener('activate', function(event){
});&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Since the previous version is out of the way,it is a perfect time to delete the old cache so that all users can have the current version of our site.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;gotcha&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We change files all the time! When we make changes in our file say a css file, this  can become a 'problem' .A  page reload  wont help much  because we still using the cache with the old css.&lt;/p&gt;

&lt;p&gt;Despite the changes in our css file,our site remain the same.Meaning, to see the changes, we make a change to the service worker script,you can simply add  a comment ,remember its just a byte difference and the browser will consider it as 'new'&lt;/p&gt;

&lt;h3&gt;
  
  
  Notes
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Service workers does not  provide cached data for offline use only,but also effective during slow connectivity online.&lt;/li&gt;
&lt;li&gt;Service workers are programmable JavaScript "servants/workers"&lt;/li&gt;
&lt;li&gt;They can not access DOM directly,instead communicate with the pages it controls through responding to messages via &lt;code&gt;postmessage&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Require sites to be served over https. This is important because they intercepts request and can modify response ,to avoid hijacking by third parties&lt;/li&gt;
&lt;li&gt;Stays idle when not in use,restarted when next needed&lt;/li&gt;
&lt;li&gt;Make extensive use of promises&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Further reading:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developers.google.com/web/ilt/pwa/introduction-to-service-worker"&gt;Introduction to service workes&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle"&gt; Jake Archibald&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Thank you for reading, hope you are ready to give users an amazing experience both online and offline.Let me know if liked the article or if I missed something!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/achiengcindy1"&gt; Connect with me on twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>serviceworkers</category>
      <category>progressivewebapps</category>
      <category>offlinefirst</category>
      <category>cacheapi</category>
    </item>
    <item>
      <title>Introduction To Python Lists</title>
      <dc:creator>Cindy Achieng</dc:creator>
      <pubDate>Mon, 30 Apr 2018 13:28:09 +0000</pubDate>
      <link>https://forem.com/achiengcindy/inntroduction-to-python-lists-26af</link>
      <guid>https://forem.com/achiengcindy/inntroduction-to-python-lists-26af</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu97qjseqf4zdkqh1zx5n.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu97qjseqf4zdkqh1zx5n.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;List is the most versatile python data structure and stores an ordered sequence of elements just like your shopping list or to-do-list.In Python, Lists are &lt;code&gt;mutable&lt;/code&gt;,meaning that the elements can be altered unlike &lt;code&gt;tuples&lt;/code&gt; or even &lt;code&gt;strings&lt;/code&gt;.These elements of  a &lt;code&gt;list&lt;/code&gt; are called &lt;code&gt;items&lt;/code&gt; and can be any data type.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Lists in Python
&lt;/h3&gt;

&lt;p&gt;Creating lists in python is quite simple, use square brackets [] and separate items in the list with commas.&lt;br&gt;
A list can be empty or contain any number of items with different data types  (integers,float,strings etc.).&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mylist = [ ]  #empty list
mylist2 = [1,2]  # list containing 2 items with integers
mylist3 = [1, 2, 'hello']  # list with 3 items,mixed data types,integers and a string
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Note : a  list can also hold another list as an item,these are called &lt;code&gt;nested lists.&lt;/code&gt; as show below.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mylist4 = [['python','php'],[1,2,3]  # a nested list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Accessing items in a list
&lt;/h3&gt;

&lt;p&gt;We can access items in a list by &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Indexing&lt;/strong&gt;.&lt;br&gt;
We use the &lt;code&gt;index&lt;/code&gt; operator [ ].Each item in a list has an assigned index value. It is important to &lt;strong&gt;Note&lt;/strong&gt; that the  index starts from 0 in python and &lt;strong&gt;must&lt;/strong&gt; be an integer&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;java&lt;/th&gt;
&lt;th&gt;python&lt;/th&gt;
&lt;th&gt;perl&lt;/th&gt;
&lt;th&gt;ruby&lt;/th&gt;
&lt;th&gt;c#&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;

&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; :The first item of any non-empty list is [0].&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Languages = ['java', 'python', 'perl' 'ruby', 'c#' ]   # define a list
print(Languages[0]) # Access the first item of a list at index 0
# Output:java which is the first item on the list.
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Negative Indexing&lt;/strong&gt; Python also  supports  negative indexing.The negative indexing  is useful when you want to  get the last item in a list because it start accessing a list  from the end.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;java&lt;/th&gt;
&lt;th&gt;python&lt;/th&gt;
&lt;th&gt;perl&lt;/th&gt;
&lt;th&gt;ruby&lt;/th&gt;
&lt;th&gt;c#&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;-5&lt;/td&gt;
&lt;td&gt;-4&lt;/td&gt;
&lt;td&gt;-3&lt;/td&gt;
&lt;td&gt;-2&lt;/td&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:The last item of any non-empty list is [-1].&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# define a list 
Languages = ['java', 'python', 'perl' 'ruby', 'c#' ] 
 print(Languages[-1) #Access the last item of a list
# Output:  C#
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;length of list&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Python has useful in-built functions that work with list.We will discuss them later but for now, &lt;code&gt;len()&lt;/code&gt; function help us in returning the total number of elements in a list.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# define a list
languages = ['java', 'python' ,'perl', 'ruby', 'c#']
# print the length of the list
print(len(languages)) 
# output 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Slicing of a List
&lt;/h3&gt;

&lt;p&gt;Slices are good for getting a subset of items in a list.It uses the &lt;code&gt;slicing&lt;/code&gt; operator : (colon) to extract part of the sequence.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Languages = ['java', 'python', 'perl','ruby', 'c#' ] # define a list 
# [:3] slicing everything up to but not including index 3
print(languages[:3])  
#Outputs: ['java', 'python', 'perl' ]

# define a list 
Languages = ['java', 'python', 'perl','ruby', 'c#' ]
# [3:] slicing everything from index 3 to the last item
print(languages[3:])
#Output: ['ruby', 'c#' ]


Languages = ['java', 'python', 'perl','ruby', 'c#' ]
#elements from beginning to end
print(languages[:])
#Output: ['java', 'python', 'perl','ruby', 'c#' ]

# define a list 
Languages = ['java', 'python', 'perl','ruby', 'c#' ]
# elements from 1st to 3rd
print(languages[0:3])
Output # ['java', 'python', 'perl']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  How to  change/add elements in a list
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;list.append(item)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The method &lt;code&gt;list.append(item)&lt;/code&gt; will add the &lt;code&gt;item&lt;/code&gt; at  the end of a list.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   # define a list
   languages = ['java', 'python' ,'perl', 'ruby', 'c#']
   # append c
   languages.append('c') 
   print (languages)
  # Output : ['java', 'python', 'perl', 'ruby', 'c#', 'c']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;list.insert(i, item)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This method  will insert an item at the ith position in a list , shifting elements to the right.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# define a list
languages = ['java', 'python' ,'perl', 'ruby', 'c#']
# insert c
languages.insert( 0, 'php') 
print languages 
# Output :  ['php', 'java', 'python', 'perl', 'ruby', 'c#']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;list.extend(items)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The extend method concatenates lists. Note that you do not call extend with multiple arguments;it takes  in a second list as its argument.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# define a list
languages = ['java', 'python' ,'perl', 'ruby', 'c#']

Languages2=['c++', 'c'] # define a second list

languages.extend(Languages2)

print(languages)

# Output ['java', 'python', 'perl', 'ruby', 'c#', 'c++', 'c']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;extend method does not return any value,instead it modifies the original list by adding the content of the second list&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Deleting List Elements
&lt;/h3&gt;

&lt;p&gt;Use the &lt;strong&gt;del&lt;/strong&gt; keywords to delete an item at specific index&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;single item&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; languages = ['java', 'python' ,'perl', 'ruby', 'c#'] # define a list
 del languages[2] # use del keyword
 print(languages)
 # Output removes perl ['java', 'python', 'ruby', 'c#']
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Multiple items&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; languages = ['java', 'python' ,'perl', 'ruby', 'c#'] # define a list
 del languages[1:3]  #delete Multiple items by slicing
 print(languages)

 # Output : ['java', 'ruby', 'c#'] 
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;list.remove(item)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It will search and  remove &lt;code&gt;only&lt;/code&gt; the first occurrence  of an item &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Languages = ['java', 'python', 'perl','python','ruby', 'c#' ]
Languages.remove('python')  # the first occurrence of python
print(languages) # outputs ['java', 'perl', 'python', 'ruby', 'c#']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It removes the python after java'.Note that the 'python' after perl is still present&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;list.pop()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Removes and returns the last item of a list&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;languages = ['java', 'python' ,'perl', 'ruby', 'c#']

print(languages.pop()) # print c#

print(languages)
# output ['java', 'python', 'perl', 'ruby']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;list.pop(i)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Removes and returns the ith item of a list&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Languages = ['java', 'python', 'perl','ruby', 'c#' ]
print(languages.pop(1)) # removes  index 1 item
#  Output returns Python
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;list.index(item)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When lists start to get long, it becomes more difficult for us to count out our items to determine at what index position a certain value is located. We can use &lt;code&gt;list.index(item)&lt;/code&gt;,  to return the index in the list where that item is located. &lt;br&gt;
If there is more than one item with value  &lt;code&gt;item&lt;/code&gt;, this method will return   the first occurrence.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary of  list methods
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
       &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;Method Name&lt;/th&gt;
       &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;td&gt;alist.append(item)&lt;/td&gt;
      &lt;td&gt;Adds a new item at the end of the list&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;td&gt;alist.insert(i, item)&lt;/td&gt;
      &lt;td&gt;Insert item at the ith position shifting other items to the right.&lt;/td&gt;
    &lt;/tr&gt;
        &lt;tr&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;td&gt;alist.extend()&lt;/td&gt;
      &lt;td&gt;Adds the elements  of a second list to the original list&lt;/td&gt;
   &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;td&gt;del alist[i]&lt;/td&gt;
      &lt;td&gt;Deletes the item at the ith position,it can also a range of items by the use of slicing&lt;/td&gt;
   &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;5&lt;/th&gt;
      &lt;td&gt;alist.remove(item)&lt;/td&gt;
      &lt;td&gt;Search and remove the first occurrence of an item,does not return a new list and throws an error if not found&lt;/td&gt;
   &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;6&lt;/th&gt;
      &lt;td&gt;pop()&lt;/td&gt;
      &lt;td&gt;Removes and returns the last item of a list&lt;/td&gt;
   &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;7&lt;/th&gt;
      &lt;td&gt;pop(i)&lt;/td&gt;
      &lt;td&gt;Removes and returns the i item of a list&lt;/td&gt;
   &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;8&lt;/th&gt;
      &lt;td&gt;alist.index(item)&lt;/td&gt;
      &lt;td&gt;Returns the index of first occurrence&lt;/td&gt;
   &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;9&lt;/th&gt;
      &lt;td&gt;alist.sort()&lt;/td&gt;
      &lt;td&gt;sort the items of a list&lt;/td&gt;
   &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;10&lt;/th&gt;
      &lt;td&gt;alist.reverse()&lt;/td&gt;
      &lt;td&gt;Reverses a List&lt;/td&gt;
   &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;11&lt;/th&gt;
      &lt;td&gt;alist.count(item)&lt;/td&gt;
      &lt;td&gt;Returns the  count of occurrence of an item&lt;/td&gt;
   &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Common List Operations
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Concatenation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Concatenation uses the  &lt;code&gt; + &lt;/code&gt; Operator. It Combines lists. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# define a list
languages = ['java', 'python' ,'perl', 'ruby', 'c#']
print(languages +(['c++', 'c']))
# Output:  ['java', 'python' ,'perl', 'ruby', 'c#', c++, c]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Repetition&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;uses the  &lt;code&gt; * &lt;/code&gt; Operator. Concatenates a list a repeated number of times&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; mylist = ['strings are  cool'] * 2
 print (mylist)
# output:  ['strings are  cool', 'strings are  cool']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Membership&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Keyword &lt;code&gt;In&lt;/code&gt;  is used to test if an item is  a member of a  list.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;languages = ['java', 'python' ,'perl', 'ruby', 'c#']
if 'python' in languages:
    print('right')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Iteration
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;For&lt;/code&gt; Loop is used to iterate through each element on a list with the keyword  &lt;code&gt;in&lt;/code&gt;.The for loop allows you to to perform an action for every element in the list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;illustration 1&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;languages = ['java', 'python' ,'perl', 'ruby', 'c#']
for i in languages:
   print(i)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will print the all the items in the list one per line as shown below:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java
python
perl
ruby
c#
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;illustration 2&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;random_sum = [2,7,8,9]
total = 0
for i in random_sum:
    total +=i
print total
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above code will print 26,the sum of all the items of the list.&lt;br&gt;
The for loop requires a variable to hold the items being iterated and the source.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;While&lt;/code&gt; Loop will first check the condition .If the condition is &lt;code&gt;true&lt;/code&gt;,it will keep iterating and terminates the loop  once the condition turns &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;languages = ['java', 'python' ,'perl', 'ruby', 'c#']
i = 0
while i &amp;lt;len(languages):
    print(languages[i])
    i = i+3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above codes will print &lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java&lt;br&gt;
ruby&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Conclusion&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;Now you know what lists are and how to manipulate them.For further understanding on list, read  about list comprehension.&lt;/p&gt;

</description>
      <category>python</category>
      <category>list</category>
      <category>datastructures</category>
    </item>
    <item>
      <title>Pipenv, the new Python packaging tool</title>
      <dc:creator>Cindy Achieng</dc:creator>
      <pubDate>Mon, 23 Apr 2018 16:40:45 +0000</pubDate>
      <link>https://forem.com/cindyachieng/pipenv-the-new-python-packaging-tool-179n</link>
      <guid>https://forem.com/cindyachieng/pipenv-the-new-python-packaging-tool-179n</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxu3vw4t3rwhvlvp4h12l.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxu3vw4t3rwhvlvp4h12l.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clearly,I have been living under a rock but not anymore! I shared an article &lt;a href="https://achiengcindy.com/how-set-django-environment-linux-beginners/1" rel="noopener noreferrer"&gt;about setting django environment using pip and virtualenv&lt;/a&gt; and  &lt;a href="https://dev.to/hangtwenty/comment/2m3e"&gt;  M. Floering&lt;/a&gt; suggested I check &lt;code&gt;pipenv&lt;/code&gt;. You guessed right , yes I did and I am loving it!&lt;br&gt;
&lt;code&gt;Pipenv&lt;/code&gt; is the official recommended python packaging tool  acccording to &lt;a href="https://docs.pipenv.org/" rel="noopener noreferrer"&gt;  pipenv.org&lt;/a&gt;.&lt;br&gt;
It is a great tool for managing your project's dependencies as well as install and uninstall packages.&lt;/p&gt;

&lt;p&gt;Seems like something pip and virtualenv did just well, &lt;strong&gt;but why pipenv?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Think of &lt;code&gt;pipenv &lt;/code&gt; as a powerful  combination of pip and virtualenv.&lt;/li&gt;
&lt;li&gt;Goodbye to  manually creating and managing you virtual environments &lt;code&gt;pipenv &lt;/code&gt;does it for you!.&lt;/li&gt;
&lt;li&gt;Great at managing project's dependencies.Instead of pip's &lt;code&gt;requirements.txt&lt;/code&gt;,  &lt;code&gt;pipenv &lt;/code&gt; creates two files the &lt;code&gt;pipfile&lt;/code&gt; for the packages you installed directly and &lt;code&gt;pipfile.lock&lt;/code&gt; for the dependencies and the specific version of the packages based on your pipfile.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  pipenv workfow
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Create virtualenv if doesn't exist already. &lt;/li&gt;
&lt;li&gt;Create &lt;code&gt;pipfile&lt;/code&gt; to manage the packages installed by you&lt;/li&gt;
&lt;li&gt;Finally, creates &lt;code&gt;pipfile.lock&lt;/code&gt; to manage dependencies for the packages in pipfile&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Let's get started!
&lt;/h4&gt;

&lt;p&gt;We use &lt;code&gt; pip&lt;/code&gt; to install &lt;code&gt;pipenv&lt;/code&gt;,so ensure you have  both python and pip installed.&lt;br&gt;
To check if pip is  installed run:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pip --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;.. and python:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Installing pipenv&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pip install --user pipenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I have used the user installation otherwise just run  $ pip install pipenv.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Using pipenv&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that we have successfully installed &lt;code&gt;pipenv&lt;/code&gt;, let's use it. Create the project directory and name it(I will call mine laughing-blog) and then change directory into the project's folder.&lt;br&gt;
Let's  Initiate  &lt;code&gt;pipenv&lt;/code&gt; by using the &lt;code&gt; install&lt;/code&gt; command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ mkdir laughing-blog //projectname
$ cd laughing-blog
$ pipenv --three install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:Specify  your python version by using &lt;code&gt;$ pipenv --three&lt;/code&gt; for python 3 and &lt;code&gt;$ pipenv --two &lt;/code&gt; for python 2.To use an  abitrary python version do:&lt;br&gt;
&lt;code&gt;pipenv --python 3.6.4&lt;/code&gt; or just &lt;code&gt;$ pipenv install&lt;/code&gt; to use the default python  version.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The above code creates a new virtual environment for your project if it doesn’t exist already and the two magic files, &lt;code&gt;Pipfile&lt;/code&gt; and &lt;code&gt;Pipfile.lock&lt;/code&gt; in your project directory.&lt;/p&gt;

&lt;p&gt;Below is a breakdown of the  &lt;strong&gt;pipenv install&lt;/strong&gt; output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;virtualenv&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Creating a virtualenv for this project…
Using /usr/bin/python3 (3.5.2) to create virtualenv
Virtualenv location: /home/cindy/.local/share/virtualenvs/laughing-blog-FpALE3CM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;pipfile&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Creating a Pipfile for this project…
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Finally, &lt;strong&gt;pipfile.lock&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (711973)!
Installing dependencies from Pipfile.lock (711973)…
🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Activating Virtualenv&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To activate virtualenv,simply run:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pipenv shell
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To exit virtulalenv,run:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ exit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Managing Packages
&lt;/h4&gt;

&lt;p&gt;To install a package simply run:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pipenv  install &amp;lt;packagename&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;... and to remove the package in the pipfile run:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pipenv  uninstall &amp;lt;packagename&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  understanding pipfile and pipfile.lock
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Pipfile&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Pipfile&lt;/code&gt; manages the packages that you install,think of it as an  upgrade of &lt;code&gt;requirements.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;What makes pipfile  superior to requirements.txt&lt;/p&gt;

&lt;p&gt;Lets look at a sample of  &lt;code&gt;requirements.txt&lt;/code&gt; file&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:simply run &lt;code&gt;pip freeze &amp;gt; requirements.txt&lt;/code&gt; to generate the above file&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
certifi==2018.4.16
chardet==3.0.4
defusedxml==0.5.0
Django==2.0.4
django-allauth==0.35.0
idna==2.6
oauthlib==2.0.7
python3-openid==3.1.0
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You will notice that &lt;code&gt;requirements.txt&lt;/code&gt; list all the package we installed , version and the  dependencies as well.&lt;br&gt;
 &lt;code&gt;pipfile&lt;/code&gt; holds the  packages we installed and spare the rest to  &lt;code&gt;pipfile.lock&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;pipfile.lock&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the file that contains the dependencies based on the packages present in  &lt;code&gt;Pipfile&lt;/code&gt;, the specific version of the packages to be used avoiding the risks of automatically upgrading packages that depend upon each other and breaking your project dependency tree.&lt;/p&gt;

&lt;p&gt;If pipfile.lock wasn't created for some reason, you can lock the currently installed packages by running:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pipenv lock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;pipfile sample&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; [packages]
 django = "*"
 django-allauth = "*"

 [requires]
 python_version = "3.5"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;pipfile.lock sample&lt;/strong&gt;&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "django-allauth": {&lt;br&gt;
        "hashes": [&lt;br&gt;
            "sha256:7b31526cccd1c46f9f09acf0703068e8a9669337d29eb065f7e8143c2d897339"&lt;br&gt;
        ],&lt;br&gt;
        "index": "pypi",&lt;br&gt;
        "version": "==0.35.0"&lt;br&gt;
    },&lt;br&gt;
    "idna": {&lt;br&gt;
        "hashes": [&lt;br&gt;
            "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f",&lt;br&gt;
            "sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4"&lt;br&gt;
        ],&lt;br&gt;
        "version": "==2.6"&lt;br&gt;
    },&lt;br&gt;
    "oauthlib": {&lt;br&gt;
        "hashes": [&lt;br&gt;
            "sha256:09d438bcac8f004ae348e721e9d8a7792a9e23cd574634e973173344046287f5",&lt;br&gt;
            "sha256:909665297635fa11fe9914c146d875f2ed41c8c2d78e21a529dd71c0ba756508"&lt;br&gt;
        ],&lt;br&gt;
        "version": "==2.0.7"&lt;br&gt;
    },&lt;br&gt;
    "python3-openid": {&lt;br&gt;
        "hashes": [&lt;br&gt;
            "sha256:0086da6b6ef3161cfe50fb1ee5cceaf2cda1700019fda03c2c5c440ca6abe4fa",&lt;br&gt;
            "sha256:628d365d687e12da12d02c6691170f4451db28d6d68d050007e4a40065868502"&lt;br&gt;
        ],&lt;br&gt;
        "version": "==3.1.0"&lt;br&gt;
    },&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h5&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Conclusion&lt;br&gt;
&lt;/h5&gt;

&lt;p&gt;Now,you know the definition,advantages and how pipenv functions.And the difference between the two magic files pipfile and pipfile.lock.&lt;/p&gt;

&lt;p&gt;This Post was originally posted on &lt;a href="https://achiengcindy.com/pipenv-new-python-packaging-tool/5/" rel="noopener noreferrer"&gt;achiengcindy.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>pip</category>
      <category>pipenv</category>
      <category>python3</category>
      <category>virtualenv</category>
    </item>
    <item>
      <title>Laughing Blog Tutorial  Part 2 - Handling Django Forms</title>
      <dc:creator>Cindy Achieng</dc:creator>
      <pubDate>Sat, 07 Apr 2018 20:09:37 +0000</pubDate>
      <link>https://forem.com/cindyachieng/laughing-blog-tutorial-series-part-2--creating-a-newsletter-app-3dph</link>
      <guid>https://forem.com/cindyachieng/laughing-blog-tutorial-series-part-2--creating-a-newsletter-app-3dph</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fCWnxJ8_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7yekhr15bh7ano2v23hl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fCWnxJ8_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7yekhr15bh7ano2v23hl.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Forms provide a rich way of interacting with users. However, the form handling process is complex. Forms accept user input which poses a major security threat. I like to think of it as an unlocked door. You definitely need some security measures. The rule of the thumb is to never trust a user input or worse malicious attackers taking advantage of unsuspecting users. Caution is required to ensure that the user's data is sanitized and field validation is taken into consideration.&lt;/p&gt;

&lt;h3&gt;
  
  
  From Class
&lt;/h3&gt;

&lt;p&gt;Django has an inbuilt &lt;code&gt;form Class&lt;/code&gt; that allows you to easily create forms. You define the fields of your form, specify the layout, display widgets labels, specify how they have to validate user input and the messages associated with invalid fields. It also provides methods for rendering itself in templates using predefined formats such as tables, list or paragraphs.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will focus on creating, processing forms and rendering to the template. The task is to create a form that enables users to subscribe to the newsletter app and then send the new subscribers a welcome email.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Newsletter App
&lt;/h3&gt;

&lt;p&gt;In Django, apps are small components used to build projects For an app to be active, add it to the list of &lt;code&gt;settings.INSTALLED_APPS.&lt;/code&gt; .Apps perform a specific function and can be reused in various projects.&lt;br&gt;
Since we are creating a newsletter, we will name it a newsletter. Make sure you are in the same directory as &lt;code&gt;manage.py&lt;/code&gt; and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python manage.py startapp newsletter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When Django creates the &lt;code&gt;newsletter app&lt;/code&gt;, it also  creates some files and the structure look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt; &lt;span class="n"&gt;newsletter&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
        &lt;span class="n"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
        &lt;span class="n"&gt;admin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
        &lt;span class="n"&gt;apps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
        &lt;span class="n"&gt;migrations&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
            &lt;span class="n"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
        &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
        &lt;span class="n"&gt;tests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
       &lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to use the app, we must activate it by adding it to &lt;code&gt;settings.INSTALLED_APPS&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;INSTALLED_APPS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
        &lt;span class="s"&gt;'newsletter'&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;Now our app is installed and activated, let make it do something!&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Models
&lt;/h3&gt;

&lt;p&gt;Next, we going to create our model in models.py. For each model defined Django will create a table for it in the database. Let's define our model and name it  NewsUsers and give it 3 fields &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt; and &lt;code&gt;date_added&lt;/code&gt;&lt;br&gt;
write the following code in your &lt;strong&gt;newsletter/models.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.db&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;NewsUsers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EmailField&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;date_added&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DateField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auto_now_add&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__str__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;import the &lt;code&gt;models&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Next,I have defined 3 fields:&lt;code&gt;name&lt;/code&gt;,&lt;code&gt;email&lt;/code&gt; and  the &lt;code&gt;date_added&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;__str__()&lt;/code&gt; method simply tell python to display a human-readable representation of the model&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Make and Run Migrations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python manage.py makemigrations newsletter
python manage.py migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Anytime you make changes to the models remember to run migrations&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Adding Models to Admin Site
&lt;/h3&gt;

&lt;p&gt;We will create a simple admin site to manage the newsletters users&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.contrib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;admin&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;.models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;NewsUsers&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;NewsletterAdmin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;admin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ModelAdmin&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;list_display&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'date_added'&lt;/span&gt;&lt;span class="p"&gt;,)&lt;/span&gt;
&lt;span class="n"&gt;admin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;NewsUsers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;NewsletterAdmin&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;Create a Superuser and runserver&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To Interact with the admin site, we must create a user with admin privileges&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python manage.py createsuperuser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then input the credentials. Below is a snippet&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Username: laughing-blog
Email address: &lt;span class="s2"&gt;"email Adress"&lt;/span&gt;
Password: 
Password &lt;span class="o"&gt;(&lt;/span&gt;again&lt;span class="o"&gt;)&lt;/span&gt;: 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the server and navigate to  &lt;code&gt;http://127.0.0.1:8000/admin&lt;/code&gt; on the browser.Log in using superuser credentials you created above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; python manage.py runserver
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are successful then you will see an interface similar to this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xG6L2VQJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/krXpt4U.png%3F1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xG6L2VQJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/krXpt4U.png%3F1" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Django  is 'smart' and naturally pluralizes the model In admin &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We have NewsUserss and that is not cool! To avoid such a  scenario, define &lt;code&gt;meta class&lt;/code&gt; in models and set the &lt;code&gt;verbose _name=' singular'&lt;/code&gt;  and &lt;code&gt;verbose_name_plural.&lt;/code&gt;&lt;br&gt;
Your  models should look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.db&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;NewsUsers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EmailField&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;date_added&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DateField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auto_now_add&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Meta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;verbose_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"NewsUser"&lt;/span&gt;
        &lt;span class="n"&gt;verbose_name_plural&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"NewsUsers"&lt;/span&gt;
        &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__str__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;always run migrations after modifying the models&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After applying migrations, run the server again and navigate to the admin interface and the extra &lt;code&gt;s&lt;/code&gt; should be gone and if you click to add the user, you should be able to add users in the newsletter list&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oBXjfQny--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/m4zwiYC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oBXjfQny--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/m4zwiYC.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the Newsletter Form
&lt;/h3&gt;

&lt;p&gt;Django has two base classes. The &lt;code&gt;form&lt;/code&gt; class and &lt;code&gt;modelForm&lt;/code&gt; for creating forms. With the  &lt;code&gt;form&lt;/code&gt;  you get to create standard forms and the &lt;code&gt;ModelForm&lt;/code&gt; allows you to build forms from the model's fields. &lt;/p&gt;

&lt;p&gt;Depending on your needs you can choose either of the two methods. The standard forms are best in scenarios where the forms do not interact with the database directly.&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Forms: Allows you to build Standard Forms&lt;/li&gt;
&lt;li&gt;ModelForm: Allows you to build forms from a model by defining fields using the &lt;code&gt;Meta class&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;In our case, we will create a form using the ModelForm &lt;br&gt;
Create a new file called &lt;code&gt;forms.py&lt;/code&gt; in  &lt;code&gt;newsletter app&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;it's a general practice to create Django forms in a file called &lt;code&gt;forms.py&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's go ahead and declare the form. To create our &lt;code&gt;ModelForm&lt;/code&gt;, import the form class and the model class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;forms&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;.models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;NewsUsers&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;NewsUserForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;forms&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ModelForm&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Meta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NewsUsers&lt;/span&gt;
        &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Import the forms library&lt;/li&gt;
&lt;li&gt;derive from the ModelForm class&lt;/li&gt;
&lt;li&gt;declare the Fields we need in the meta section&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Handling Django forms in views
&lt;/h3&gt;

&lt;p&gt;It's time for the heavy lifting&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.shortcuts&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;render&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;.forms&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;NewsUserForm&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;NewsUsers&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;newsletter_subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'POST'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NewsUserForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_valid&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
      &lt;span class="n"&gt;instance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
      &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'your email is already added to our database'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NewsUserForm&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'form'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"newsletter/subscribe.html"&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;huh! what is all that?&lt;/p&gt;

&lt;p&gt;First things first, let us deal with the importations. Import &lt;code&gt;NewsUserForm&lt;/code&gt; from &lt;code&gt;form.py&lt;/code&gt;  and  &lt;code&gt;NewsUsers&lt;/code&gt; from  &lt;code&gt;models.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The first step in handling forms in Django is to display an empty form to the user. When our view is initially loaded with a GET request, we create a new form instance that will be used to display the empty form in the template.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NewsUserForm&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;A form may be blank in the case where you creating a new record or may be pre-populated with initial values. At this stage, the form is unbound because it is not associated with any user input although it may have initial values. At this point, the form is &lt;code&gt;unbound&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The second step is to check if the user has filled the form and submit it via POST. So, If it is a POST request, we create a new form instance and populate it with data from the request. This process is called &lt;code&gt;binding&lt;/code&gt; and the form is said to be &lt;code&gt;bound&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'POST'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NewsUserForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;binding allows us to validate data. I mean it's meaningless validating a form with no data right?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Next, Check for form validation and clean the data. The method &lt;code&gt;is_valid()&lt;/code&gt;, is used to check if the form is valid. Form validation means the data accepted is as specified when defining the fields. In our case, the &lt;code&gt;name&lt;/code&gt; field&lt;code&gt;accepts up to a maximum of 30 characters only, the&lt;/code&gt;email` field must be a valid email and so on. This method will return true if the fields contain valid data or false if invalid throwing errors.&lt;/p&gt;

&lt;p&gt;If the form is valid, we clean the data. This means performing sanitization of the input i.e removing invalid characters that might be used to send malicious content to the server.&lt;/p&gt;

&lt;p&gt;If we have a valid form as in our case, we process the form. To save the data we call &lt;code&gt;save()&lt;/code&gt; method.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"save()method"&lt;br&gt;
It is worth mentioning that only &lt;code&gt;modelForms&lt;/code&gt; have this method and not &lt;code&gt;form&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Creating newsletter/urls.py
&lt;/h3&gt;

&lt;p&gt;Okay, our data is saved in the database. We now want to create the url that will display the form we just created.&lt;br&gt;
Create a new file in newsletter app and name it &lt;code&gt;urls.py&lt;/code&gt; then place the code below:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;python&lt;br&gt;
from django.urls import path&lt;br&gt;
from .views import newsletter_subscribe&lt;br&gt;
app_name = 'newsletter'&lt;br&gt;
urlpatterns = [&lt;br&gt;
path('subscribe', newsletter_subscribe, name='subscribe'),&lt;br&gt;
]&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;br&gt;
In  the main urls.py include the uurl confi from the newsletter app&lt;/p&gt;

&lt;h3&gt;
  
  
  Main urls.py
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;python&lt;br&gt;
from django.contrib import admin&lt;br&gt;
from django.urls import path,include&lt;br&gt;
urlpatterns = [&lt;br&gt;
path('admin/', admin.site.urls),&lt;br&gt;
path('newsletter/',include('newsletter.urls' , namespace='newsletter')),&lt;br&gt;
]&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;br&gt;
To check if the form is being displayed, run the server using the command down below&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;bash &lt;br&gt;
python manage.py runserver&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When you navigate to  &lt;code&gt;http://127.0.0.1:8000/newsletter&lt;/code&gt; on the browser, it will return an error that the template does not exist.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DggVU56e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/GRNghQt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DggVU56e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/GRNghQt.png" alt="template"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do not panic just yet, we just need to create the template subscribe.html&lt;/p&gt;

&lt;h3&gt;
  
  
  Rendering the Form in  Templates
&lt;/h3&gt;

&lt;p&gt;Create a templates directory in newsletter app called &lt;code&gt;templates&lt;/code&gt; and inside it create another directory called newsletter which will hold the file &lt;code&gt;subscribe.html&lt;/code&gt; file. The structure should look like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;python&lt;br&gt;
newsletter&lt;br&gt;
 templates&lt;br&gt;
 newsletter&lt;br&gt;
   subscribe.html&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;subscribe.html&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;python&lt;br&gt;
    {% extends "base.html" %}&lt;br&gt;
    {% block content %}&lt;br&gt;
    &amp;lt;form action="{% url 'newsletter:subscribe' %}" method="post"&amp;gt;&lt;br&gt;
    {% csrf_token %}&lt;br&gt;
    {{ form.as_p }}&lt;br&gt;
    &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;&lt;br&gt;
    &amp;lt;/form&amp;gt;&lt;br&gt;
    {% endblock %}&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;you must include cross-site request forgery {% csrf_token %} tag for POST requests&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Run the Server again and navigate to &lt;code&gt;http://127.0.0.1:8000/newsletter/subscribe&lt;/code&gt; &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; $ python manage.py runserver
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;you should see the form below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Gyy4-lMK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/044ItZF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gyy4-lMK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/044ItZF.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fill in your name and email and when you hit submit, it saves&lt;br&gt;
check the admin interface and you should see the user you just added.&lt;/p&gt;

&lt;h3&gt;
  
  
  Recap
&lt;/h3&gt;

&lt;p&gt;So far we have created&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Newsletter App&lt;/li&gt;
&lt;li&gt;Creating Models&lt;/li&gt;
&lt;li&gt;Adding Models to admin site&lt;/li&gt;
&lt;li&gt;Creating forms from models&lt;/li&gt;
&lt;li&gt;Writing views&lt;/li&gt;
&lt;li&gt;Creating urls&lt;/li&gt;
&lt;li&gt;Creating Superuser&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  newsletter/views.py
&lt;/h3&gt;

&lt;p&gt;The above view will work just fine, but some custom validation on the &lt;code&gt;email field&lt;/code&gt; is required to ensure that the same email is not used more than once!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;try using the same email more than once and it will save&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We do not want that to happen right? so let's add some queries to filter the email. If the email already exists we notify the user it already exists else save.&lt;br&gt;
Update your views to look like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;python&lt;br&gt;
from django.shortcuts import render&lt;br&gt;
from .forms import NewsUserForm&lt;br&gt;
from .models import NewsUsers&lt;br&gt;
def newsletter_subscribe(request):&lt;br&gt;
  if request.method == 'POST':&lt;br&gt;
    form = NewsUserForm(request.POST)&lt;br&gt;
    if form.is_valid():&lt;br&gt;
      instance = form.save(commit=False) #we dont want to save just yet&lt;br&gt;
      if NewsUsers.objects.filter(email=instance.email).exists():&lt;br&gt;
        print( "your Email Already exists in our database")&lt;br&gt;
      else:&lt;br&gt;
        instance.save()&lt;br&gt;
        print( "your Email has been submitted to our database")    &lt;br&gt;
  else:&lt;br&gt;
    form = NewsUserForm()&lt;br&gt;
  context = {'form':form}&lt;br&gt;
  template = "newsletter/subscribe.html"&lt;br&gt;
  return render(request, template, context)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;br&gt;
Create the model instance with the save() method, but  don't save it to the database just yet  by calling &lt;code&gt;commit = False&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;save()&lt;/code&gt; method creates an instance of the model that the form is linked to and saves it to the database.&lt;/li&gt;
&lt;li&gt;If called with &lt;code&gt;commit=False&lt;/code&gt;, it creates the model instance but doesn't save to the database just yet!&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then, we check if the email exists by using &lt;code&gt;filter&lt;/code&gt; before we save. If it exists, we tell the user it already exists else save and display to the user it has been added to our database.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;fill the form using a new email and check if it saves. We have added a notification message on the console, so check your console for guidance. Use the same email again and check the console&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now it validates our emails, Great Work!&lt;/p&gt;

&lt;h3&gt;
  
  
  Sending Emails
&lt;/h3&gt;

&lt;p&gt;Sending Emails with Django is quite simple.All we need is  an Email service Provider.You can use  gmail or write to the console for  testing .Refer to  &lt;a href="https://achiengcindy.com/blog/2018/03/23/sending-emails-django-application-using-mailjet/"&gt;Sending Emails with mailjet&lt;/a&gt; because I will be using &lt;a href="https://www.mailjet.com/?tap_a=25852-4bddf6&amp;amp;tap_s=243499-30c71b&amp;amp;aff=243499-30c71b"&gt;mailjet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember the &lt;code&gt;.env&lt;/code&gt; file we created in &lt;a href="https://achiengcindy.com/blog/2018/04/01/laughing-blog-tutorial-part-1-project-structure/"&gt;Project Structure&lt;/a&gt; and update it with your &lt;code&gt;smtp&lt;/code&gt; credentials&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EMAIL_HOST=in-v3.mailjet.com
EMAIL_HOST_USER="Your Username"
EMAIL_HOST_PASSWORD="Your Password"
EMAIL_PORT=587
EMAIL_USE_TLS=True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Replace "Your Username"  with the actual username and "Your Password" with your actual password.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;settings.py&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EMAIL_HOST = config('EMAIL_HOST')
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
EMAIL_PORT = config('EMAIL_PORT', cast=int)
EMAIL_USE_TLS = config('EMAIL_USE_TLS', cast=bool)
DEFAULT_FROM_EMAIL = config('DEFAULT_FROM_EMAIL')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;newsletter/views.py&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We want to start sending emails, Import &lt;code&gt; send_mail&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;python&lt;br&gt;
from django.shortcuts import render&lt;br&gt;
from .forms import NewsUserForm&lt;br&gt;
from . models import NewsUsers&lt;br&gt;
from django.core.mail import send_mail&lt;br&gt;
def newsletter_subscribe(request):&lt;br&gt;
   if request.method == 'POST':&lt;br&gt;
    form = NewsUserForm(request.POST)&lt;br&gt;
    if form.is_valid():&lt;br&gt;
      instance = form.save(commit=False) #we do not want to save just yet&lt;br&gt;
      if NewsUsers.objects.filter(email=instance.email).exists():&lt;br&gt;
        print('your email Already exists in our database')&lt;br&gt;
      else:&lt;br&gt;
        instance.save()&lt;br&gt;
        print('your email has been submitted to our database')&lt;br&gt;
        send_mail('Laughing blog tutorial series', 'welcome', 'mail@achiengcindy.com',[instance.email], fail_silently=False) &lt;br&gt;
  else:&lt;br&gt;
    form = NewsUserForm()&lt;br&gt;
  context = {'form':form}&lt;br&gt;
  template = "newsletter/subscribe.html"&lt;br&gt;
  return render(request, template, context)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;"What is the difference between Bound and Unbound Form?"&lt;br&gt;
A &lt;code&gt;bound&lt;/code&gt; form has data associated with it. &lt;code&gt;Unbound &lt;/code&gt; form has no data associated with it.It is either empty or contain default values.To check if a form is bound use &lt;code&gt;is_bound()&lt;/code&gt; method.In our case &lt;code&gt;form.is_bound()&lt;/code&gt; return false while passing even an   empty dictionary binds the form.&lt;code&gt;form.is_bound({})&lt;/code&gt; returns true&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We have successfully created a basic &lt;code&gt;newsletter app&lt;/code&gt; and managed to  send a welcome message to new subscriptions.The  code for this tutorial is available on  &lt;a href="https://github.com/achiengcindy/laughing_blog"&gt; Github &lt;/a&gt;.&lt;br&gt;
In the next tutorial, we will continue to build our newsletter app by making it more readable! &lt;a href="https://twitter.com/achiengcindy_"&gt;Connect with me on Twitter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post was originally posted on &lt;a href="https://achiengcindy.com/blog/2018/04/07/laughing-blog-tutorial-part-2-handling-django-forms/"&gt;achiengcindy.com&lt;/a&gt; &lt;/p&gt;

</description>
      <category>django</category>
      <category>laughingblog</category>
      <category>newsletter</category>
    </item>
    <item>
      <title>How to set up Django Environment in Linux for beginners</title>
      <dc:creator>Cindy Achieng</dc:creator>
      <pubDate>Wed, 28 Mar 2018 15:53:48 +0000</pubDate>
      <link>https://forem.com/cindyachieng/-how-to-set-up-django-environment-in-linux-for-beginners-35am</link>
      <guid>https://forem.com/cindyachieng/-how-to-set-up-django-environment-in-linux-for-beginners-35am</guid>
      <description>&lt;p&gt;When  I started learning Django, finding a tutorial that had everything I needed was pretty hard
So hopefully this tutorial will help you get started!&lt;/p&gt;

&lt;h5&gt;
  
  
  What you will learn
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Create a virtualenv &lt;code&gt;test&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create a sample project called &lt;code&gt;HelloDjango&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create a demo Django app  called &lt;code&gt;accounts&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Finally configure the &lt;code&gt;settings.py&lt;/code&gt;
&lt;p&gt;Let’s dive right in&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Prerequisites
&lt;/h5&gt;

&lt;p&gt;Make sure you have the following installed on your computer to follow-through.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You got Linux Os installed (ubuntu, Debian)&lt;/li&gt;
&lt;li&gt;Python 3+&lt;/li&gt;
&lt;li&gt;Django 2.0&lt;/li&gt;
&lt;li&gt;Virtualenv&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Django Introduction
&lt;/h5&gt;

&lt;p&gt;According to &lt;a href="https://www.djangoproject.com/" rel="noopener noreferrer"&gt;djangoProject&lt;/a&gt;,Django is a python web framework for developers looking for a faster way to build web applications and with less code.Essentially, django is for perfectionists with deadlines&lt;/p&gt;

&lt;h5&gt;
  
  
  Why Consider Django?
&lt;/h5&gt;

&lt;p&gt;Please refer to the &lt;a href="https://www.djangoproject.com/" rel="noopener noreferrer"&gt;django Documentation&lt;/a&gt; for more info.I will give a personal opinion why it is really cool.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inbuilt Security features such as Cross site request forgery (CSRF) protection. &lt;/li&gt;
&lt;li&gt;Great Documentation.&lt;/li&gt;
&lt;li&gt;Faster because It has many inbuilt features such as Admin site, Authentication &lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Linux Installation
&lt;/h5&gt;

&lt;p&gt;I recommend Ubuntu or Debian .For this specific tutorial, I had mint installed because its light and it’s just a personal preference.&lt;/p&gt;

&lt;h5&gt;
  
  
  Python Installation
&lt;/h5&gt;

&lt;p&gt;Django is a python framework so first ensure you have python installed.The default installed in my Os is 2.7.Check the version of python installed by typing  the following command into your shell:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python --version
$ python -V  (Mind the capital) 
$ python2 -V
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above outputs&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Python 2.7.12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To check the version of Python3 &lt;/p&gt; 

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   $ python3 -V
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above outputs&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Python 3.5.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this tutorial ,we are using python 3.5 and higher.Type the command below to check which version 3 is installed&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You should see something close to this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can type CTRL+D to exit the interactive shell for now.&lt;/p&gt;

&lt;h5&gt;
  
  
  Installing Python
&lt;/h5&gt;

&lt;p&gt;If you do not have python installed,use this command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt-get install python3.5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;to install the latest version 3.6 check this &lt;a href="%20https://mintguide.org/other/794-python-3-6-install-latest-version-into-linux-mint.html"&gt;tutorial&lt;/a&gt; &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;
  
  
  Setting up Virtual Environment
&lt;/h5&gt;

&lt;p&gt;We could just create a Django application on our computer, but to control the packages unique for our application we will use Virtual Enviroment.Virtual Environment is useful when you want to create isolated environments, each running their own versions of packages.We can even create virtual environments with various python versions ! sounds cool.For this tutorial I am going to use virtualenv.&lt;/p&gt;

&lt;h5&gt;
  
  
  Virtualenv
&lt;/h5&gt;

&lt;p&gt;We can install virtualenv using python’s package manager pip.use the command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo pip install virtualenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;Pip is a useful python package tool that installs, updates, and remove Python packages/libraries used by Django and your other Python apps.Pip come installed with python 2.7+downloaded from &lt;a href="https://www.python.org/" rel="noopener noreferrer"&gt;python website&lt;/a&gt;.You just have to upgrade it using the command:&lt;br&gt;
       $ pip install -U pip &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You should get something like this if &lt;code&gt;virtualenv&lt;/code&gt;is already installed as in my case:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cindy@cindy-Veriton-M290 ~/Desktop $ pip install virtualenv
Requirement already satisfied: virtualenv in /home/cindy/.local/lib/python2.7/site-packages
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h5&gt;
  
  
  Create and name  virtualenv
&lt;/h5&gt;

&lt;p&gt;Once you have successfully installed virtualenv,next we  create the virtualenv test in shell.I like creating my project in documents Folder.So right-click and choose open a terminal here option.Once you open the terminal,type:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$  virtualenv -p python3 test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;test&lt;/code&gt; is just  a name,you could give it any name.The -p points to the python version you want to use ,in the above case python 3&lt;/p&gt;

&lt;h5&gt;
  
  
  Activate Virtualenv
&lt;/h5&gt;

&lt;p&gt;Now that we have created our virtualenv test,we need to use it to install django and other packages we will need.In order to use our virtualenv,we &lt;strong&gt;must&lt;/strong&gt;activate it. change directory to your virtual environment using:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$  cd test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then once you are inside the virtualenv directory,activate it as shown below:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; $ source bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;By now you should see your virtualenv in brackets&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(test)  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Below is a sample from my console:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(test) cindy@cindy-Veriton-M290 ~/test $ 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h5&gt;
  
  
  How to check packages installed in the virtualenv you just created
&lt;/h5&gt;

&lt;p&gt;run:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; $  pip freeze
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h5&gt;
  
  
  Django Installation
&lt;/h5&gt;

&lt;p&gt;our &lt;code&gt;virtualenv&lt;/code&gt; is running,let's install django .The version of django at the time of writing this article is 2.0.2.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pip install django
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ pip freeze 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;your console should list the installed packages&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(test) cindy@cindy-Veriton-M290 ~/test $ pip freeze
Django==2.0.2
pytz==2018.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;To specify django version,use:&lt;br&gt;
    $ pip install django==.For example to install django 1.11:&lt;br&gt;
               $ pip install django==1.11&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;
  
  
  Creating Django Project
&lt;/h5&gt;

&lt;p&gt;Django is successfully installed so lets create our project Structure! Type this in your console:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;django-admin startproject HelloDjango
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This command creates a template for our project.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HelloDjango/
    manage.py
    HelloDjango/
        __init__.py
        settings.py
        urls.py
        wsgi.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The outer &lt;code&gt;HelloDjango&lt;/code&gt; is the container holding our project.Its okay to change the name to something else say ‘src'.&lt;/p&gt;

&lt;p&gt;The inner&lt;code&gt; HelloDjango &lt;/code&gt;contains your site's configurations.I Highly recommend you leave it as it is, at least for now.&lt;/p&gt;

&lt;p&gt;Change to project directory&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   cd  HelloDjango
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;The project directory is the outer HelloDjango containing manage.py file.If you changed its name to src,then change directory to src.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h5&gt;
  
  
  Make Migrations
&lt;/h5&gt;

&lt;p&gt;We need to create a database and Django comes with sqlite .You are free to use any other databases of your choice.But for this tutorial we will use the sqlite. Change directory to the project root and make migrations by typing the command:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python manage.py makemigrations
 $ python manage.py migrate   
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h5&gt;
  
  
  Test development server
&lt;/h5&gt;

&lt;p&gt; To test if your project is working well,go to your project root directory then type this :

     $ python manage.py runserver
&lt;/p&gt;
&lt;p&gt;You should see something like this:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Performing system checks...
System check identified no issues (0 silenced).
 February 28, 2018 - 18:58:33
 Django version 2.0.2, using settings 'achieng_website.settings'
 Starting development server at http://127.0.0.1:8000/
 Quit the server with CONTROL-C.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;When you go to  http://127.0.0.1:8000/,If django was successfully installed you should get a success message"congratulations" &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuht26hr18xc567p6m349.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuht26hr18xc567p6m349.png" alt="SucessPage" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Configuring  Settings.py
&lt;/h5&gt;

&lt;p&gt;We will make some changes on our settings.py.This file help us manage our static files such as css,js, and images.First we going to change &lt;code&gt;Templates DIR&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
               ...
            ],
        },
    },
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add  &lt;code&gt;staticfiles_Dirs &lt;/code&gt; as well:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      STATICFILES_DIRS = (
         os.path.join(BASE_DIR, 'static'),
      )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h5&gt;
  
  
  Change time zone
&lt;/h5&gt;

&lt;p&gt;Finally,lets go back to our &lt;strong&gt;settings.py&lt;/strong&gt;  and change our timezone.I come from Nairobi so my time zone is Africa/Nairobi.Check yours on: 
&lt;a href="https://en.wikipedia.org/wiki/List_of_time_zones_by_country" rel="noopener noreferrer"&gt;wikipedia&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Africa/Nairobi'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h5&gt;
  
  
  Creating an App
&lt;/h5&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; python manage.py startapp accounts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Your project structure should be like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; accounts/
    __init__.py
    admin.py
    apps.py
    migrations/
        __init__.py
    models.py
    tests.py
   views.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The app creates modules such as &lt;code&gt;models.py&lt;/code&gt;,&lt;code&gt;admin.py&lt;/code&gt;,&lt;code&gt;views.py&lt;/code&gt;,&lt;code&gt;apps.py&lt;/code&gt;.
Django implements MVC Pattern&lt;/p&gt;

&lt;p&gt;For the app you have just created to be used,add it to &lt;code&gt;INSTALLED_APPS&lt;/code&gt; in the &lt;code&gt;settings.py&lt;/code&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'accounts',
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This Post was originally posted on&lt;a href="https://achiengcindy.com/permalink/1/" rel="noopener noreferrer"&gt;achiengBlog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>django</category>
      <category>beginners</category>
      <category>virtualenv</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
