<?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: Mandyiee</title>
    <description>The latest articles on DEV Community by Mandyiee (@okonkwomandy).</description>
    <link>https://dev.to/okonkwomandy</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%2F839423%2Fb556d86c-a784-45da-b928-506b60ecd44d.jpg</url>
      <title>DEV Community: Mandyiee</title>
      <link>https://dev.to/okonkwomandy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/okonkwomandy"/>
    <language>en</language>
    <item>
      <title>The easiest way to build the Pinterest Layout without using a framework</title>
      <dc:creator>Mandyiee</dc:creator>
      <pubDate>Sun, 02 Oct 2022 21:49:36 +0000</pubDate>
      <link>https://dev.to/okonkwomandy/the-easiest-way-to-build-the-pinterest-layout-without-using-a-framework-3i0g</link>
      <guid>https://dev.to/okonkwomandy/the-easiest-way-to-build-the-pinterest-layout-without-using-a-framework-3i0g</guid>
      <description>&lt;p&gt;Modern web design is at the forefront of the industry. The usual CSS grid layout with equal spacing is quickly losing popularity, whereas the Pinterest layouts with unlimited scrolling are quickly taking over as the standard.  This article provides an in-depth look at creating the Pinterest layout. &lt;/p&gt;

&lt;p&gt;The Pinterest layout, often known as the masonry layout, arranges elements one after the other in a linear fashion. Items will fill in any gaps left by shorter items in the first line when they migrate to the following line.&lt;/p&gt;

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

&lt;p&gt;In plainer language, HTML elements such as images or card elements can be displayed on a website in a visually appealing and space-efficient manner. Pinterest is the most well-known application of the masonry layout, it is known as the "Pinterest Layout " for this reason. The Pinterest layout excels in lengthy lists and flexible layouts.&lt;/p&gt;

&lt;p&gt;Additionally, websites that use photographs as their "highlight" often find that the Pinterest layout is the best option. Visual imagery always has a significant impact on the perceived worth and memorability of a website's user experience.&lt;/p&gt;

&lt;p&gt;The Pinterest layout solves these two issues. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The images on a website have to stand out.&lt;br&gt;
At least some if not all of the images in a website should stand out.  These visuals are used to convey the significance of the aspects i.e drawing users to certain pages or CTAs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The much more satisfying view of the dynamic layout.&lt;br&gt;
With different row sizes, scrolling would be more entertaining and interactive, especially when designing for mobile screens. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Pinterest layout can be constructed in a variety of ways. Some would need complex calculations, while others would need CSS and Javascript. Here are a few of the most straightforward solutions. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The CSS Flexbox&lt;/li&gt;
&lt;li&gt;The CSS Grid&lt;/li&gt;
&lt;li&gt;The CSS column&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The CSS Flexbox
&lt;/h3&gt;

&lt;p&gt;The use of CSS Flexbox and a little Javascript is required for this technique. The basic idea here is to create div elements based on the number of columns, attach those div elements to the main container, and place the former boxes in the corresponding column.&lt;/p&gt;

&lt;p&gt;The concept in infographics,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Javascript is used to obtain the container that requires the Pinterest layout &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frw1yiffsn69b6766cgrl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frw1yiffsn69b6766cgrl.png" alt="The container that requires the Pinterest layout &amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Based on the necessary amount of columns, Javascript would be employed to create new div elements. Three were selected as the number of columns, therefore three div elements were created.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;The previous div elements (boxes) are divided throughout the columns to generate the Pinterest layout.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhfqi43vrwjn0n1r9sa5j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhfqi43vrwjn0n1r9sa5j.png" alt="the Pinterest layout"&gt;&lt;/a&gt;&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/Mandyee/embed/jOxLbLw?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  The Grid-Masonry
&lt;/h3&gt;

&lt;p&gt;The use of a CSS grid would be employed for this layout. The columns will serve as the grid axis and the rows will be the masonry axis. This layout is structured using the grid-template-columns and the grid-template-rows. &lt;/p&gt;

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

.container { 
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-gap: 10px;
  padding: 10px;
  grid-template-rows: masonry;
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;That, however, only functions in Firefox. For other browsers,  this is the workaround.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;.boxes&lt;/em&gt; class would be added to all the elements in our container.&lt;/p&gt;

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

.boxes {
  width: 100%;
  height: 100px;
  grid-row: auto / span 1;
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;grid-row: auto / span 1;&lt;/code&gt; tells the element to span across one row. The row height that was selected was 100px. The remaining boxes should either span across double or triple rows which means they should either be double or triple the height respectively. &lt;/p&gt;

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

.box-1 {
  height: 200px;
  grid-row: auto / span 2;
}


&lt;/code&gt;&lt;/pre&gt;

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

.box-2 {
  height: 300px;
  grid-row: auto / span 3;
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With that, The Pinterest layout has been achieved.&lt;/p&gt;

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

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Mandyee/embed/xxjrgrB?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  The CSS Columns
&lt;/h3&gt;

&lt;p&gt;This is the simplest solution setting that doesn't need calculations or Javascript. Although it reorders the div elements, it is still the most sought-after solution. &lt;/p&gt;

&lt;p&gt;The column is added to the masonry container&lt;/p&gt;

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

.boxes-con {
  -moz-column-count: 3;
  -webkit-column-count: 3;
  column-count: 3;
  column-gap: 20px;
  }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Even while this works, there is one thing you must remember. The CSS multi-column style was designed for text and enables text to break inside; however, the Pinterest layout does not require this. The solution would be to add &lt;code&gt;break-inside: avoid-column;&lt;/code&gt; to the child element of the container. &lt;/p&gt;

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

.boxes {
break-inside: avoid-column;
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The Pinterest layout has been achieved. &lt;/p&gt;

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

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Mandyee/embed/JjvJbVa?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  The End
&lt;/h3&gt;

&lt;p&gt;It will be ideal to use the layout now that you are fully informed of how to construct the Pinterest layout. Along with improving the website's aesthetic, the Pinterest layout can also give it improved functionality. Other Examples of the Pinterest layout design in action might be image galleries, blog postings, news websites, etc.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>css</category>
    </item>
    <item>
      <title>Coding Without The Traditional Database: Facing The Challenges</title>
      <dc:creator>Mandyiee</dc:creator>
      <pubDate>Mon, 15 Aug 2022 21:32:00 +0000</pubDate>
      <link>https://dev.to/okonkwomandy/building-without-the-traditional-database-the-challenges-e1f</link>
      <guid>https://dev.to/okonkwomandy/building-without-the-traditional-database-the-challenges-e1f</guid>
      <description>&lt;p&gt;The conventional database would be thought of as the standard tool for building software. Developers like myself frequently ponder whether there is a better approach.&lt;/p&gt;

&lt;p&gt;Simply abandoning the common approach and trying something new will result in building without the conventional database. There are several methods, but in our previous &lt;a href="https://dev.to/okonkwomandy/python-shelve-or-the-online-database-system-bfd"&gt;article&lt;/a&gt;, we chose shelve, a straightforward yet powerful python solution for permanent data storage&lt;/p&gt;

&lt;p&gt;I succeeded in creating: &lt;a href="http://thatnoteapp.herokuapp.com/"&gt;thatnoteapp&lt;/a&gt;. &lt;a href="http://thatnoteapp.herokuapp.com/"&gt;Thatnoteapp&lt;/a&gt; is a web app for taking notes that makes use of the shelve package in Python to store notes as private notes. The packages needed for this project are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UUID&lt;/li&gt;
&lt;li&gt;Flask&lt;/li&gt;
&lt;li&gt;Flask_ckeditor&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The major objective of this project was to develop an authentication-free web-based note-taking tool that saves information to the user's device. A website without user registration or login functionality is referred to as authentication-free.&lt;/p&gt;

&lt;p&gt;Numerous challenges were faced in the process of developing this project. Some challenges were overcome, and others caused the initial objectives to be adjusted. A few of the issues are shown here, along with solutions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Incapable of storing data on the user's device&lt;/li&gt;
&lt;li&gt;Inability to retain new data&lt;/li&gt;
&lt;li&gt;Key error &lt;/li&gt;
&lt;li&gt;Personalize the data&lt;/li&gt;
&lt;li&gt;Personalize the data: get_data function&lt;/li&gt;
&lt;li&gt;Redirecting the page&lt;/li&gt;
&lt;li&gt;A list or a string&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Incapable of storing data on the user's device
&lt;/h3&gt;

&lt;p&gt;This is a scenario where one's desire to build a program resulted in the creation of something else that was nonetheless beneficial.&lt;/p&gt;

&lt;p&gt;The biggest letdown was learning that the website could not access the device's storage as originally intended. To make a folder on the device, I intended on making use of this function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def start():
  folder = os.path.join(Path.home(), '.dais')
  file = os.path.join(folder,'daisdb')
  os.chdir(Path.home())
  if os.path.exists(folder):
    if os.path.exists(file): 
      var = 1
   else:
     os.chdir(folder)
     noteObject = shelve.open('daisdb')
     note = [] 
     noteObject['notes'] = note
     noteObject.close()
   else: 
     os.mkdir('.dais') 
     os.chdir(folder)
     noteObject = shelve.open('daisdb')
     note = [] 
     noteObject['notes'] = note 
     noteObject.close()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The functionality had not been created. The server would create the folder rather than the user's device.  This gave me yet another idea: a programmer must always be innovative.&lt;/p&gt;

&lt;p&gt;Although creating a folder on the server was sufficient, the objectives needed to be revised. From initially saving the notes on the device, the objective was changed to "building without the traditional database." However, that created a new challenge, which was how to personalize the data without user authentication.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inability to retain new data
&lt;/h3&gt;

&lt;p&gt;The list couldn't be updated with the new information. I initially considered making a new list and then rebuilding the shelve data for each newly saved note.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;noteObject = shelve.open('daisdb', writeback = True)
noteList =  noteObject['notes']
noteList.append(obj)
noteObject['notes'] = noteList
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Although this method worked, I had to see whether a better solution exist. After considerable investigation, I discovered that the error was generated by my failure to include the write back attribute or close the shelve. To eliminate the mistake, I took this action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;noteObject = shelve.open('daisdb', writeback = True)
 noteObject['notes'].append(obj)
 noteObject.sync() 
noteObject.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The key error
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;noteObject.['notes'].append(obj)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This would occasionally generate this error and other times it would function as intended.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Traceback (most recent call last): File "/usr/lib/python3.5/shelve.py", line 111, in __getitem__ value = self.cache[key] KeyError: 'lb'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Python KeyError, a form of LookupError exception indicates that there was a problem locating the key you were looking for. &lt;/p&gt;

&lt;p&gt;After doing a lot of research and reading StackOverflow, I discovered that the error was triggered by &lt;code&gt;noteObject['notes']&lt;/code&gt;. The error was eradicated by changing &lt;code&gt;noteObject['notes']&lt;/code&gt; to &lt;code&gt;noteObject.get('notes')&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;noteObject = shelve.open('daisdb', writeback = True) 
noteObject['notes'].append(obj)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Changed to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;noteObject = shelve.open('daisdb', writeback = True)
 noteObject.get('notes').append(obj)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Personalize the data
&lt;/h3&gt;

&lt;p&gt;Utilizing &lt;strong&gt;the IP address&lt;/strong&gt; is one method to establish an authentication-free web app.&lt;/p&gt;

&lt;p&gt;An IP address, or Internet Protocol address, is a unique series of numbers that identifies any device on a network.&lt;/p&gt;

&lt;p&gt;The next step was to obtain the IP addresses from both the &lt;strong&gt;backend (server)&lt;/strong&gt; and the &lt;strong&gt;frontend (javascript)&lt;/strong&gt; and compare them to generate personalized data.&lt;/p&gt;

&lt;p&gt;The server's public IP address, which was not unique, was the IP address that the Python code returned. I required a different IP address for each device, therefore this became a significant issue.&lt;/p&gt;

&lt;p&gt;Utilizing &lt;a href="https://axios-http.com/docs/intro"&gt;Axios&lt;/a&gt;  to send the IP address to the backend with the newly saved note became the best option.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;input=hidden&lt;/code&gt; element was used to store before sending the IP address with the submit button&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let start = document.getElementById('title')
        start.addEventListener('focus', async() =&amp;gt; {
            let result = await axios.get(`https://api.ipify.org?format=json`, {
                mode: 'cors',
                credentials: 'include'
            });

            let data = await result.data;
            document.getElementById('hide').value = data.ip
        })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I retrieved the user's IP address from the URL and sent it to a flask view to create a customised page for each user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.addEventListener('load', async() =&amp;gt; { 
 url = "/";
 let result = await axios.get(`https://api.ipify.org?format=json`,
 { mode: 'cors', 
credentials: 'include' 
}); 
 let data = await result.data;  
 let res = axios.post(url, { 
data 
}) 
.then((response) =&amp;gt; {
 console.log('sent')
}, (error) =&amp;gt; {
 console.log(error);
 });
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Personalize the data: get_data function
&lt;/h3&gt;

&lt;p&gt;Retrieving data from the backend after utilizing the Axios function to send the data was not familiar to me. It took a lot of research to find out that using the &lt;code&gt;.get_data()&lt;/code&gt; was the best option.,&lt;/p&gt;

&lt;p&gt;The parameter in the function &lt;code&gt;request.get_data('data')&lt;/code&gt;, is the name of the variable that the data was saved with.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let data = await result.data;  
 let res = axios.post(url, { 
data 
}) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To extract the IP address, the received data is required to be changed into a dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    resp = request.get_data('data')

    resp = json.loads(resp.decode("utf-8").replace("'",'"'))

    ipaddress = resp['data']['ip'] 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Redirecting the page
&lt;/h3&gt;

&lt;p&gt;The flask redirect function was ineffective. It appeared to be because an Axios function was used to send the data, so I used Javascript's &lt;code&gt;window.location.assign()&lt;/code&gt; method to direct the user to their personalized page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.addEventListener('load', async() =&amp;gt; {
    url = "/"

    let result = await axios.get(`https://api.ipify.org?format=json`, {
        mode: 'cors',
        credentials: 'include'
    });

    let data = await result.data;
    console.log(data)
    let res = axios.post(url, {
            data
        })
        .then((response) =&amp;gt; {
            window.location.assign('/' + data.ip);
        }, (error) =&amp;gt; {
            console.log(error);
        });
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  A list or a string
&lt;/h3&gt;

&lt;p&gt;For some reason, I mistook this &lt;code&gt;noteObject['notes']&lt;/code&gt; for a string and used a "+" in instead of the list's "append" function. Fortunately, it was resolved very quickly. I suppose when one overthinks, they forget little details. This serves as a reminder that a good programmer should also get enough rest before writing code.&lt;/p&gt;

&lt;p&gt;Additionally, there are several things that I figured out rather well. This &lt;a href="https://github.com/Mandyiee/thatnoteapp"&gt;link&lt;/a&gt; will take you to the code. As a programmer, I must admit that there are some problems that I haven't solved or whose solutions could be made easier.&lt;/p&gt;

&lt;p&gt;Have a thought? Share it below.&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>database</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Building Without The Traditional Database</title>
      <dc:creator>Mandyiee</dc:creator>
      <pubDate>Wed, 22 Jun 2022 13:14:00 +0000</pubDate>
      <link>https://dev.to/okonkwomandy/python-shelve-or-the-online-database-system-bfd</link>
      <guid>https://dev.to/okonkwomandy/python-shelve-or-the-online-database-system-bfd</guid>
      <description>&lt;p&gt;Why not change things up instead of solely using the online database system to store data? Being unusual is always exciting for the modern day programmer.&lt;/p&gt;

&lt;p&gt;Often wondering if instead of using an online database, I could save data on an individual’s device. That way, I felt it to be more secure. Putting myself to the test I worked on my project. It was quite the challenge. I used the Javascript localstorage API to achieve my purpose.&lt;/p&gt;

&lt;p&gt;Strings can be stored as persistent key-value pairs in the localStorage object. All other windows and frames from the same origin quickly display any changes. Unless the user deletes saved data or configures an expiration limit, the stored values are permanent indefinitely. For accessing and setting values, localStorage employs a map-like interface.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;localStorage.setItem(“key”, “value”);
localStorage.getItem(“key”);
localStorage.removeItem(key);
localStorage.clear()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is a link to the code &lt;a href="https://github.com/Mandyiee/Notella"&gt;github code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another difficulty arose since the localStorage could only hold roughly 5 MB of data.Because it couldn't be used for important purposes, this presented a significant challenge that had to be overcomed.As you could have predicted I found another way. The way? The python shelf library.&lt;/p&gt;

&lt;p&gt;It was defined as a “persistent, dictionary-like object. The difference with “dbm” databases is that the values (not the keys!) in a shelf can be essentially arbitrary Python objects — anything that the pickle module can handle”.&lt;br&gt;
You can read more at &lt;a href="https://docs.python.org/3/library/shelve.html"&gt;https://docs.python.org/3/library/shelve.html&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;How did I come up with this idea? I was reading ‘Al Sweigart’s Automate the boring stuff with Python’ which is one of my favorite programming books. It’s a fantastic book that I highly recommend.&lt;/p&gt;

&lt;p&gt;It is a simple yet effective tool for permanent data storage, as well as a dictionary-like object that is persistently saved in a disk file, in simpler terms.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import shelve
shelfFile = shelve.open(‘mydata’) 
cats = [‘Zophie’, ‘Pooka’, ‘Simon’] 
shelfFile[‘cats’] = cats 
shelfFile.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With that as my base, I was able to construct &lt;a href="http://thatnoteapp.herokuapp.com/"&gt;thatnoteapp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I succeeded in creating the easiest thing I could have hoped to. Here is a brief explanation of how I managed to do that&lt;/p&gt;

&lt;p&gt;In this situation, storing data in an list would be ideal because they are incredibly versatile and simple to manage.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;noteObject = shelve.open('daisdb')
note = [] 
noteObject['notes'] = note 
noteObject.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create new notes, i used a dictionary to store its keys and values. After appending it to the list, we now have a list of of dictionaries&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def new():
 obj = {
  ‘ids’:ids,
  ‘title’:title, 
  ‘content’: data, 
  ‘date’: current_date 
 } 

 noteObject =  shelve.open(‘daisdb’, writeback = True) 
 noteObject[‘notes’].append(obj) 
 noteObject.sync()
 noteObject.close()
 return redirect(‘/’)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this was how I sent it to the front end.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def index():
 noteObject = shelve.open(‘daisdb’, ‘r’, writeback = True) 
 notes = noteObject[‘notes’]
 return render_template(‘index.html’,notes=notes) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The numerous projects that could result from this post interest me; Why not be one of the programmers who would try it out?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I wrote a full tutorial on this &lt;a href="https://dev.to/okonkwomandy/building-without-the-traditional-database-the-challenges-e1f"&gt;project&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Importing Hack</title>
      <dc:creator>Mandyiee</dc:creator>
      <pubDate>Fri, 20 May 2022 19:06:43 +0000</pubDate>
      <link>https://dev.to/okonkwomandy/the-importing-hack-1g8o</link>
      <guid>https://dev.to/okonkwomandy/the-importing-hack-1g8o</guid>
      <description>&lt;p&gt;When I started programming, I was fine with having the longest lines of code. Well, as long as it works, right?&lt;/p&gt;

&lt;p&gt;After some time, I discovered that no one could decipher my code... Much like my handwriting.&lt;/p&gt;

&lt;p&gt;And how would I grow or even get hired if no one else could read my code?&lt;/p&gt;

&lt;p&gt;Like every other programmer, I had to find the  solution. And yes, I got it.&lt;/p&gt;

&lt;p&gt;The "importing hack" solution.&lt;/p&gt;

&lt;p&gt;Importing and exporting modules are already familiar concepts. I would like to discuss how to import and export our function.&lt;/p&gt;

&lt;p&gt;Imagine turning a code that is this lengthy&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def chatWithFriend():
  print("what is your name")
  friend = input()
  print(f' good day {friend}')
  print(f' how are you, {friend}')
  resp1 = input()
  print(f'what is your favorite food,{friend}')
  print('My favourite food is fried rice')
  print('would like to eat my favorite food')
  resp2 = input()
  print(f'what school do you attend, {friend}')
  print('I attend the university of Nsukka, Nigeria')
  resp3 = input()

chatWithFriend()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...Into this. And yes, it works.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#message.py
from greet import *

def chatWithFriend():
  print("what is your name")
  friend = input()
  greetFriend(friend)
  resp1 = input()
  foodFriend(friend)
  resp2 = input()
  schoolFriend(friend)
  resp3 = input()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The trick is this: not using one big function. It would always get very messy. So, why not divide the functions into smaller functions?&lt;/p&gt;

&lt;p&gt;Make a new file, input this functions and import them into your existing one.&lt;/p&gt;

&lt;p&gt;Here are two ways to import these functions &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Importing only one function 
This is used when only one function has to be imported.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#greet.py
def greetFriend(friend):
  print(f' good day {friend}')
  print(f' how are you, {friend}')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#message.py
from greet import greetFriend

def chatWithFriend():
  print("what is your name")
  friend = input()
  greetFriend(friend)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Importing all the functions
This will import all of the file's functions into our main file.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#greet.py
def greetFriend(friend):
  print(f' good day {friend}')
  print(f' how are you, {friend}')

def foodFriend(friend):
  print(f'what is your favorite food,{friend}')
  print('My favourite food is fried rice')
  print('would like to eat my favorite food')

def schoolFriend(friend):
  print(f'what school do you attend, {friend})
  print('I attend the university of Nsukka, Nigeria')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#message.py
from greet import *

def chatWithFriend():
  print("what is your name")
  friend = input()
  greetFriend(friend)
  resp1 = input()
  foodFriend(friend)
  resp2 = input()
  schoolFriend(friend)
  resp3 = input()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Bonus Tip
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Importing only a number of functions
A specific variable named __ all __ can be used in modules to limit which variables are imported.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#greet.py

__all__ = ['greetFriend', 'foodFriend']

def greetFriend(friend):
  print(f'Good day {friend}')
  print(f'How are you, {friend}')

def foodFriend(friend):
  print(f'What is your favorite food,{friend}')
  print('My favourite food is fried rice')
  print('Would like to eat my favorite food')

def schoolFriend(friend):
  print(f'What school do you attend, {friend}')
  print('I attend the university of Nsukka, Nigeria')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#message.py
from greet import *

def chatWithFriend():
  print("what is your name")
  friend = input()
  greetFriend(friend)
  resp1 = input()
  foodFriend(friend)
  resp2 = input()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We all share the programmer's mentality: "If it works, don't change it." I had it too, who didn't? Absolutely no one. &lt;/p&gt;

&lt;p&gt;How did I overcome it? I had to to speak to myself. I didn't want to remain a beginner indefinitely, and I could only progress if my code was readable. It was difficult, but I was able to convince myself.&lt;/p&gt;

&lt;p&gt;If I could do that then, you can. Why not use the imports and exports function?&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>python</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Validating Inputs in a Shorter Time</title>
      <dc:creator>Mandyiee</dc:creator>
      <pubDate>Sun, 15 May 2022 19:59:30 +0000</pubDate>
      <link>https://dev.to/okonkwomandy/validating-inputs-in-a-shorter-time-477c</link>
      <guid>https://dev.to/okonkwomandy/validating-inputs-in-a-shorter-time-477c</guid>
      <description>&lt;p&gt;Writing shorter code is one of the most important characteristics of a competent programmer; anyone can create code, but only a select few can write short code (the short and mighty code).&lt;/p&gt;

&lt;p&gt;Let's have a look at this code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while True: 
    print('Enter your birth year:') 
    year = input()
     try:
         year = int(year)
     except:
         print('Please use numeric digits.')
         continue
     if age &amp;lt; 2999:
         print('The year is not valid')
         continue 
     if age &amp;gt; 1999:
         print('The year is not valid')
         continue 
     break
 print(f'Your birth year is {year}.')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another chunk of code to examine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;age = pyip.inputInt('Enter a new num: ', max=2999, min=1999 )

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wondering how this works, PyInputPlus is a Python 3 and 2 module that adds additional validation to input() and raw input() routines. Al Sweigart is the creator and maintainer of PyInputPlus. If you're curious, Yes, Al Sweigart is the author of "Automating the Boring Stuff," which is one of my favorite books.&lt;/p&gt;

&lt;p&gt;PyInputPlus can be installed from PyPI using pip:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install pyinputplus&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And then you can run&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Import pyinputplus as pyip&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What else am I able to do with this?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;inputStr()&lt;/strong&gt;&lt;br&gt;
Is similar to the built-in input() function, but with PyInputPlus's additional functionality. You can also use it to call a custom validation function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;inputNum()&lt;/strong&gt;&lt;br&gt;
Ensures that the user enters a number and that the result is either an int or a float, kqdepending on whether the value contains a decimal point.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;inputChoice()&lt;/strong&gt;&lt;br&gt;
Ensures that the user selects one of the options available.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;inputMenu()&lt;/strong&gt;  Is comparable to inputChoice(), but instead displays a menu with numbered or lettered choices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;inputDatetime()&lt;/strong&gt;&lt;br&gt;
Ascertains that the user has entered a date and time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;inputYesNo()&lt;/strong&gt;&lt;br&gt;
Ensures that the user responds with a "yes" or "no"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;inputBool()&lt;/strong&gt;&lt;br&gt;
Is identical to inputYesNo(), but instead of returning a Boolean value, it accepts a "True" or "False" response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;inputEmail()&lt;/strong&gt;&lt;br&gt;
Ascertains if the user has entered a genuine email address.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;inputFilepath()&lt;/strong&gt;&lt;br&gt;
Ensures that the user enters a correct file path and filename, with the option to check for the existence of a file with that name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;inputPassword()&lt;/strong&gt;&lt;br&gt;
Is similar to input(), except instead of displaying passwords or other sensitive information on the screen, it displays * characters as the user inputs.&lt;/p&gt;

&lt;h3&gt;
  
  
  How can I use this in my project
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;String Input&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyinputplus as pyip 

# string input 

inp = pyip.inputStr(prompt="Enter a string... l",  blank=True) 

print(inp)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Integer Input&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyinputplus as pyip 

# integer input 

inp = pyip.inputInt(prompt = "Enter an Integer... ",  

                    default = 0, limit = 3) 

print(inp)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Menu Input&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyinputplus as pyip 

# menu item input 

inp = pyip.inputMenu(['apple', 'orange', 'mango']) 

print(inp)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why should I write shorter codes
&lt;/h3&gt;

&lt;p&gt;Shorter lines of code are arguably more efficient than code stretched across multiple lines.&lt;/p&gt;

&lt;p&gt;If you have more lines of code, defects might hide in more places, making discovering them more difficult. &lt;/p&gt;

&lt;p&gt;Many lines of code can yield the same (and likely better) benefits as fewer lines of code.&lt;/p&gt;

&lt;p&gt;Why not try writing shorter codes today? &lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Website without images?</title>
      <dc:creator>Mandyiee</dc:creator>
      <pubDate>Wed, 06 Apr 2022 20:14:01 +0000</pubDate>
      <link>https://dev.to/okonkwomandy/website-without-images-39hp</link>
      <guid>https://dev.to/okonkwomandy/website-without-images-39hp</guid>
      <description>&lt;p&gt;&lt;strong&gt;A website without images would probably be the worst thing on the Internet today.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And even with that fact, some developers do not know how to add images to a website.&lt;/p&gt;

&lt;p&gt;Here is how to do that using the django admin panel.&lt;/p&gt;

&lt;p&gt;Let's use a model class name profile.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; class Customer(models.Model):
  user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE)
  name = models.CharField(max_length=200, null=True)
  email = models.CharField(max_length=200)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First thing we have to do is to add image field to the class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; image = models.ImageField(null=True, blank=True)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have to add the pillow package, the python Imaging Library  is a free and open-source extension library for Python that adds support for accessing, processing, and saving a wide range of image file types.&lt;/p&gt;

&lt;p&gt;We can the install the pillow package by running this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; pip install pillow 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can proceed by adding the data to the database by running the migrations&lt;br&gt;
&lt;/p&gt;

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

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step is to update the media url and root. By doing this, we are telling django where to store the images. You should add this to the settings.py file&lt;br&gt;
&lt;/p&gt;

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

 MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images')

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We should head to the site's urls.py file and import some packages&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; from django.conf.urls.static import static
 from django.conf import settings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how it should look like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; from django.contrib import admin
 from django.urls import path, include
 from django.conf.urls.static import static
 from django.conf import settings

 urlpatterns = [
     path('admin/', admin.site.urls),
     path(' ', include('store.urls')),
    ]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we add this to the urls.py file. This is to add a route for the images&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this,we can upload the image using the django admin panel.&lt;/p&gt;

&lt;p&gt;Finally, we can render the image on the html file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;img class="thumbnail" src="{{profile.image.url}}"&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Bonus Tip&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What if the image was deleted or missing. We would not want the entire website to suddenly stop working. &lt;/p&gt;

&lt;p&gt;There are two ways of going around this error&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Add a property decorator to the model class&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; @property 
    def imageURL(self):
       try:
        url = self.image.url
       execpt:
        url = ""
       return url

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Use an IF statement&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   {% if product.image %}
       &amp;lt;img class="thumbnail" src="{{profile.image.url}}"&amp;gt;
   {% else %}
       &amp;lt;img class="thumbnail" src="{% static 'images/placeholder. png %}"&amp;gt;
   {% endif %}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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