<?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: Manish Kumar Shah</title>
    <description>The latest articles on DEV Community by Manish Kumar Shah (@manishshah120).</description>
    <link>https://dev.to/manishshah120</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%2F434025%2Fda2e840c-2471-48a9-95db-8cca59fa50c0.jpeg</url>
      <title>DEV Community: Manish Kumar Shah</title>
      <link>https://dev.to/manishshah120</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manishshah120"/>
    <language>en</language>
    <item>
      <title>Django Same data objects get created every time!</title>
      <dc:creator>Manish Kumar Shah</dc:creator>
      <pubDate>Tue, 11 Aug 2020 18:40:42 +0000</pubDate>
      <link>https://dev.to/manishshah120/django-same-data-objects-get-created-every-time-llg</link>
      <guid>https://dev.to/manishshah120/django-same-data-objects-get-created-every-time-llg</guid>
      <description>&lt;p&gt;Here's the &lt;em&gt;models.py&lt;/em&gt; file&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.db import models
from django.utils.text import slugify

class News(models.Model):
    title         =   models.CharField(max_length=120)
    datess        =   models.CharField(max_length=120)
    linkss        =   models.CharField(max_length=120)
    slug          =   models.SlugField(blank=True, null=True)

    def save(self, *args, **kwargs):
        if not self.slug and self.title:
            self.slug = slugify(self.title)
        super(News, self).save(*args, **kwargs)

    class Meta:
        verbose_name_plural = "news"

    def __str__(self):
        return f'{self.title}'

    def get_absolute_url(self):
        return f"/news/{self.slug}"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the &lt;em&gt;views.py file&lt;/em&gt;&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.shortcuts import render
from .models import News
from django.core.paginator import Paginator
from django.db.models import Q
# For scraping part
import requests
from bs4 import BeautifulSoup


def news_list(request, *args, **kwargs):
    # fOR scraping part - START::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    response = requests.get("http://www.iitg.ac.in/home/eventsall/events")
    soup = BeautifulSoup(response.content,"html.parser")
    cards = soup.find_all("div", attrs={"class": "newsarea"})

    iitg_title = []
    iitg_date = []
    iitg_link = []
    for card in cards[0:6]:
        iitg_date.append(card.find("div", attrs={"class": "ndate"}).text)
        iitg_title.append(card.find("div", attrs={"class": "ntitle"}).text.strip())
        iitg_link.append(card.find("div", attrs={"class": "ntitle"}).a['href'])
    # fOR scraping part - END::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    # fOR storing the scraped data directly into the dtatbase from the views.py file - START---------------------------------------------------------------
    for i in range(len(iitg_title)):
        News.objects.create(title = iitg_title[i], datess = iitg_date[i], linkss = iitg_link[i])
    # fOR storing the scraped data directly into the dtatbase from the views.py file - END-----------------------------------------------------------------

    queryset = News.objects.all()   #Getting all the objects from the database

    search_query = request.GET.get('q')
    if search_query:
        queryset = queryset.filter(
            Q(title__icontains = search_query) |
            Q(description__icontains = search_query)
        )

    paginator = Paginator(queryset, 5)  #Adding pagination
    page_number = request.GET.get('page')
    queryset = paginator.get_page(page_number)

    context = {
       'object_list': queryset
    }

    return render(request, 'news_list.html', context)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this above code each time I refresh the webpage the same data objects get's created again and again, How to solve this issue?&lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>sql</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Facial expression detection with PyTorch</title>
      <dc:creator>Manish Kumar Shah</dc:creator>
      <pubDate>Sat, 01 Aug 2020 18:08:15 +0000</pubDate>
      <link>https://dev.to/manishshah120/facial-expression-detection-with-pytorch-436m</link>
      <guid>https://dev.to/manishshah120/facial-expression-detection-with-pytorch-436m</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/jovianml/can-computers-understand-our-emotions-c296ddf5f23f"&gt;https://medium.com/jovianml/can-computers-understand-our-emotions-c296ddf5f23f&lt;/a&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>python</category>
      <category>imagerecognition</category>
    </item>
  </channel>
</rss>
