<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: JonesOnCorners</title>
    <description>The latest articles on DEV Community by JonesOnCorners (@jonesoncorners).</description>
    <link>https://dev.to/jonesoncorners</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%2F191751%2Fb20807e8-9b65-4159-9c6d-850f529afba9.jpeg</url>
      <title>DEV Community: JonesOnCorners</title>
      <link>https://dev.to/jonesoncorners</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jonesoncorners"/>
    <language>en</language>
    <item>
      <title>Lists in Python</title>
      <dc:creator>JonesOnCorners</dc:creator>
      <pubDate>Thu, 30 Jan 2020 10:15:52 +0000</pubDate>
      <link>https://dev.to/jonesoncorners/lists-in-python-26gg</link>
      <guid>https://dev.to/jonesoncorners/lists-in-python-26gg</guid>
      <description>&lt;h1&gt;
  
  
  The Basics
&lt;/h1&gt;

&lt;p&gt;1) One of the 4 data strucuters provided by Python(as of version 3.7).&lt;br&gt;
   2) Used to store homegeneous or heterogeneous data i.e a single list can hold various data types.&lt;br&gt;
   3) If you come from a C or C++ background which have Arrays, Python Lists are similar to them but much more powerful.&lt;/p&gt;

&lt;h1&gt;
  
  
  Examples
&lt;/h1&gt;

&lt;h1&gt;
  
  
  Basic List examples
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;my_first_list = [1, 2, 3, 4, 5, 1]&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;my_second_list = ['JSON','XML','YAML']&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;my_third_list = ['JAVA',1.2,'Orcale', "a+b", 7]&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(f"My First List is {my_first_list}\n")&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;print(f"My Second List is {my_second_list}\n")&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;print(f"My Third List is {my_third_list}\n")&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Methods available for Lists
&lt;/h1&gt;

&lt;p&gt;1) &lt;strong&gt;&lt;em&gt;copy()&lt;/em&gt;&lt;/strong&gt; used to copy one list to another&lt;br&gt;
2) &lt;strong&gt;&lt;em&gt;count()&lt;/em&gt;&lt;/strong&gt; used to count the occurence of a particular element in the &lt;br&gt;
   list.The Counter() function available in the collections module is a faster &lt;br&gt;
   way if you want to count the entire list&lt;br&gt;
3) &lt;strong&gt;&lt;em&gt;insert()&lt;/em&gt;&lt;/strong&gt; takes in 2 arguments a) the index at which the insert needs to &lt;br&gt;
   happen and b) the element to be inserted. Please make a note that if the index &lt;br&gt;
   entered is greater than the length of the list the element will always be &lt;br&gt;
   appended to the last.&lt;br&gt;
4) &lt;strong&gt;&lt;em&gt;pop()&lt;/em&gt;&lt;/strong&gt; as many would already know is used to display the last inserted &lt;br&gt;
   element. Pop is a common stack operation&lt;br&gt;
5) &lt;strong&gt;&lt;em&gt;reverse()&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;sort()&lt;/em&gt;&lt;/strong&gt; are pretty self explanatory, the only point &lt;br&gt;
   to note is that both these happen in place i.e. the original list is sorted or &lt;br&gt;
   reversed. Also worth noting that sort() doesn't work for heterogeneous lists&lt;br&gt;
6) &lt;strong&gt;&lt;em&gt;append()&lt;/em&gt;&lt;/strong&gt; function adds a new elemet to the end of the list&lt;br&gt;
7) &lt;strong&gt;&lt;em&gt;clear()&lt;/em&gt;&lt;/strong&gt; just makes the list blank in place.&lt;/p&gt;

&lt;h1&gt;
  
  
  Inserting, appending and pop from a list examples
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;my_first_list.insert(88,55)&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;my_first_list.insert(3,33)&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;my_first_list.append(99)&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;print(f"My first list after inserting element is {my_first_list}\n")&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;print(f"Result of pop is {my_first_list.pop()}\n")&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;print(f"My first list after pop element is {my_first_list}\n")&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;print(f"The number of times 1 appears in my_first_list is {my_first_list.count(1)}\n")&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Sort and reverse a list
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;my_sorted_first_list = my_first_list.sort()&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(f"New list after sorting is {my_sorted_first_list}")&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(f"Original list after sorting is {my_first_list}")&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Counting elements in a list
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print("Entire counted list is--&amp;gt; ",Counter(my_first_list))&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print("Number of times 1 occurs in the list is--&amp;gt; ",my_first_list.count(1))&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Slicing and Indexing Lists
&lt;/h1&gt;

&lt;p&gt;Indexing is selecting one of the member from a list. Indexes in Python just like in any other programming language start with 0.Reverse indexing is also possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;list_index  = ['Scott','Marcus','Jesse','David','Juan']&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print("Element at index 2 is ", list_index[2])&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print("Element at index -2 is", list_index[-2])&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Slicing is where you want to select more than one element from a list and follows the general rule&lt;br&gt;
   list[start🔚step]&lt;br&gt;
   where start = starting index&lt;br&gt;
         end   = end index not inclusive of the end i.e. last element will be &lt;br&gt;
                 index[end-1]&lt;br&gt;
         step  = positional skip in between start and end&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;list_slice = [1, 4, 10, 55, 2, 32, 56, 86, 29, 90]&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(list_slice[0::3])&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(list_slice[0::4])&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(list_slice[-7:-4])&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(list_slice[::-2])&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;list_slice.extend((100, 101))&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(list_slice)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  List Comprehension
&lt;/h1&gt;

&lt;p&gt;This is a way which allows us to create new lists where in the new list &lt;br&gt;
is a result of some operation be it simple or a complex.&lt;/p&gt;

&lt;h1&gt;
  
  
  Consider you want a list of squares for all the numbers from 1 to 10
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;**list_squares_upto10 = [x&lt;/em&gt;&lt;em&gt;2 for x in range(11)]&lt;/em&gt;**&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(list_squares_upto10)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Consider another example of preparing a list which is a combination of two lists.&lt;br&gt;
The syntax and readability of such inline codes does go down but they are&lt;br&gt;
still a very powerful tool for smaller operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;combined_list = [(x, y) for x in [1, 2, 4] for y in [2, 4, 5] if x != y]&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(combined_list)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;list_of_negative = [-2, -10, -7, -15]&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;list_of_abs = [abs(x) for x in list_of_negative]&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(list_of_abs)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;print(my_first_list)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  y = list(zip(*[iter(my_first_list)]*3))
&lt;/h1&gt;

&lt;p&gt;print(y)&lt;/p&gt;

&lt;p&gt;In addition to the methods specific to Lists, the below Python methods are also&lt;br&gt;
applicable&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;max(list)&lt;/li&gt;
&lt;li&gt;min(list)
3.sorted(list)&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Series Login-Logout &amp; Authentication in Django --Part I</title>
      <dc:creator>JonesOnCorners</dc:creator>
      <pubDate>Tue, 08 Oct 2019 05:53:19 +0000</pubDate>
      <link>https://dev.to/jonesoncorners/series-login-logout-authentication-in-django-part-i-4gf4</link>
      <guid>https://dev.to/jonesoncorners/series-login-logout-authentication-in-django-part-i-4gf4</guid>
      <description>&lt;p&gt;Django comes with a very comprehensive user authentication module which can be combined with it's fantastic &lt;strong&gt;admin&lt;/strong&gt; module to implement user login and logout modules. In this series my aim is to implement user authentication using various methodologies available to use today. We start of by using the inbuilt Django Authentication. &lt;/p&gt;

&lt;p&gt;I strongly suggest everyone starts off by reading the official Django Authentication Docs first which are available at the link &lt;a href="https://docs.djangoproject.com/en/2.2/topics/auth/"&gt;Django Authentication&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AUTHENTICATION v/s AUTHORIZATION&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's also almost always good to know what's the difference between &lt;strong&gt;authentication&lt;/strong&gt; and &lt;strong&gt;authorization&lt;/strong&gt;. To explain it in a very simple way, consider you are invited to a party at a colleagues place and are given a invitation card, so you turn up at your friends' place, ring the bell and the friend looks at your invite(yes, he's a very bad friend who doesn't trust you just by looking at you) and lets you in i.e. you are &lt;strong&gt;authenticated&lt;/strong&gt; via the invite he gave you. Once you enter, the friend tells you the party rules and clearly mentions that the party is restricted to the hall and the kitchen, all the rooms upstairs are out of limits, i.e you are &lt;strong&gt;authorized&lt;/strong&gt; to use the hall and the kitchen(and of course the toilets :xD) but not the rooms upstairs. So in technical terms, authentication is allowing entry to a website or an application but authorization is limiting what area of the app you are allowed to access. Authentication and Authorization are implemented by creating users, roles, groups, auth tokens and so on.&lt;/p&gt;

&lt;p&gt;As said earlier, Django comes with the auth module pre-installed. Once go through the standard process of creating a django project using the &lt;strong&gt;django-adming start project&lt;/strong&gt; command the settings.py file contains auth module already.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pc_0-vL7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/uy95mi2uku2bzc6w9rwu.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pc_0-vL7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/uy95mi2uku2bzc6w9rwu.JPG" alt="Installed Apps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We also need to add the url to access these login and logout pages the urls.py of our project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;urlpatterns = [
    path('admin/', admin.site.urls),
    path('display/', include('display.urls')),
    path('accounts/', include('django.contrib.auth.urls')), #Add this line to the urls.py of the **PROJECT**

]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Django also provides a very simple but useful login html form which is more than sufficient for getting a hold of the basics. In order to make use of the form we start off by creating the templates folder and within it a registration sub folder. In the registration folder create a login.html file which we will use to render the standard &lt;em&gt;form.as_p&lt;/em&gt; login html template. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--83QlVzMj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r4ridhjp8jw9nadl3dao.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--83QlVzMj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r4ridhjp8jw9nadl3dao.JPG" alt="Directory Structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next we move to the settings.py and within that we need to register the templates folder we just created so that all the html files can be clubbed together in this location and are accessible across all applications within our project.&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uShdKr7X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ge1ckkwq46rhqroda05k.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uShdKr7X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ge1ckkwq46rhqroda05k.JPG" alt="Register  templates folder"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now move to the login.html file we just created and add the below lines of code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{% block title %}Login{% endblock %} 
{% block content %}
&amp;lt;h2&amp;gt;Login&amp;lt;/h2&amp;gt;
&amp;lt;form method="post"&amp;gt;
    {% csrf_token %} {{ form.as_p }}
    &amp;lt;button type="submit"&amp;gt;Login&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
{% endblock %}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This code will render&lt;br&gt;
1) A page titled Login&lt;br&gt;
2) A form with two text fields  Username and Password and a login button.&lt;br&gt;
3) The button on click makes a HTTP POST request.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Na0tC6r1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/28pqn1hqkhoc5m52e97j.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Na0tC6r1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/28pqn1hqkhoc5m52e97j.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, you can use this screen to login via a user which can be easily created using the django admin console. The database table which the user is authenticated once we login is the &lt;em&gt;auth_user&lt;/em&gt;, which Django implicitly generates when we do our first migration when we create a django project. I will probably do a Django project starter tutorial later to cover this part. Once you enter the credential and hit enter you'll notice that you get a HTTP 404, the reason is your Django application doesn't really have a redirect function as of now, as in it doesn't know what to do on successful login. In order to handle that let's create a default landing page called &lt;em&gt;home.html&lt;/em&gt; where we can redirect upon login.&lt;/p&gt;

&lt;p&gt;In the templates base folder(not the registration sub folder) we'll create a file home.html* which will display a simple welcome message and also allow the user to logout so that we can complete the whole login-logout toggle. We will also modify the &lt;strong&gt;project&lt;/strong&gt; urls.py to add the home page view and also modify the settings.py to add two more parameters at the end &lt;strong&gt;LOGIN_REDIRECT_URL&lt;/strong&gt; and &lt;strong&gt;LOGOUT_REDIRECT_URL&lt;/strong&gt; essentially telling Django what to do when the user chooses to logout. &lt;/p&gt;

&lt;p&gt;The code of the home.html is designed to handle both login and logout, i.e. if the user is logged in it displays a simple  'Welcome  !!!' user message and provides a logout link which uses the Django logout template. If the user logs out we simply display a message and provide a link back to the login page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{% extends 'base.html' %} {% block title %} HOME {% endblock %} 
{% block content%} 
    {%if user.is_authenticated %} 
        Welcome {{ user.username }}!!!
       &amp;lt;p&amp;gt;&amp;lt;a href="{% url 'logout' %}"&amp;gt;logout&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
    {% else %}
        &amp;lt;p&amp;gt;You are not logged in&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;&amp;lt;a href="{% url 'login' %}"&amp;gt;login&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
    {% endif %} {% endblock %}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Final urls.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.contrib import admin
from django.urls import path, include
from django.views.generic.base import TemplateView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('display/', include('display.urls')),
    path('accounts/', include('django.contrib.auth.urls')),
    path('', TemplateView.as_view(template_name ='home.html'), name = 'home'),

]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Add below parameters to the settings.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LOGIN_REDIRECT_URL ='home'
LOGOUT_REDIRECT_URL = 'home'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kNrCHmw_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rzkj0swyqi308w1y0cg2.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kNrCHmw_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rzkj0swyqi308w1y0cg2.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T03vOtiN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/we68738b04idxzg7jflt.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T03vOtiN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/we68738b04idxzg7jflt.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4V3Loz7g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/d2w3v5wodd1p9ug3myj8.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4V3Loz7g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/d2w3v5wodd1p9ug3myj8.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So this is the most basic authentication functionality provided by Django which is powerful enough to implement for a beginner level project or even at a small college level. &lt;/p&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Setting up MYSQL on UBUNTU EC2 and hassle free connectivity from MYSQL Workbench</title>
      <dc:creator>JonesOnCorners</dc:creator>
      <pubDate>Tue, 24 Sep 2019 05:55:24 +0000</pubDate>
      <link>https://dev.to/jonesoncorners/setting-up-mysql-on-ubuntu-ec2-and-hassle-free-connectivity-from-mysql-workbench-15hj</link>
      <guid>https://dev.to/jonesoncorners/setting-up-mysql-on-ubuntu-ec2-and-hassle-free-connectivity-from-mysql-workbench-15hj</guid>
      <description>&lt;p&gt;So I start my blogging journey with this post, feedback on this will be much appreciated. I've recently moved from developing legacy applications hosted on-premise to developing on a cloud based environments. So far I have worked on both GCP and Amazon AWS, although the exposure to GCP is rather limited.One particular issue I've seen many people struggle with is getting their EC2 instances setup for MYSQL and then connecting them from MYSQL Workbench. So here is a tutorial that will help you get started.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/lumberyard/latest/userguide/linux-set-up-ubuntu-amazon-ec2.html"&gt;Once your EC2 instance is up and running&lt;/a&gt; the first thing you need to do is upgrade the default software package provided on the instance that you just managed to fire up. Start by switching to the root using the command&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;sudo su&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then follow this up by first installing MYSQL on the instance by firing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;apt install mysql-server&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the installation is complete check if the mysql service is running using&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;systemctl status mysql&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The next part is making the necessary configuration for allowing external connections to this EC2 database instance. This can be achieved by &lt;br&gt;
1) Setting up the &lt;em&gt;root&lt;/em&gt; user to connect from workbench by changing the authentication method from &lt;em&gt;auth_sockect(default)&lt;/em&gt; to &lt;em&gt;mysql_native_password&lt;/em&gt; &lt;br&gt;
&lt;strong&gt;ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'very_strong_password';&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;or &lt;/p&gt;

&lt;p&gt;2) Creating another user simply for external users, please note that the case is important here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'newpwd';&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now the EC2 side part is pretty much done. Download the MYSQL Workbench and click on the (+) to add a new connection&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uvYDOCm9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/xpbongvzo61c2z11yygb.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uvYDOCm9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/xpbongvzo61c2z11yygb.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The pop screen which appears looks something like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ziumqDPp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ksy0d0ly2gjulv904km1.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ziumqDPp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ksy0d0ly2gjulv904km1.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the screen you need to make the following configurations&lt;/p&gt;

&lt;p&gt;Connection Method:- Standard TCP/IP over SSH&lt;br&gt;
SSH Name         :- The public IP of your Amazon EC2 instance&lt;br&gt;
SSH Username     :- Choose as per your EC2&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a5vEpNEE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3yll6haxdw3npy8rqlpb.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a5vEpNEE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3yll6haxdw3npy8rqlpb.JPG" alt="Depending on what EC2 instance you've used a list of usernames can be found here"&gt;&lt;/a&gt;&lt;br&gt;
SSH Password     :- No change needed&lt;br&gt;
SSH Key File     :- &lt;strong&gt;This is important, you need to use the .PEM file downloaded while creating the EC2 instance and not the .PPK file because while connecting from putty we use the .PPK, do not get confused.&lt;/strong&gt;&lt;br&gt;
MYSQL Hostname   :- 127.0.0.1&lt;br&gt;
MYSQL Username   :- Depending on what approach you took it can be either &lt;em&gt;root&lt;/em&gt; or the &lt;em&gt;newuser&lt;/em&gt; you created&lt;br&gt;
MYSQL Password   :- The password you created. Hope it's a strong one.&lt;br&gt;
Default Schema   :- Leave blank&lt;/p&gt;

&lt;p&gt;Click on Test Connection and you should be all set&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zqkzIzsj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/adomtzu0ioplh8eabjtj.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zqkzIzsj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/adomtzu0ioplh8eabjtj.JPG" alt="Test Connection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this step if you get an access denied error I am pretty sure you did one of the following 3 things wrong(been there done that)&lt;br&gt;
1) Your user creation and grants have not been done correctly. If you are using root user you can query the mysql.user table and check if the root user has &lt;em&gt;mysql_native_password&lt;/em&gt; set.&lt;br&gt;
2) You are not using the .PEM file but .PPK instead&lt;br&gt;
3) Your password isn't correct.&lt;/p&gt;

&lt;p&gt;Happy starting your AWS journey :)&lt;/p&gt;

</description>
      <category>aws</category>
      <category>database</category>
      <category>ubuntu</category>
      <category>python</category>
    </item>
  </channel>
</rss>
