<?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: vinod sagar</title>
    <description>The latest articles on DEV Community by vinod sagar (@vinodsa).</description>
    <link>https://dev.to/vinodsa</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%2F1177096%2F19a07e0e-6af3-4945-b4a3-3e46f0dfc76a.jpeg</url>
      <title>DEV Community: vinod sagar</title>
      <link>https://dev.to/vinodsa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vinodsa"/>
    <language>en</language>
    <item>
      <title>Using Faker Module in Django</title>
      <dc:creator>vinod sagar</dc:creator>
      <pubDate>Tue, 02 Jan 2024 08:27:51 +0000</pubDate>
      <link>https://dev.to/vinodsa/using-faker-module-in-django-2k3</link>
      <guid>https://dev.to/vinodsa/using-faker-module-in-django-2k3</guid>
      <description>&lt;p&gt;When ever we are working on some application and testing on it , we need some data which are harder to type often so using this faker data module , we can save time and helpful to do productive work.&lt;/p&gt;

&lt;p&gt;pip install Faker&lt;/p&gt;

&lt;p&gt;Below is the documentation of FAKER module&lt;br&gt;
[&lt;a href="https://faker.readthedocs.io/en/master/"&gt;https://faker.readthedocs.io/en/master/&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;This is the code we can use in Django application.&lt;/p&gt;

&lt;p&gt;create a file in project folder any name faker_data.py&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crudproject.settings') # crudproject is your project name 
import django
django.setup()
import random
from crudapp.models import Student #this is application name and model
from faker import Faker
fake = Faker()
country = ['India', 'Sweden', 'England', 'Italy', 'Brazil', 'Austria'] 

def lazy_name():
  fname = fake.first_name()
  lname = fake.last_name()
  email = fake.email()
  mobile = fake.ean(length=13)
  location = random.choice(country)
  student = Student.objects.get_or_create(fname=fname, lname=lname, email=email, mobile=mobile, location=location)
  return student

def generate_times(N):
  for _ in range(N):
  lazy_name()

if __name__ == '__main__':
print("Generating please wait..")
generate_times(10)
print("Names generated")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thank you&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>django</category>
      <category>faker</category>
    </item>
  </channel>
</rss>
