<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lewis Kori on Medium]]></title>
        <description><![CDATA[Stories by Lewis Kori on Medium]]></description>
        <link>https://medium.com/@lewiskori?source=rss-bc9050c089c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CNjT614ZgsmfFrwQEdNjsA.png</url>
            <title>Stories by Lewis Kori on Medium</title>
            <link>https://medium.com/@lewiskori?source=rss-bc9050c089c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:18:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lewiskori/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to set up a new Django project]]></title>
            <link>https://lewiskori.medium.com/how-to-set-up-a-new-django-project-7533ed8f8e73?source=rss-bc9050c089c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7533ed8f8e73</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Lewis Kori]]></dc:creator>
            <pubDate>Wed, 02 Dec 2020 19:32:12 GMT</pubDate>
            <atom:updated>2020-12-02T19:32:12.202Z</atom:updated>
            <content:encoded><![CDATA[<p>How to set up a new Django project</p><p>This post is a continuation of the <a href="https://lewiskori.com/series/intro-to-multi-tenant-apps-with-django/">django multi-tenancy series</a>. In this part, we’ll begin to implement the backend of the multitenant Django app. We’ll be setting up a Django project from scratch.</p><p>The project source code up until this point is available on the <a href="https://github.com/lewis-kori/budgeting-app/tree/setup">github setup branch</a>.</p><p>The project’s final outcome can be explored using this <a href="https://defyne.lewiskori.com/">live demo</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Lpiy7twkspLohQRU.png" /></figure><h3>Installing project dependencies</h3><p>For this project, we’ll need to have python 3+ installed. You can find the necessary steps in <a href="https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-ubuntu-16-04">this digital ocean post</a>. Next, we’ll need to make virtual environments for installing project dependencies.</p><h3>Install virtualenv</h3><p>pip install virtualenv</p><h3>Create a new virtualenv</h3><p>virtualenv yourenvname -p python3.8</p><h3>Activate virtual environment</h3><p>source yourenvname/bin/activate</p><p>Run this command within the directory the virtual environment was created in.</p><p>Once your virtual environment is activated, there’s a number of dependencies we’ll be needing for the project:</p><ul><li>Django and the djangorestframework: for an extensive introduction on how to use these libraries, check out my previous post on <a href="https://lewiskori.com/blog/building-web-ap-is-with-django/">building web apis with django</a>.</li><li>Djoser: REST implementation of Django authentication system. The Djoser library provides a set of Django Rest Framework views and endpoints to handle basic actions such as registration, login, logout, password reset, and account activation</li><li>django-rest-framework-simplejwt: provides a JSON Web Token authentication backend for the Django REST Framework.</li></ul><p>My previous post on setting up Django APIs with JWT authentication should get you started on what JWTs are and how to implement them in Django. 😃</p><p>The repository has a requirements.txt and you can mass install all the dependencies by running pip install -r requirements.txt</p><blockquote><em>Curious on some of the popular dependencies I use with Django? This post has some </em><a href="https://lewiskori.com/blog/handy-resources-and-tools-for-python-and-django-developers/"><em>handy tools and resources for python programmers.</em></a></blockquote><p>To kick off the new Django project, run the following once you’ve activated the previously created virtual environment.</p><p>django-admin startproject budgeting</p><p>Now to start with the first app that we’ll require for the next section:</p><p>cd budgeting python manage.py startapp users</p><p>users will be our first app for this project and we&#39;ll put all the authentication logic here.</p><p>Next up, we’ll cover user authentication in a multi-tenant app powered by django.🤠</p><h3>open to collaboration</h3><p>I recently made a collaborations page on my website. Have an interesting project in mind or want to fill a part-time role?</p><p>You can now <a href="https://lewiskori.com/collaborate">book a session</a> with me directly from my site.</p><p><em>Originally published at </em><a href="https://lewiskori.com/blog/how-to-set-up-a-new-django-project/"><em>https://lewiskori.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7533ed8f8e73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handy resources and tools for python and Django developers]]></title>
            <link>https://medium.com/analytics-vidhya/handy-resources-and-tools-for-python-and-django-developers-348e8959b819?source=rss-bc9050c089c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/348e8959b819</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[django-rest-framework]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Lewis Kori]]></dc:creator>
            <pubDate>Sun, 15 Nov 2020 16:48:20 GMT</pubDate>
            <atom:updated>2020-11-15T16:48:20.515Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o22fbIZ82oppUXc8jHfeDQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@heyfaisal?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Faisal M</a> on <a href="https://unsplash.com/s/photos/django?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Handy resources and tools for python and Django developers</p><p>I’ve been developing software using Django for a while now and over the years, there’s a couple of resources and Libraries that I’ve come to depend on. They’re tried and tested and can be easily extended to suit my needs.</p><p>I did another post <a href="https://lewiskori.com/blog/list-of-resources-for-junior-developers/">highlighting resources for junior devs</a>. You can check it out if you’re interested.</p><p>I’ll start the list with some technical content creators who have been invaluable to the success I’ve had in Django development.</p><h3>Content Creators</h3><h3>Simple is better than complex</h3><p><a href="https://simpleisbetterthancomplex.com/">This is a blog</a> run by Vitor Freitas that provides Django technical knowledge and tips. I highly recommend it.</p><h3>Real Python</h3><p>Yet another <a href="https://realpython.com/">long-running blog</a>. Every python developer has at least encountered the platform once or twice while doing research for their projects.</p><h3>thegreencodes</h3><p>This a <a href="https://marvinkweyu.thegreencodes.com/articles/">blog</a> run by <a href="https://twitter.com/marvinus_j">Marvin Kweyu</a> a Kenyan Software developer who describes himself as a Djangonaout. The articles are well researched and written articulately.</p><h3>Corey Schaefer</h3><p>The <a href="https://www.youtube.com/user/schafer5">youtube channel</a> has a plethora of resources. These are not limited to <a href="https://www.youtube.com/playlist?list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p">Django development</a> but also python programming in general. His passion and dedication can be felt in every video and you’re sure to learn a lot from there.</p><h3>The New Boston</h3><p>This was my <a href="https://www.youtube.com/playlist?list=PL6gx4Cwl9DGBlmzzFcLgDhKTTfNLfX1IK">first stop</a> while doing web dev and Bucky’s contribution to the software world cannot be understated. Glad to see <a href="https://www.youtube.com/watch?v=D-3i1g5YFik">he’s back to content creation</a> after a long hiatus.</p><h3>Talk python FM</h3><p><a href="https://talkpython.fm/">talkpython.fm</a> is a Podcast hosted by Michael Kennedy where they discuss various issues in the python-dev world. One of their episodes on <a href="https://talkpython.fm/episodes/show/277/10-tips-every-django-developer-should-know">Django development best Practises</a> was particularly useful and eye-opening.</p><h3>Online communities</h3><p>In as much as the content creators have provided information, they may not always be available when you need some pressing questions answered. This is where online communities come in to fill in the gap. These are platforms of like-minded individuals who you can reach out to and in most cases, answer your questions or help you to grow in one way or another.</p><h3>dev.to python tag</h3><p><a href="https://dev.to/">dev.to</a> is a community of software developers and people interested in software development. It organizes their content in form of tags. One of my favourite ones is the<a href="https://dev.to/t/python">#python</a> tag where people from across the globe regularly post their content here. Be it questions or technical blog posts/podcasts.</p><h3>Indiehackers django group</h3><p>An indie hacker according to the platform is:</p><ol><li>person building an online project that can generate revenue.</li><li>person seeking financial independence, creative freedom, and the ability to work on their own schedule.</li></ol><p><a href="https://www.indiehackers.com/">indiehackers.com</a> is exactly that, a community of online people seeking to build online projects that generate income and enable them to attain financial freedom. Django being one of the biggest software dev frameworks is an enabler of such dreams. So it’s only fitting that the platform should have a <a href="https://www.indiehackers.com/group/django">dedicated Django group</a> for the hundreds of entrepreneurs that trust the framework to turn their dreams into reality.</p><h3>PythonKe telegram group</h3><p>Being a software developer based in Nairobi, Kenya the <a href="https://t.me/pythonKE">telegram group</a> keeps me informed and grounded on issues affecting devs in my area as well as providing a place I can quickly get my questions answered.</p><h3>Software Libraries</h3><h3>Djangorestframework</h3><p><a href="https://www.django-rest-framework.org/">Django REST framework</a> is a powerful and flexible toolkit for building Web APIs with Django. Django in itself has support for JSON serialization but DRF makes the process so easy. The API development approach makes it easy to build solutions that enable you to create Frontends with modern javascript frameworks like react, angular and Vue. The possibilities are endless.</p><p><a href="https://pypi.org/project/django-cors-headers/">django-cors-headers</a> Django App that adds Cross-Origin Resource Sharing (CORS) headers to responses. This allows in-browser requests to your Django application from other origins. Adding CORS headers allows your resources to be accessed on other domains. However, It’s important you understand the implications before adding the headers since you could be unintentionally opening up your site’s private data to others. The cors-headers-site provides a number of resources to help you understand these implications.</p><h3>Djoser</h3><p>The <a href="https://djoser.readthedocs.io/en/latest/introduction.html">Djoser</a> library provides a set of Django Rest Framework views and endpoints to handle basic actions such as registration, login, logout, password reset, and account activation. You could build out the features yourself but this has most of the features you may end up building.</p><p>My previous post highlights <a href="https://lewiskori.com/blog/user-registration-and-authorization-on-a-django-api-with-djoser-and-json-web-tokens/">user authentication and authorization with jwts</a>. All powered by Djoser.</p><h3>Django storages</h3><p><a href="https://django-storages.readthedocs.io/en/latest/">Django-storages</a> is a collection of custom storage backends for Django. The library allows you to configure Django to store static and media files to various platforms such as amazon s3, <a href="https://m.do.co/c/2282403be01f">digital ocean</a>, google cloud and Dropbox.</p><h3>Django channels and djangochannelsrestframework</h3><p><a href="https://pypi.org/project/djangochannelsrestframework/">djangochannelsrestframework</a> provides a DRF like an interface for building channels-v2 WebSocket consumers. The library leverages on the power of <a href="https://lewiskori.com/blog/handy-resources-and-tools-for-python-and-django-developers/#djangorestframework">djangorestframework</a> and <a href="https://channels.readthedocs.io/en/stable/">django-channels</a> to provide seamless integration of the two.</p><p>Other notable libraries are:</p><ol><li><a href="https://django-allauth.readthedocs.io/en/latest/installation.html">django-allauth</a></li><li><a href="https://django-filter.readthedocs.io/en/stable/">django-filter</a></li><li><a href="https://pypi.org/project/python-decouple/">python-decouple</a></li></ol><h3>Conclusion</h3><p>That’s it from me. If you have any additional resources drop them in the comments. I’m curious to see what tools you use.</p><h4>Open to collaboration</h4><p>I recently made a collaborations page on my website. Have an interesting project in mind or want to fill a part-time role? You can now <a href="https://lewiskori.com/collaborate">book a session</a> with me directly from my site.</p><p><em>Originally published at </em><a href="https://lewiskori.com/blog/handy-resources-and-tools-for-python-and-django-developers/"><em>https://lewiskori.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=348e8959b819" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/handy-resources-and-tools-for-python-and-django-developers-348e8959b819">Handy resources and tools for python and Django developers</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building my new site with gridsome(vue.js)]]></title>
            <link>https://lewiskori.medium.com/building-my-new-site-with-gridsome-vue-js-bd1658e596f7?source=rss-bc9050c089c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd1658e596f7</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[gridsome]]></category>
            <category><![CDATA[portfolio]]></category>
            <dc:creator><![CDATA[Lewis Kori]]></dc:creator>
            <pubDate>Wed, 16 Sep 2020 22:01:01 GMT</pubDate>
            <atom:updated>2020-09-16T22:01:01.316Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*CF0FWtNihYv0FcWlyQyd3w.png" /></figure><p>I’m really excited to finally launch my new website 🥳. It’s been a labor of love and in terms of growth, I must say I really enjoyed working on it. For the tech stack, I went out of my comfort zone as I am majorly a backend developer. So I used the opportunity to polish on my frontend skills. I utilized my favorite javascript framework, vue.js. I used their static site generator, gridsome. <a href="https://bulma.io/">Bulma</a> was used for CSS. In this article, I’ll explain how this decision came to be, what I was using before, and my thoughts on gridsome.</p><h3>What I was using before</h3><p>As aforementioned, I am primarily a backend developer, so the first version of my website wasn’t up to date with the modern web trends. I did this on purpose because at the time my main aim was to perfect my backend skills and so heavily concentrated on that aspect.</p><p>I used Django(python web framework), Postgresql, and a template from colorlib which I extended and modified to suit my needs. With time, I wrapped that with docker and redeployed the entire site. I used that project as a learning opportunity. You can read all about the lessons I learned <a href="https://lewiskori.com/blog/lessons-learnt-from-building-and-deploying-a-portfolio-website/">here</a>.</p><p><a href="https://v-one.lewiskori.com/">Here’s version one of the site</a> for comparison.</p><h3>Why I switched to gridsome</h3><p>So my site was working fine and I absolutely loved it. With time however and as I became more experienced in the backend, that curiosity bug that most developers come shipped with 😅 began nudging at me. Since I’d been learning vue.js and came to love it, I thought this would be a great opportunity to flex my frontend muscles a bit. Besides, what better way to learn than doing?</p><p>Other than these reasons, It’s important as a developer to keep up to date with the ever-changing tech field. My old site missed two important features that I really wanted. continuous deployment and better code highlighting in markdown.</p><p>I saw netlify as an easy solution to the continuous deployment challenge. For context, here’s a snapshot of my previous syntax highlighting,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/0*ZjRjcinHOuN73T7a.png" /></figure><h3>Benefits of gridsome</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9gzyOxa8QnjS0Q0a.png" /></figure><p>As highlighted above, gridsome comes with a plethora of advantages. Building on the awesome vue framework, it manages to be simple to understand, their documentation is exceptional, to say the least, and I got to solve the two challenges I had mentioned.</p><p>To deploy to netlify, all you have to do is link your GitHub repo to netlify. From there, netlify will monitor for changes and update your site automatically. The <a href="https://gridsome.org/docs/deploy-to-netlify/">gridsome docs</a> offer more on this.</p><p>For code highlighting, I could now embed from various sources including gists and codepen. As a bonus, the new site has the capabilities to embed Spotify content for music lovers 🕺🏼.</p><h4>Extra features</h4><p>Some additional features that were implemented for the new site are</p><ol><li>The site is now a PWA! So awesome.</li><li>Improved SEO by utilizing Vue Meta.</li><li>Writing content in Markdown.</li></ol><h3>Challenges of gridsome</h3><p>The development process was fairly fun as their documentation was well written and thought out. However, I lacked some material which is not a bad thing in itself as it forces you to figure stuff on your own. I’m keen to write a comprehensive tutorial on using gridsome with the lessons I learned. In case you’re interested, subscribe to my newsletter and you’ll get the content as soon as it’s out.</p><h3>Was it worth the switch to gridsome</h3><p>Without a shadow of a doubt yes!! The site took me a little over a month. Working tirelessly on my off-work hours. But in the end, the effort was worth it. In the process, I’ve come to appreciate the modern web and extremely curious to explore graphql which gridsome utilizes.</p><h3>What next</h3><p>This won’t be the end as no project is ever complete, I’ll be making a few modifications and I’d appreciate any input to the design. In the coming days, I’ll make the entire codebase completely open-source for use to anyone who may want such a site.</p><p>In terms of content, be sure to <a href="https://mailchi.mp/c42286076bd8/lewiskori">watch out</a> as I’ll double down on more backend tutorials with python and golang.</p><p>Thanks for reading this post. Should you have any questions feel free to leave a comment below. My <a href="https://twitter.com/lewis_kihiu/">twitter dm</a> is always open as well.</p><h4>credits</h4><ol><li>The design was highly inspired by <a href="https://brittanychiang.com/">Brittany Chiang’s</a> Gatsby site.</li><li>The <a href="https://github.com/lewis-kori/gridsome-starter-blog">gridsome starter blog source code</a> gave me a lot of insight into where documentation lacked.</li></ol><p><em>Originally published at </em><a href="https://lewiskori.com/blog/building-my-new-site-with-gridsome-vue-js/"><em>https://lewiskori.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd1658e596f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create custom commands in django]]></title>
            <link>https://medium.com/analytics-vidhya/how-to-create-custom-commands-in-django-892899178a80?source=rss-bc9050c089c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/892899178a80</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Lewis Kori]]></dc:creator>
            <pubDate>Wed, 16 Sep 2020 20:27:10 GMT</pubDate>
            <atom:updated>2020-09-25T13:28:57.773Z</atom:updated>
            <content:encoded><![CDATA[<p>When developing django projects, there comes a need to write one-off scripts that automate a particular task. Here are some use cases I’ve found myself applying before we continue with the implementation.</p><ol><li>Cleaning up faulty data columns en masse.</li><li>Migrating multiple schemas in a <a href="https://lewiskori.com/series/intro-to-multi-tenant-apps-with-django/">multitenant application</a></li></ol><p>There are two ways we can go about running these types of commands in django. Write a normal python script which you can then call by running, and the other is by utilizing django-admin commands. These are run by calling python manage.py command_name.</p><p>For this post, I’ll demonstrate with a blog app having just 3 database tables, User, Category, and Post. I’ve assumed you are comfortable initializing a django project, but in case you aren’t, <a href="https://lewiskori.com/blog/building-web-ap-is-with-django/">this post</a> should help you out.</p><p>The source code for this post can be found <a href="https://github.com/lewis-kori/django-commands">here</a>.</p><h3>Normal python script method</h3><p>For the first example, we’ll try to list all system users with the script below</p><pre>from django.contrib.auth import get_user_model<br><br>User = get_user_model()<br><br># retrieve all users<br>users = User.objects.all()<br><br># loop through all users<br>for user in users:<br>    print(f&#39;user is {user.get_full_name()} and their username is {user.get_username()}&#39;)</pre><p>You can name the script list_users.py and run it by python list_users.py</p><p>Immediately you run this, you’ll be met with an error,</p><p>django.core.exceptions.ImproperlyConfigured: Requested setting AUTH_USER_MODEL, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.</p><p>One would have assumed that since you are in django’s project directory, the script would run with no problem. However, this is not the case. This is because the script is not aware of which project the script is to apply to. You could have multiple projects in a single machine or virtual environment. So it’s important to give the script some context.</p><p>We’ll do this by slightly modifying our script.</p><pre>import os<br><br>os.environ.setdefault(&#39;DJANGO_SETTINGS_MODULE&#39;, &#39;projectname.settings&#39;)<br><br>import django<br>django.setup()<br><br>from django.contrib.auth import get_user_model<br><br>User = get_user_model()<br><br>users = User.objects.all()<br><br>for user in users:<br>    print(f&#39;user is {user.get_full_name()} and their username is {user.get_username()}&#39;)</pre><p>Here, we specify the project’s settings and not only that, call django.setup() method. The method configures the settings, logging, and populates the app registry. In short, we are making the script aware of our project context.</p><p>In case you’re curious about the os module, my <a href="https://lewiskori.com/blog/how-to-clear-screen-in-python-terminal/">previous post</a> provides more insight.</p><p><strong>Note that the order of import is important and must remain like so.</strong></p><p>If we run the script again, all our users should be printed to the terminal 👯‍♂️.</p><p>Next up we’ll initialize an app called posts by running django-admin startapp posts.</p><p>The app will house our blog posts models.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62f6c5bc8dd16477f8ddf05d504df4ee/href">https://medium.com/media/62f6c5bc8dd16477f8ddf05d504df4ee/href</a></iframe><p>For this example, we’ll create an instance of a blog post from the command line. Initialize a script and name it create_post.py</p><pre>import os<br>os.environ.setdefault(&#39;DJANGO_SETTINGS_MODULE&#39;, &#39;commands.settings&#39;)<br><br>import django<br>django.setup()<br><br>from django.contrib.auth import get_user_model<br>from posts.models import Category, Post<br><br>User = get_user_model()<br><br>def select_category():<br>    # retrieve categories. (You can create some examples from the django admin)<br>    categories = Category.objects.all().order_by(&#39;created_at&#39;)<br>    print(&#39;Please select a category for your post: &#39;)<br>    for category in categories:<br>        print(f&#39;{category.id}: {category}&#39;)<br>    category_id = input()<br>    category = Category.objects.get(id=category_id)<br>    return category<br><br><br>def select_author():<br>    # retrieve all users<br>    users = User.objects.all()<br>    print(&#39;Please select an author for your post: &#39;)<br>    for user in users:<br>        print(f&#39;{user.id}: {user}&#39;)<br>    user_id = input()<br>    user = User.objects.get(id=user_id)<br>    return user<br><br><br><br>def create_post():<br>    title = input(&quot;Title of your post: &quot;)<br>    content = input(&quot;Long post content: &quot;)<br>    category = select_category()<br>    author = select_author()<br>    Post(**locals()).save()<br>    print(&#39;Post created successfully!&#39;)<br><br>if __name__ == &quot;__main__&quot;:<br>    create_post()</pre><p>Here, we are creating an instance of a blog post. Notice how we handle the ForeignKey relations? Ensure that you assign an object instance of the relevant DB table to that field.</p><p>By running python create_post.py, we are then prompted for some input.</p><h3>Writing custom django management commands method</h3><p>As aforementioned, django-admin commands are executed by running python manage.py command_name an example of these are runserver, migrate and collectstatic. To get a list of available commands run python manage.py help. This displays a list of the available commands as well as the django app folder in which they&#39;re housed.</p><p>To register a custom admin command, add a management\commands directory in your django app folder. In our case, it&#39;s going to be in posts\management\commands.</p><p>Once this is set up, we can then initialize our custom scripts in the commands folder. For the first example, we’ll write a command that flags the blog posts created before as published.</p><p>To do this create a file and name it publish_post.py</p><pre>from django.core.management.base import BaseCommand, CommandError<br>from posts.models import Category, Post<br><br>class Command(BaseCommand):<br>    help = &#39;Marks the specified blog post as published.&#39;<br><br>    # allows for command line args<br>    def add_arguments(self, parser):<br>        parser.add_argument(&#39;post_id&#39;, type=int)<br><br>    def handle(self, *args, **options):<br>        try:<br>            post = Post.objects.get(id=options[&#39;post_id&#39;])<br>        except Post.DoesNotExist:<br>            raise CommandError(f&#39;Post with id {options[&quot;post_id&quot;]} does not exist&#39;)<br>        if post.published:<br>            self.stdout.write(self.style.ERROR(f&#39;Post: {post.title} was already published&#39;))<br>        else:<br>            post.published = True<br>            post.save()<br>            self.stdout.write(self.style.SUCCESS(f&#39;Post: {post.title} successfully published&#39;))</pre><p>Django management command is composed of a class named Command which inherits from BaseCommand.</p><p>To handle arguments, the class utilizes <a href="https://docs.python.org/3/library/argparse.html">argparse</a>. The method add_arguments allows our function to receive arguments.</p><p>In our case, the function is expecting an argument that will be assigned the key post_id</p><p>The handle() function then evaluates the input and executes our logic.</p><p>In the example above, the kind of argument expected is called a positional argument and must be provided for the function to run. To do this, we run python manage.py publish_post 1 (or any post primary key)</p><p>Another type of argument called Optional argument can be applied to the methods, as the name implies, the lack of these will not hinder the function execution.</p><p>An example is provided below. We’ll initialize a file and name it edit_post.py. Populating it with the code below.</p><pre>from django.core.management.base import BaseCommand, CommandError<br>from posts.models import Category, Post<br><br>class Command(BaseCommand):<br>    help = &#39;Edits the specified blog post.&#39;<br><br>    def add_arguments(self, parser):<br>        parser.add_argument(&#39;post_id&#39;, type=int)<br><br>        # optional arguments<br>        parser.add_argument(&#39;-t&#39;, &#39;--title&#39;,type=str, help=&#39;Indicate new name of the blog post.&#39;)<br>        parser.add_argument(&#39;-c&#39;, &#39;--content&#39;,type=str, help=&#39;Indicate new blog post content.&#39;)<br><br>    def handle(self, *args, **options):<br>        title = options[&#39;title&#39;]<br>        content = options[&#39;content&#39;]<br>        try:<br>            post = Post.objects.get(id=options[&#39;post_id&#39;])<br>        except Post.DoesNotExist:<br>            raise CommandError(f&#39;Post with id {options[&quot;post_id&quot;]} does not exist&#39;)<br><br>        if title or content:<br>            if title:<br>                old_title = post.title<br>                post.title = title<br>                post.save()<br>                self.stdout.write(self.style.SUCCESS(f&#39;Post: {old_title} has been update with a new title, {post.title}&#39;))<br>            if content:<br>                post.content = content<br>                post.save()<br>                self.stdout.write(self.style.SUCCESS(&#39;Post: has been update with new text content.&#39;))<br>        else:<br>            self.stdout.write(self.style.NOTICE(&#39;Post content remains the same as no arguments were given.&#39;))</pre><p>Here we are just editing a blog post title or content. To do this we can run python manage.py edit_post 2 -t &quot;new title&quot; to edit just the title</p><p>or python manage.py edit_post -c &quot;new content&quot; to edit just the content. We can provide both arguments should we wish to edit both title and content by running python manage.py edit_post 2 -t &quot;new title again&quot; -c &quot;new content again&quot;</p><h3>Extra resources</h3><ol><li><a href="https://docs.djangoproject.com/en/3.1/howto/custom-management-commands/">Django docs</a>.</li><li><a href="https://simpleisbetterthancomplex.com/tutorial/2018/08/27/how-to-create-custom-django-management-commands.html#cron-job">Simple is better than complex</a>.</li></ol><h3>Sponsors</h3><p><strong>Please note that some of the links below are affiliate links and at no additional cost to you. Know that I only recommend products, tools and learning services I’ve personally used and believe are genuinely helpful. Most of all, I would never advocate for buying something you can’t afford or that you aren’t ready to implement.</strong></p><h3>Scraper API</h3><p>Scraper API is a startup specializing in strategies that’ll ease the worry of your IP address from being blocked while web scraping. They utilize IP rotation so you can avoid detection. Boasting over 20 million IP addresses and unlimited bandwidth.</p><p>In addition to this, they provide CAPTCHA handling for you as well as enabling a headless browser so that you’ll appear to be a real user and not get detected as a web scraper. Usage is not limited to scrapy but works with requests, BeautifulSoup, and selenium in the python ecosystem. Integration with other popular platforms such as node.js, bash, PHP, and ruby is also supported. All you have to do is concatenate your target URL with their API endpoint on the HTTP get request then proceed as you normally would on any web scraper. Don’t know how to web scrape? Don’t worry, I’ve covered that topic extensively on <a href="https://lewiskori.com/series/web-scraping-techniques-with-python/">the web scraping series</a>. All entirely free!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*dLmGIJymkhmsLbs8.gif" /></figure><p>Using <a href="https://www.scraperapi.com/?_go=korilewis">this scraper api link</a> and the promo code lewis10, you’ll get a 10% discount on your first purchase!! You can always start on their generous free plan and upgrade when the need arises.</p><p>That’s it from me, should you have any questions, <a href="https://twitter.com/lewis_kihiu">twitter dm</a> is always open.</p><p><em>Originally published at </em><a href="https://lewiskori.com/blog/how-to-create-custom-commands-in-django/"><em>https://lewiskori.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=892899178a80" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/how-to-create-custom-commands-in-django-892899178a80">How to create custom commands in django</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[web scraping: Managing proxies and Captcha with scrapy and the Scraper API]]></title>
            <link>https://lewiskori.medium.com/web-scraping-managing-proxies-and-captcha-with-scrapy-and-the-scraper-api-937c3ae11d9?source=rss-bc9050c089c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/937c3ae11d9</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[captcha]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Lewis Kori]]></dc:creator>
            <pubDate>Mon, 07 Oct 2019 12:11:49 GMT</pubDate>
            <atom:updated>2019-10-10T14:01:01.522Z</atom:updated>
            <content:encoded><![CDATA[<p>In the <a href="https://dev.to/lewiskori/introduction-to-web-scraping-with-python-24li">first</a> and <a href="https://dev.to/lewiskori/beginner-s-guide-to-web-scraping-with-python-s-selenium-3fl9">second</a> part of this series, we’ve introduced ourselves to web scraping and the techniques one can apply to achieve this task. We did so with BeautifulSoup and selenium python libraries. Check them out if you haven’t yet.</p><p>In this final part of the web scraping series, we’ll be exploring the scrapy library, the scraper API and gain an understanding of the need for using these tools.</p><p>For this walkthrough, we’ll scrape data from the <a href="https://www.themoviedb.org/movie">moviedb</a> website. This is just an example as they provide an API if you want any of their data. Find the code on <a href="https://github.com/lewis-kori/movies_scraper">github</a>.</p><h3>Why scrapy?</h3><p>Scrapy is an open-source python library. <br> Scrapy lets you crawl websites concurrently without having to deal with threads, processes, synchronization or anything else. It handles your requests asynchronously and it is really fast. If you wanted something like this in your custom crawler, you’d have to implement it by yourself or use some async library.</p><p>For more details on this topic, check this <a href="https://www.quora.com/Why-would-some-use-scrapy-instead-of-just-crawling-with-requests-or-urllib2/answer/Valdir-Stumm-Junior?ch=10&amp;share=6de6f35c&amp;srid=5lfYx">post</a>.</p><h3>Why Scraper API?</h3><p><em>Please note that some of the links below are affiliate links and at no additional cost to you. Know that I only recommend products, tools and learning services I’ve personally used and believe are genuinely helpful. Most of all, I would never advocate for buying something you can’t afford or that you aren’t ready to implement.</em></p><p>Scraper API is a startup specializing in strategies that’ll ease the worry of your IP address from being blocked while web scraping. They utilize IP rotation so you can avoid detection. Boasting over 20 million IP addresses and unlimited bandwidth.<br> In addition to this, they provide CAPTCHA handling for you as well as enabling a headless browser so that you’ll appear to be a real user and not get detected as a web scraper.<br> Usage is not limited to scrapy but works with requests, BeautifulSoup and selenium in the python ecosystem. Integration with other popular platforms such as node.js, bash, PHP and ruby is also supported. All you have to do is concatenate your target URL with their API endpoint on the HTTP get request then proceed as you normally would on any web scraper. In this walkthrough, I’ll highlight just how to do that😁.</p><p>Using this <a href="https://www.scraperapi.com/?fpr=lewiskori">link</a> and the promo code SCRAPE201818, you’ll get a 10% discount on your first purchase!!<br> You can always start on their generous free plan and upgrade when the need arises.</p><h3>1. Setting up.</h3><p>To get started, we need to install the scrapy library. Run</p><p>Afterwards, head over to the <a href="https://www.scraperapi.com/?fpr=lewiskori">scraper API website</a> and get an API key. We’ll need this to access their services in a very simple way. So hold on tight.</p><h4>initiating the project</h4><p>With these two steps done, we should be all set up to make the web crawler.<br> Run pip install scrapy</p><p>This will create our project that’ll initialize with the following structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/0*03CRZOr_t4DySNtx.PNG" /></figure><p>Now for the fun part.<br> we’ll create a file in the spider’s folder and aptly name it movies.py.<br> This will house most of the code needed to power our web crawler.</p><p>Our entire code will appear like so.</p><pre>from scrapy import Spider<br>from ..items import GetmoviesItem<br>from .config import API_KEY<br><br>class moviesCrawl(Spider):<br>    name=&quot;movies&quot;<br>    page_number=15<br><br>    url_link=&quot;https://www.themoviedb.org/movie?page=1&quot;<br><br>    start_urls=[&#39;http://api.scraperapi.com/?api_key=&#39;+ API_KEY + &#39;&amp;url=&#39; + url_link + &#39;&amp;render=true&#39;]<br><br>    def parse(self,response):<br>        movies=response.css(&quot;div.item.poster.card&quot;)<br>        items=GetmoviesItem()<br>        for movie in movies:<br>            items[&quot;title&quot;]=movie.css(&#39;.title.result::text&#39;).extract()<br>            items[&quot;rating&quot;]=movie.css(&quot;.user_score_chart::attr(data-percent)&quot;).extract()<br>            items[&quot;description&quot;]=movie.css(&quot;.overview::text&quot;).extract()<br>            items[&quot;poster_link&quot;]=movie.css(&#39;.poster.lazyload.fade::attr(data-src)&#39;).extract()<br><br>            yield items<br><br><br>        next_page_url = &quot;https://www.themoviedb.org/movie?page=&quot;+ str(self.page_number)<br>        next_page=&#39;http://api.scraperapi.com/?api_key=&#39;+ API_KEY + &#39;&amp;url=&#39;+ next_page_url + &#39;&amp;render=true&#39;<br><br>        if self.page_number&lt;=15:<br>            self.page_number+=1<br>            yield response.follow(next_page,callback=self.parse)</pre><p>Might look a bit frightening, but we’ll go through it line by line.</p><pre>from scrapy import  Spider<br>from ..items import GetmoviesItem<br>from .config import API_KEY</pre><p>The first three lines are library imports and items we’ll need to effectively create a functioning web crawler.</p><p>For now, don’t worry about the GetmoviesItem import, we’ll get to that soon.<br> I created a separate file where I stored any configurations needed. In this case, it was the API key we got from scraper API.</p><pre>class moviesCrawl(Spider):<br>    name=&quot;movies&quot;<br><br>    url_link=&quot;https://www.themoviedb.org/movie?page=1&quot;<br>    page_number=15<br><br>    start_urls=[&#39;http://api.scraperapi.com/?api_key=&#39;+ API_KEY + &#39;&amp;url=&#39; + url_link + &#39;&amp;render=true&#39;]</pre><p>This is where things start getting interesting. We first create the moviesCrawl class which inherits from the spider class initially imported at the top of the file. This class will form the basis for our web scraper and we’ll specify the behaviour of the web crawler from here.</p><p>We first have to give it a name and this is done in the names variable. This name will be used when we want to run the scraper once we are through creating it.</p><p>As for the url_link variable, this is just to point to the URL we want to scrape. You’ll notice that it’s a paginated site and it takes the form</p><p><a href="https://www.themoviedb.org/movie?page={{page_number}}">https://www.themoviedb.org/movie?page={{page_number}}</a></p><p>This pattern will be utilised by the page_number variable to automatically move the scraper across multiple pages within the target site.</p><p>Finally, the start_urls variable is a keyword in scrapy. This a list of URLs where the spider will begin to crawl from when no particular URLs are specified. So, the first pages downloaded will be those listed here.</p><p>To enable us to use the scraper API and utilise its full power 😎, all we simply have to do is concatenate our url_link with the scraper API endpoint.</p><p>http://api.scraperapi.com/?api_key=&#39;+ API_KEY + &#39;&amp;url=&#39; + url_link + &#39;&amp;render=true</p><p>The render=true option simply tells the scraper API to enable javascript rendering and hence allowing a headless browser to run. This is what we covered using <a href="https://dev.to/lewiskori/beginner-s-guide-to-web-scraping-with-python-s-selenium-3fl9">selenium</a> but in a simplified format.</p><pre>def parse(self,response):<br>        movies=response.css(&quot;div.item.poster.card&quot;)<br>        items=GetmoviesItem()<br>        for movie in movies:<br>            items[&quot;title&quot;]=movie.css(&#39;.title.result::text&#39;).extract()<br>            items[&quot;rating&quot;]=movie.css(&quot;.user_score_chart::attr(data-percent)&quot;).extract()<br>            items[&quot;description&quot;]=movie.css(&quot;.overview::text&quot;).extract()<br>            items[&quot;poster_link&quot;]=movie.css(&#39;.poster.lazyload.fade::attr(data-src)&#39;).extract()<br><br>            yield items</pre><p>From scrapy’s documentation,</p><blockquote><em>The parse method is in charge of processing the response and returning scraped data and/or more URLs to follow.</em></blockquote><p>What this means in simple terms, is that using this method, we can manipulate the data received from the target web site we want to scrape. From our last two walkthroughs, we defined web scraping as</p><p><em>The process of extracting information from a webpage by taking advantage of patterns in the web page’s underlying code.<br> We can use web scraping to gather unstructured data from the internet, process it and store it in a structured format.</em></p><p>once we’ve identified the patterns in the web page’s code, we can automate the data extraction. So let’s inspect those DOM elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*OSVlzrYgU7Qbtjmb.PNG" /></figure><p>From the image above, we’ll notice that each movie item is enclosed in a div of classes item, poster and card.<br> Armed with this information, we’ll instruct the crawler to get all CSS elements exhibiting those attributes.</p><p>Before we continue, let’s deal with the GetmoviesItem class we imported at the beginning of the script.</p><pre>from scrapy import Item<br>class GetmoviesItem(scrapy.Item):<br>    # define the fields for your item here like:<br>    title=scrapy.Field()<br>    rating=scrapy.Field()<br>    description=scrapy.Field()<br>    poster_link=scrapy.Field()</pre><p>Once we’ve crawled the site data, we need to store the data somewhere in a structured format. These items objects are simple containers used to collect the scraped data. They provide a dictionary-like API with a convenient syntax for declaring their available fields. <br> For more info on this check <a href="https://doc.scrapy.org/en/latest/topics/items.html#module-scrapy.item">here</a>.</p><p>From the code above, what we’ve defined will act like dictionary keys storing the information we’ve extracted.</p><p>Are we still flowing? Great. Onwards we move.</p><p>The items variable will be an instance of the GetmoviesItem. From here, using the same field names defined as our dictionary keys, we can extract and individual attributes from each movie. Case in point, for the rating information. This attribute is stored within an element with a class name user_score_chart. Within this HTML element, we have an attribute “data-percent” and that’s why we utilised the attr method to get access to the data stored there. From there using the yield function, we can now get all the data we need.</p><p>For the final part of the code,</p><pre>next_page_url = &quot;https://www.themoviedb.org/movie?page=&quot;+ str(self.page_number)<br>        next_page=&#39;http://api.scraperapi.com/?api_key=&#39;+ API_KEY + &#39;&amp;url=&#39;+ next_page_url + &#39;&amp;render=true&#39;<br><br>        if self.page_number&lt;=15:<br>            self.page_number+=1<br>            yield response.follow(next_page,callback=self.parse)</pre><p>we take advantage of the pagination URL to iterate over as many pages as we want. Luckily for us, since we’ll be hooking up with the scraper API’s endpoint, we run no risk of our IP address being blocked since they have managed proxies for us. <br> However, I’d caution against sending excessive requests to a target site while web scraping as it can ruin other people’s user experience on the platform.</p><p>Finally, to store the information is a simple as running any of these commands based on the file format you choose.</p><p>scrapy crawl movies -o filename.csv</p><p>scrapy crawl movies -o filename.json</p><p>scrapy crawl movies -o filename.xml</p><h3>Feature evaluation</h3><h4>proxy feature</h4><p>I tested out this feature using <a href="https://httpbin.org/ip">httpbin</a> and on multiple requests, the IP rotations worked superbly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/0*nRNpGK22IqaOdayJ.PNG" /></figure><p>It’s important to note that the time of requests will slow down during IP rotation and consequently, your web scraper will run slower than usual.</p><h4>captcha</h4><p>To test out this feature identify a website with captcha enabled and run the script. A great place to start is <a href="https://www.truepeoplesearch.com/">truepeoplesearch</a> which immediately pops up a captcha form. You’ll find that the scraper API can easily handle this for you allowing you to scrape just as normally as you would.</p><h4>Headless browser</h4><p>By removing the render=true, run the script on a javascript heavy site and notice the differences.<br> A great place to start is the <a href="http://quotes.toscrape.com/js">quotes to scrape js powered site</a>.</p><h3>conclusion</h3><p>Hopefully, you too can make a simple web crawler with scrapy and utilise the scraper API.</p><p>For more on this head over to their <a href="https://www.scraperapi.com/documentation">documentation</a> page to see the awesome features, they provide to ease some of the headaches you encounter on web scraping.</p><p><a href="http://scrapy.org/">scrapy documentation</a>.</p><p>Thanks for your time.<br> If you want more of this, subscribe to my <a href="https://lewiskori.com/posts/">newsletter</a> to get notified whenever I make new posts. Want to chat? Ping me on <a href="https://twitter.com/lewis_kihiu">twitter</a>.</p><p><em>Originally published at </em><a href="https://dev.to/lewiskori/web-scraping-managing-proxies-and-captcha-with-scrapy-and-the-scraper-api-2c5b"><em>https://dev.to</em></a><em> on October 7, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=937c3ae11d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lessons learnt from building and deploying a portfolio website]]></title>
            <link>https://lewiskori.medium.com/lessons-learnt-from-building-and-deploying-a-portfolio-website-f29eae6c87c?source=rss-bc9050c089c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f29eae6c87c</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[career-advice]]></category>
            <dc:creator><![CDATA[Lewis Kori]]></dc:creator>
            <pubDate>Tue, 10 Sep 2019 09:23:32 GMT</pubDate>
            <atom:updated>2019-09-11T07:43:41.757Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vWwEk6js9kHfi988aP--6g.jpeg" /></figure><blockquote><em>“Experience is the best teacher.”</em></blockquote><p>I started making my portfolio site as a means of getting out of tutorial purgatory that had plagued me for a long time. True to the statement above and as it has been widely preached, getting your hands dirty by building a real-world project is a sure way to get your foot in the door in software development. <br> I chose my starter project as a portfolio site and the experience left a tremendous impact on me. Here are just a few of the insights gained.</p><h3>Discovering my passion.</h3><p>When I started making the site, the initial goal was to display some of the data science projects I had done. At the time I was really into data science and analytics as it had been lauded as</p><blockquote><em>“The sexiest career of the 21st century”</em></blockquote><p>However, as I was making the web app( I chose Django to begin with), I started questioning myself as to whether I enjoyed data science as much as I thought or was it the hype surrounding the field that pushed me in that direction. Did I envision myself doing it for the rest of my life?</p><p>The more and more I made the backend for my web app, the more I noticed that I was actually excited and enjoyed software engineering as opposed to my previous passion. Needless to say, I am still an enthusiast of data analytics and I’m sure the knowledge gained from all the practise won’t go to waste. However, we all have different paths to success.</p><p>Without experimenting with different domains, I wouldn’t have found my home. Probably things might change in future and that’s the beauty of knowledge. You never stop learning.</p><h3>Focusing on my strengths.</h3><p><em>“How will I juggle all these technologies?”</em></p><p>This is a question I asked myself a lot while starting my computer science degree. With the constant inflow of information, it became very confusing to choose what to pick up and what to drop. Mixed with the fear that leaving one tech stack would make me not good enough for the job market, contributed to being one hot mess. <br> Soon though, someone just told me to pick up one thing and just go with it. So I chose the Python programming language and made the site with Django. Was I perfect in HTML? No. So I chose to ask a friend to help with the front end as I concentrate on the backend. Needless to say, with time, I picked up those skills I didn’t have and I realised that all good things take time. Focus on one thing at a time.</p><h3>Opportunity for growth.</h3><p>So here I am with the finished project’s file on my computer. Feeling proud of my small win. Then I started thinking. “What next?” <br> The next phase was obviously deployment. So this brings a whole new world you didn’t know existed. With this I look into web servers, how to choose hosting providers, differentiating Nginx and apache 😂. It was all very hectic at first, but again, I remembered, all good things take time.<br> <a href="https://lewiskori.com/post/deploying-a-python-django-application-using-docker">This tutorial </a>I did early this year should help you when you get to this stage.</p><p>For anyone starting their journey into programming, remember to enjoy the process of continuous learning and learn one thing at a time. Eventually, you’ll become like that guru you admire. I for starters, I’m not yet there, but again, good things take time.</p><p>What’s one project you feel made you get an interest in software engineering?<br> Drop your experience in the comments section below.</p><p>If you enjoyed this post, subscribe to my <a href="https://lewiskori.com/posts/">newsletter</a> or get in touch on <a href="https://twitter.com/lewis_kihiu">twitter</a> for a chat any time.</p><p><em>Originally published at </em><a href="https://dev.to/lewiskori/lessons-learnt-from-building-and-deploying-a-portfolio-website-563g"><em>https://dev.to</em></a><em> on September 10, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f29eae6c87c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a django application using docker.]]></title>
            <link>https://lewiskori.medium.com/deploying-a-django-application-using-docker-197356eb9346?source=rss-bc9050c089c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/197356eb9346</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Lewis Kori]]></dc:creator>
            <pubDate>Wed, 07 Aug 2019 10:18:52 GMT</pubDate>
            <atom:updated>2019-08-07T10:24:07.219Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*j4x59_5WGi7yHyjE8j0rtw.jpeg" /></figure><p>Hey there I was inspired to write this post based on my experience trying to move my deployments to use docker, particularly for django applications and couldn’t get a comprehensive place/article that covered what I needed.Hopefully this article will help anyone out there who is feeling as stuck as I was.</p><p>A lot of you might have already heard this phrase being thrown around almost everywhere you turn. You probably googled the term docker up and even tried experimenting with it but might have given up along the way. Heck, to be honest I did hold up on it one or two times before taking a full dive. It can be a little intimidating at first, but oh boy! Once you start using docker, there’s no going back. The ease of moving from production to development environment is simply mind blowing to say the least!!<br>so enough rumbling, let’s get started.</p><h3>what is docker?</h3><p>Docker is an open-source tool that automates the deployment of an application inside a software container. which are like virtual machines, only more portable, more resource-friendly, and more dependent on the host operating system. <br>for detailed information on the workings of docker, I’d recommend reading <a href="https://dev.to/djangostars/what-is-docker-and-how-to-use-it-with-python-tutorial-87a">this article</a> and for those not comfortable reading long posts, this <a href="https://www.youtube.com/playlist?list=PLhW3qG5bs-L99pQsZ74f-LC-tOEsBp2rK">tutorial series on youtube</a> was especially useful in introducing me to the concepts of docker.</p><h3>Installing docker.</h3><p>In case you don’t have docker installed on your machine follow the detailed steps below as per your operating system.</p><p>Going forwards, I’ve assumed you already had an existing django application, so this tutorial will just be a guide on how to containerize it.</p><p>1.<a href="https://docs.docker.com/docker-for-windows/install/">windows 10 pro</a><br>2.<a href="https://docs.docker.com/toolbox/toolbox_install_windows/">windows 10 that’s not pro</a><br>3.<a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04">ubuntu</a></p><h3>Getting started</h3><p>For deploying a typical django application you would need the following services in order to get it running.</p><ol><li>1.Nginx — to serve static files and webserver.</li><li>2.Postgres/any database of your choice.</li><li>3.python with gunicorn installed.</li></ol><p>To launch each of these services, you’ll need a dockerfile. This is basically a text document highlighting all the commands on the cli and steps you would normally take to assemble an image.</p><h3>1.Python image</h3><pre>FROM python:3.6<br><br>RUN mkdir /code<br>WORKDIR /code<br><br>COPY requirements.txt ./<br>RUN pip install --no-cache-dir -r requirements.txt<br><br><br>COPY . .</pre><ol><li>The first line has to start with the <strong>FROM</strong> keyword. It tells docker, from which base image you want to base your image from. In this case, we are creating an image from the python 3.6 image.</li></ol><p>2. The second line is the command <strong>RUN</strong> is used to run instructions on the image, in this case we are creating a directory by the name <strong><em>code.</em></strong>After this the <strong><em>WORKDIR</em></strong> sets the code directory as the working directory so that any further instructions on the dockerfile occur within this directory.</p><p><strong><em>3. </em></strong><strong><em>COPY</em></strong> command copies specific files from the host machine to the image we are creating. The requirements.txt file will be copied into the working directory set previously. After this RUN the pip install command to install the python packages needed for your project.</p><p>4. Finally COPY your current working directory’s project files from the host machine onto the docker image.</p><p>In order to build this image run the simple command</p><pre>docker build .</pre><p>on the current dockerfile location directory.<br>For our use case we’ll be having multiple images and running this command for every image will be tiresome. Hence the need for docker-compose, More on that as we finalize.</p><h3>2. Nginx image</h3><pre>FROM nginx<br><br>RUN rm /etc/nginx/conf.d/default.conf<br>COPY mysite.conf /etc/nginx/conf.d</pre><p>The commands are the same as for python only specific to nginx<br>in this case we use the nginx base image, delete the default configuration file that ships with nginx and replace it with our custom config file.<br>which might look something like this.</p><pre>upstream my_site {<br>    server web:8080;<br>}<br><br>server {<br><br><br>    listen 80;<br>    charset utf-8;<br>    server_name  127.0.0.1;<br><br><br>    client_max_body_size 4G;<br>    access_log /code/logs/nginx-access.log;<br>    error_log /code/logs/nginx-error.log;<br><br><br>    location / {<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header Host $host;<br>        proxy_redirect off;<br>        if (!-f $request_filename) {<br>            proxy_pass http://my_site;<br>            break;<br>        }<br>    }<br><br>    location /static/ {<br>        autoindex on;<br>        alias /code/static_cdn/;<br>    }<br><br>    location /media/ {<br>        autoindex on;<br>        alias /code/media_cdn/;<br>    }<br><br>}</pre><p>the file locations will of course be relative to your own configurations.</p><h3>3. postgres</h3><p>Lastly we get to the database, in this use case, I used postgres.</p><pre>FROM postgres:latest<br><br>COPY ./init/01-db_setup.sh /docker-entrypoint-initdb.d/01-db-setup.sh</pre><p>Now you’re thinking</p><blockquote><strong><em>“But Lewis, what’s this init file?”</em></strong></blockquote><p>for context let’s take a look at the postgres directory within our project.</p><pre>postgres<br>├── postgres/Dockerfile<br>└── postgres/init<br>└── postgres/init/01-db_setup.sh</pre><p>This is a shell script(docker entry point) specifying what commands to run on the database container, things like creating the database, users and granting privileges to the said user.</p><pre>#!/bin/sh<br><br>psql -U postgres -c &quot;CREATE USER $POSTGRES_USER PASSWORD &#39;$POSTGRES_PASSWORD&#39;&quot;<br>psql -U postgres -c &quot;CREATE DATABASE $POSTGRES_DB OWNER $POSTGRES_USER&quot;<br>psql -U postgres -c &quot;GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER&quot;</pre><p>Note: When you create this file, don’t forget to make it executable by running</p><pre>sudo chmod u+x filename.sh</pre><h3>4. wrapping things up with docker-compose</h3><p>At this point, you’ve probably noticed that we have a lot of dockerfiles,<br>with docker-compose, we can conveniently build all this images using <br>the command</p><pre>docker-compose build .</pre><p>First off, we’ll need to create a docker-compose.yml file within our project directory. we’ll specify the services needed for our webapp to run within this file.</p><pre>version: &#39;3&#39;<br>services: <br><br>  web:<br><br>      build: .<br>      container_name: great<br>      volumes: <br>      - .:/code<br>      - static:/code/static_cdn<br>      - media:/code/media_cdn<br>      depends_on: <br>          - postgres<br>      expose: <br>        - 8080<br>      command: bash -c &quot;python manage.py collectstatic --no-input &amp;&amp; python manage.py makemigrations &amp;&amp; python manage.py migrate &amp;&amp; gunicorn --workers=3 projectname.wsgi -b 0.0.0.0:8080&quot;<br><br>  postgres:<br>      build: ./postgres<br>      restart: unless-stopped<br>      expose:<br>        - &quot;5432&quot;<br>      environment:   # will be used by the init script<br>            LC_ALL: C.UTF-8<br>            POSTGRES_USER: myuser<br>            POSTGRES_PASSWORD: mypassowrd.<br>            POSTGRES_DB: mydb<br>      volumes:<br>          - pgdata:/var/lib/postgresql/data/  <br><br>  nginx:<br>      restart: always<br>      build: ./nginx/<br>      volumes: <br>        - ./nginx/:/etc/nginx/conf.d<br>        - ./logs/:/code/logs<br>        - static:/code/static_cdn<br>        - media:/code/media_cdn<br>      ports: <br>        - &quot;1221:80&quot;<br>      links:<br>        - web  <br>volumes: <br>  pgdata:<br>  media:<br>  static:</pre><p>Going through this commands line by line:</p><ol><li>version — specifies the syntax version of docker-compose we’ll be using</li><li>services — from this point, we’ll highlight the different services we’ll be launching. As specified above, these will be nginx,python and postgres, and name them as we want. In my case i’ve named them nginx, web and postgres.</li><li>build — remember all those dockerfiles we spent time writing? Good.using the build command you can specify the location of each individual dockerfile and based on the commands on these files, an image will be build.</li><li>container_name — this gives the container the name you specified once, the containers are up and running.</li><li>Volumes — this is a way of sharing data between the docker-containers and the host machine. They also allow persistence of data even after the docker-containers are destroyed and recreated again as this is something you’ll find yourself doing often.for more on volumes and how to use them check out <a href="https://stephenafamo.com/blog/docker-volumes-introduction/">this article.</a></li><li>ports — this is to specify which ports from the docker containers are mapped to the host machine, taking the nginx service for example, the container’s port 80 is mapped to the host machine’s port 1221.</li><li>expose — Exposing a port makes the port accessible to linked services, but not from the host machine.</li><li>restart — specifies the behavior of the containers in case of unforeseen shutdown</li><li>command — instructs the containers which commands to run before starting, in this case the chained commands in the web service are for checking for changes in the database and binding the web service to the port 8080.</li></ol><h3>5. final steps</h3><p>To build the images, it’s now a matter of simply running</p><pre>docker-compose build</pre><p>This might take a few minutes to build as the base images are downloading in case you didn’t have them locally,</p><p>To start the various service containers, simply run</p><pre>docker-compose up</pre><p>or if you want to specify which compose file to run in case of multiple docker-compose files within one directory</p><p>docker-compose -f filename.yml up</p><p><strong><em>DISCLAIMER</em></strong>: Don’t forget to set the Debug = False and allowed hosts, in the settings.py file of django to reflect the domain name or ip-address you’ll be using.<br>In addition to this, change the database from the default sqlite3 that comes with django to reflect the database and usernames we specified<br>in the environment section of the postgres service like so</p><pre>DATABASES = {<br>&#39;default&#39;: {<br>&#39;ENGINE&#39;: &#39;django.db.backends.postgresql_psycopg2&#39;,<br>&#39;NAME&#39;: &#39;mydb&#39;,<br>&#39;USER&#39;: &#39;myuser&#39;,<br>&#39;PASSWORD&#39;: &#39;mypassword&#39;,<br>&#39;HOST&#39;: &#39;postgres&#39;,<br>&#39;PORT&#39;: 5432,<br>}<br>}</pre><p>That’s it.</p><p>To view the running site, run</p><pre>localhost:1221</pre><pre>virtual-box-machine-ip:1221(for those using docker-toolbox)</pre><p>in case you want to stop the containers</p><p>docker-compose stop</p><p>to start the stopped containers</p><p>docker-compose start</p><p>to destroy the containers</p><p>docker-compose down</p><p>you made changes to the docker-files and need those changes applied</p><p>docker-compose down &amp;&amp; docker-compose build &amp;&amp; docker-compose up</p><p>Now to get the site up and running on the web, simply create a configuration file for your local machines nginx(or apache) on the web server and simply point it to the docker-container running your django app. In this case you’ll point it to the nginx container.<br>127.0.0.1:1221</p><p>To get a list of common commands you’ll need for docker, read this <a href="https://dev.to/aduranil/10-docker-compose-and-docker-commands-that-are-useful-for-active-development-22f9">concise post</a></p><p>for laravel developers <br><a href="https://balysnotes.com/single_post/Brian_Baliach/051032437815811656">here’s something</a> to get you started with docker</p><p>Thank you very much for your time and I hope this article was useful. If you want more of this , feel free to <a href="https://lewiskori.com/contact-me/">contact me</a>.</p><p>Don’t forget to Like, share and <a href="https://lewiskori.com/">subscribe</a>. If you simply have more to add,drop a comment below.</p><p>thanks.</p><p>Originally published on<a href="https://lewiskori.com/post/deploying-a-python-django-application-using-docker"> my site</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=197356eb9346" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Continuous improvement/continuous growth as a developer]]></title>
            <link>https://lewiskori.medium.com/continuous-improvement-continuous-growth-as-a-developer-c654fdd446d7?source=rss-bc9050c089c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c654fdd446d7</guid>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Lewis Kori]]></dc:creator>
            <pubDate>Sun, 14 Jul 2019 17:25:40 GMT</pubDate>
            <atom:updated>2019-07-14T17:25:40.316Z</atom:updated>
            <content:encoded><![CDATA[<p>the story was originally posted on my <a href="https://lewiskori.com/post/continuous-improvementcontinuous-growth-as-a-developer"><strong><em>personal website</em></strong></a>.</p><p>This post has been a long time coming and it’s very ironic I made a decision to writing more <a href="https://medium.com/@lewiskosh/staying-true-to-yourself-in-2019-9259d09bba8"><strong><em>this year</em></strong></a>, but oh well, better late than never they say.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*zfV-sQWB2y25y4iAhSercQ.jpeg" /></figure><p>I started programming well over two years ago. It all began as a casual look at some C language tutorial one afternoon. At the time it all seemed so foreign to me and to be honest kinda challenging. Nonetheless I continued putting in the hours whenever i had free time and eventually managed to build a couple of projects along the various tutorials. The journey hasn’t been easy as some of you programmers reading this post can attest. Along the way I’ve picked up many lessons(some learned the hard way), but all eventually building me to not only be a good software engineer, but also a better human being. This are some of the precious nuggets picked up along the journey.</p><h4>1. GETTING STARTED</h4><figure><img alt="do it" src="https://cdn-images-1.medium.com/max/732/1*jAr6SO6fu13aV0_jypIqHA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@socialcut?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">S O C I A L . C U T</a> on <a href="https://unsplash.com/search/photos/starting-something-motivation?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>The number one question that new programmers ask themselves is</p><blockquote>“which programming language do I start with? My God they’re so many!”</blockquote><p>The thought can be scary and overwhelming as you are bombarded with so many options. Some from friends who will tell you do this and then you get online and meet a vast array of articles telling you to do a completely different thing. while not an expert on advice myself, the best approach to navigate this issue for me was evaluating my priorities and what I intended to do/build with the skills I would gain. After identifying my wants it became relatively easy to choose which technologies to learn,attained those skills and all those people bashing on you to learn this or that becomes white noise.</p><p>you can get a list of the popular languages and their best use case <a href="https://medium.com/@CarolPelu/5-popular-programming-languages-and-their-uses-22af241de35b"><strong><em>here</em></strong></a><em> and </em><a href="https://dev.to/drminnaar/choosing-a-programming-language-493h"><strong><em>here</em></strong></a><em>.</em></p><p>You’ll find that starting out is often the most difficult part, but with enough persistence and grit, everything will almost be like muscle memory(read copy paste google and stackoverflow answers)</p><h4>2. Learn incrementally</h4><p>Ok now you are through with your first tutorial/online course and you see all your friends doing this amazing things. This is when the imposter syndrome really sets in. The feeling of inadequacy is a real issue and is something I really struggled with for a long time. Every time you feel like you are at the tail end of the pack and you are not good enough to be in this industry. So what do you do, you overwork yourself and eventually burn out.It took me a long time to get out of this zone and I decided to take a more laid back approach to how I learn new things. The goal now was to learn something in each and every project that I undertook, no matter how small it was, it would eventually lead to something big, and surprise surprise, within no time all those little things added up to a lot of knowledge and personal growth. hopefully this technique will reach all of you out there struggling with the same.</p><p>Asking for help when you don’t know something also goes a long way and saves you countless hours to often times, small issues that could have been solved by someone more experienced than you are. Here’s a great place to ask around if you ever feel <a href="https://stackoverflow.com/"><strong><em>stuck</em></strong></a><em>.</em></p><blockquote><em>“Look, I know you’re very proud man, but you need to let other people help you if you’re in trouble. No man is an island.”</em></blockquote><h4>3. Attending meetups</h4><blockquote>A person requires the company and support of others and society as a whole in order to thrive.</blockquote><p>It’s human nature to want to interact with others and naturally, we coalesce around those who are most similar to us. Nothing exemplifies this than attending tech meetups whenever you get the chance.</p><p>The benefits include but are not limited to😁:</p><ol><li>Getting the latest industry trends.</li><li>Securing good opportunities either professionally or personally.</li><li>A great way to meet new people and expand your networks.</li><li>It’s an opportunity to spend some time in the real world, away from your laptop.</li><li>By sharing what you are struggling with you may well find some helpful advice.</li></ol><p>A great place to start and identify local meetup groups and communities is this <a href="https://www.meetup.com/"><strong><em>gem</em></strong></a> which is not really focused on tech meetups but all sorts of communities ranging from art and fitness enthusiasts,cooking clubs to book clubs. Give it a look if you haven’t heard of it yet.</p><h4>4. Take breaks</h4><p>Taking a break gives you a chance to step back from the inner workings of the issue, letting you re-examine it from a fresh perspective. It can also allow your subconscious a chance to work on the problem — which can result in leaps to new ideas, rather than a continued plod down an existing path.</p><p>Taking breaks also goes a long way in reducing burn out and I’ve found personally, a run or workout has helped in maintaining some balance.</p><p>So have any points to add? drop them in the comment section below to help others reading this, and if you enjoyed this post don’t forget to share and subscribe.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c654fdd446d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[staying true to yourself in 2019]]></title>
            <link>https://lewiskori.medium.com/staying-true-to-yourself-in-2019-9259d09bba8?source=rss-bc9050c089c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9259d09bba8</guid>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[friendship]]></category>
            <category><![CDATA[relationships]]></category>
            <category><![CDATA[self-awareness]]></category>
            <category><![CDATA[love]]></category>
            <dc:creator><![CDATA[Lewis Kori]]></dc:creator>
            <pubDate>Sun, 30 Dec 2018 16:14:34 GMT</pubDate>
            <atom:updated>2018-12-30T16:14:34.243Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oUvNq0jyWwaQusWZVaoEuw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/FtZL0r4DZYk?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">MI PHAM</a> on <a href="https://unsplash.com/@phammi?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I recently put down the book <strong><em>A man of the people</em> </strong>by the great Chinua Achebe, and one of the characters that stood out for me was one Max Kulamo. A vibrant young lawyer in the fictional city of Biro. For context, the events of the book happen in post independent Africa where their country, seven years after independence from British colonial rule, is suffering from run away corruption and the government is haemorrhaging cash faster than anyone can understand. The masses, blindly led to believe that everything is OK, follow their leaders’ word like a fish takes to water.</p><p>It’s in the backdrop of this that Max decides to start a revolutionary new party seeking to challenge the seemingly irredeemable corrupt politicians. He rides on the promise of hope,change and youthful valor. It therefore comes as a surprise when he willingly takes a bribe of a 1000 euros from one of the government officials to abdicate his candidature to the country’s parliament on his behalf. Is this the change that was promised?</p><p>Not only does he betray the dream they were fighting so hard to give their people,but he also goes back on his word and still vies for the political seat he promised to relinquish. A mistake that comes to haunt him.Max, unfortunately,bit off far more than he could chew.In the end, he gets murdered in cold blood by the very politician he had made a pact with. A victim of his own doing.</p><p>The world is littered with many Max(es). Sticking true to your values is as hard as it gets. It requires a certain degree of willpower and therefore one can’t blame themselves for wanting to indulge a little by bending the rules. Then you find yourself subscribing to different values altogether down the line 😣.It’s important to remember.</p><blockquote><em>“If you set out to be liked, you would be prepared to compromise on anything, at any time, and you would achieve nothing.”-Bruce Lee</em></blockquote><p>Here a few pointers to help you stick to the straight and narrow path.</p><h4><strong>1. surround yourself with honest friends</strong></h4><blockquote>“Show me your friends and I’ll show you your future”-Dan Pena</blockquote><p>This rings true every time. You are a reflection of people you surround yourself with. Surrounding yourself with honest people who are willing to stick the hard truth to you is very essential.Try and get rid of toxic people who may lead you to deviate your values.It may be hard to cut off these ties, but if you believe it’s what is right for you, then don’t be afraid to let go.</p><h4>2<strong>. don’t hide your character or preferences</strong></h4><p>Ever heard of imposter syndrome? This is the fear that the world is going to find us out. One of our greatest fears is that if we show our true selves, the world will say, “Oh, it’s just you.” But being just you is actually the best and most perfect thing you could ever be.</p><blockquote>“Be just you, everyone else is taken” -Oscar Wilde.</blockquote><p>shedding off the masks you’ve put on to please people can have a lot of potential benefits. For starters the relief from living a fake life will give you a lot of joy,where you no longer have to do things just to please a few people who most likely don’t even appreciate you. Secondly, you’ll now be able to achieve your full potential set by your own standards and values and not dictated by what other people have to say on every small thing that you do.</p><h4>3.evaluate your values</h4><p>Your values are the things that you believe are important in the way you live and work.</p><p>These values should determine your priorities in whatever task you want to achieve, be it business, social interactions or even your spirituality. When you define this persona values, it becomes easier to identify what’s really <a href="https://www.mindtools.com/pages/article/newTED_85.htm">important to you</a>.</p><h4>4. embrace your flaws</h4><p>There’s nothing bad in trying to be your best with the natural abilities and talents that you have.What hurts is when you are enslaved by the compulsion to meets some artificial standards on what is ‘perfect’. In reality, perfection is an illusion as nothing in this world is hardly perfect. Try embrace the flaws you have, be it a scar in your body, an inability to do something or psychological issues. You’ll find that if you stop worrying about this issues, you’ll actually lighten up more easily and you become healthier. Healthier relationships with others and most importantly a healthier relationship with yourself.</p><p>Most importantly , avoid comparing yourself to others as much as you can as well.</p><h4>5. Don’t forget to laugh</h4><p>Laughter is the best medicine. Don’t believe me?<a href="https://www.helpguide.org/articles/mental-health/laughter-is-the-best-medicine.htm/">check this out</a></p><p>Sulking and whining all day will not alleviate all your problems, if anything,it just makes you a toxic person and one to avoid. Doing things that make you happy this coming year should be a top priority. Laughing has been proven to ease up a lot of tension and actually reduce stress. So why not do yourself a favor and laugh more often?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3oz8xSSfeH1U6l4DTy%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fkevinhartwhatnow-funny-film-3oz8xSSfeH1U6l4DTy&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3oz8xSSfeH1U6l4DTy%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="351" frameborder="0" scrolling="no"><a href="https://medium.com/media/554fc9df8729ff0fb82a9af25922786d/href">https://medium.com/media/554fc9df8729ff0fb82a9af25922786d/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9259d09bba8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[why you shouldn’t read too much]]></title>
            <link>https://lewiskori.medium.com/why-you-shouldnt-read-too-much-4bfa0664f05c?source=rss-bc9050c089c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bfa0664f05c</guid>
            <category><![CDATA[books]]></category>
            <category><![CDATA[reading]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[reading-books]]></category>
            <dc:creator><![CDATA[Lewis Kori]]></dc:creator>
            <pubDate>Sat, 20 Oct 2018 08:23:31 GMT</pubDate>
            <atom:updated>2018-10-20T08:23:31.260Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ydRBbiqHq-CyX1tb-etiUg.jpeg" /></figure><p>It’s <a href="https://www.huffingtonpost.com/himay-zepeda/7-ways-books-can-change-y_b_5482902.html">no secret that reading a good book can be a life changing moment</a> .</p><blockquote>“I do believe something very magical can happen when you read a good book”</blockquote><blockquote>-J.K Rowling</blockquote><p>However as with most things with life, too much of it has its own undesirables.Here’s a list of why.(unpopular opinion).Don’t crucify me😁</p><h4><strong>1.You don’t take away any lessons if you read too much.</strong></h4><p><em>“In the case of good books, the point is not to see how many of them you can get through, but rather how many can get through to you.” -Mortimer J. Adler</em></p><p>the<a href="https://medium.com/swlh/why-reading-100-books-a-year-wont-make-you-successful-1863dad5944d"> end goal is not too read so many books</a> but rather to take away any valuable lessons the book may have by internalizing well after you’ve read. most people however seem to think that it’s a competition or try to prove a point by reading too much. Take a chill pill bruh.</p><h4>2.Confuse reality with plots in a book</h4><p>Often times avid readers find themselves narrating an incident of what one of their friends has gone through only to redress themselves later by remembering it was a character from their many fantasies(**coughs not hinting at me **coughs). That’s when you know you’ve got to get a life maeen.</p><h4>3.Antisocial tendencies</h4><p>Getting too engrossed in a good book can be fun. Don’t get me wrong, but if the process interferes with your social life to a point that you alienate yourself from your friends. You have to ask yourself, am I really doing the right thing?</p><h4>4.Get lost in thought</h4><p>This is where the sword swings both ways. while i do not deny that introspection is good for the mind and soul, there’s a certain degree where people tend to get too deep in their fantasies thinking about a certain read, forgetting their own reality. while it’s good to escape sometime, it’s important as well to stay grounded in reality.</p><blockquote>“life is not a book, you don’t wait around for someone to write you a happy ending”</blockquote><p>So what’s your take? is there a thing like <a href="https://www.bustle.com/articles/166425-12-things-that-happen-when-you-read-too-much">reading too much</a>?</p><p><em>checkout my</em><a href="https://twitter.com/lewis_kihiu"><em> twitter</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bfa0664f05c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>