Views & Urls In Django| Python Django Tutorials In Hindi #5

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 พ.ย. 2024
  • ►Source Code + Resources - www.codewithhar...
    ►Full Django Playlist - • Python Django Tutorial...
    ►Click here to subscribe - / @codewithharry
    Best Hindi Videos For Learning Programming:
    ►Learn Python In One Video - • Learn Python In Hindi ...
    ►Learn JavaScript in One Video - • JavaScript Tutorial
    ►Learn PHP In One Video - • Learn Php In One Video...
    ►Machine Learning Using Python - • Machine Learning Tutor...
    ►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
    ►Advanced Python Tutorials - • Intermediate/Advanced ...
    ►Object Oriented Programming In Python - • Object Oriented Progra...
    ►Python Data Science and Big Data Tutorials - • Python Data Science an...
    Follow Me On Social Media
    ►Website (created using Flask) - www.codewithha...
    ►Facebook - / codewithharry
    ►Instagram - / codewithharry
    ►Personal Facebook A/c - / geekyharis
    Twitter - / haris_is_here

ความคิดเห็น • 693

  • @CodeWithHarry
    @CodeWithHarry  5 ปีที่แล้ว +85

    If you really want me to make a social networking website in Django in one video, share this Django series everywhere!
    I will definitely make a video explaining social networking website development in one video if I get 500+ shares on my playlist!
    Thanks a lot in advance to all those who shared!
    Link is here - th-cam.com/play/PLu0W_9lII9ah7DDtYtflgwMwpT3xmjXY9.html

    • @prasanjeetbiswas4423
      @prasanjeetbiswas4423 5 ปีที่แล้ว +2

      I will love to see how to make social netwoking web side

    • @memoriesmaker9886
      @memoriesmaker9886 5 ปีที่แล้ว +1

      after writing python manage.py runserver
      at last syntax error is showing

    • @utsabbashyal7929
      @utsabbashyal7929 5 ปีที่แล้ว +2

      sir jab mera ko command 'python manage.py runserver' run karunga tab , Exception in thread django-main-thread: aah raha hei kya karu server start nahi hoo raha

    • @GaneshKumar-yg9wl
      @GaneshKumar-yg9wl 5 ปีที่แล้ว

      How u can add apps in settings.py file of main project????

    • @shreyanshmishra1685
      @shreyanshmishra1685 5 ปีที่แล้ว

      @@memoriesmaker9886 you might have forgotten to put a , after path

  • @harshitrajrocks
    @harshitrajrocks 5 ปีที่แล้ว +112

    Tried Udemy, Lynda and everything and was facing difficulty in even understanding simple things. By luck i came here and I am stuck here. So amazing quality content. You ARE UNDERRATED

    • @Christopher-ds1md
      @Christopher-ds1md 4 ปีที่แล้ว

      same here..truly amazing..

    • @gururaj2199
      @gururaj2199 4 ปีที่แล้ว +5

      I totally agree with you, I even bought a course on udemy
      that is .... that didn't teach you much, I hated that course

    • @gururaj2199
      @gururaj2199 4 ปีที่แล้ว +2

      I still do

    • @aryaman5106
      @aryaman5106 4 ปีที่แล้ว

      yea

    • @adityak3578
      @adityak3578 4 ปีที่แล้ว +2

      actually udemy is useless i learned a lotof things here..he need a aplause

  • @techsupport5637
    @techsupport5637 4 ปีที่แล้ว +11

    Def funtext(request):
    file = open('pathofthetext', 'r')
    Content = file.read()
    file.close()
    return httpresponse(content, content_type = 'text/plain')

  • @nothingwrong988
    @nothingwrong988 4 ปีที่แล้ว +105

    def index(request):
    file = open("1.txt",'r+')
    return HttpResponse(file.read()),
    This is a piece of code for the assignment task.

    • @filmystaanchannel4501
      @filmystaanchannel4501 4 ปีที่แล้ว +2

      bro r+ matlb?

    • @TariqAhmed_
      @TariqAhmed_ 4 ปีที่แล้ว +2

      @@filmystaanchannel4501 read and write both

    • @filmystaanchannel4501
      @filmystaanchannel4501 4 ปีที่แล้ว +1

      @@TariqAhmed_ thnx bro

    • @filmystaanchannel4501
      @filmystaanchannel4501 4 ปีที่แล้ว +2

      @@TariqAhmed_ par mene jab r+ nhi likha tab bhi chal rha hai code.

    • @TariqAhmed_
      @TariqAhmed_ 4 ปีที่แล้ว +1

      @@filmystaanchannel4501 han by default r hota hai.

  • @wajidshaikh9118
    @wajidshaikh9118 4 ปีที่แล้ว +10

    def index(request):
    with open('textutils/file.txt', 'r') as rm:
    return HttpResponse(rm.read())

  • @abrarfahim9744
    @abrarfahim9744 3 ปีที่แล้ว +3

    PycharmProjects\textutils>cd textutils
    than you enter to textutils....... thanks haarry bro

  • @rahulshukla5033
    @rahulshukla5033 5 ปีที่แล้ว +27

    from django.http import HttpResponse
    def index(request):
    with open("filepath/one.txt") as f:
    a = f.read()
    return HttpResponse(a)

    • @kartikverma380
      @kartikverma380 4 ปีที่แล้ว

      Import error is coming

    • @salmanali-bf4nk
      @salmanali-bf4nk 4 ปีที่แล้ว

      in my case no error is showing ....but still not displaying content in the server.

    • @rishabhsharma8030
      @rishabhsharma8030 4 ปีที่แล้ว +2

      @@salmanali-bf4nk first of all always specify filemode ----> with open("path_to_file",'r') as f: ------- and keep rest of the code same :) and make sure your file shares the same directory as that of manage.py

  • @starboy_jb
    @starboy_jb 5 ปีที่แล้ว +14

    I do your quiz by creating a text file and make a function name test in views file and then use file handling and do like
    def test(request):
    f1 = open("first.txt", "r")
    return HttpResponse(" %s " % (f1.read()))

    • @hardcode5394
      @hardcode5394 5 ปีที่แล้ว

      Thanks sir!🙏
      By the way sir, can u plz explain what is the purpose of % sign here? Hope u'll help me. Thanks once again.

    • @madhavaneja6573
      @madhavaneja6573 5 ปีที่แล้ว +1

      @@hardcode5394 docs.python.org/2/library/stdtypes.html#string-formatting-operations

    • @madhavaneja6573
      @madhavaneja6573 5 ปีที่แล้ว +2

      It is a way of string formatting.. OPen the abouve link and you'll definitely understand from example..

    • @hardcode5394
      @hardcode5394 5 ปีที่แล้ว

      Respected Mr. @@madhavaneja6573, thanks a lot for ur help.🙏

    • @munibshaikh4763
      @munibshaikh4763 5 ปีที่แล้ว +1

      Yar mera ek masla h solve kro ge to bari meherbani hogi aap ki 😄
      Sb kuch sahi h lekin file1.txt not found error araha ha wo txt file bhi wahin pr ha jahan views.py and urls.py ha

  • @notrudraxd
    @notrudraxd 3 ปีที่แล้ว +15

    def index(request):
    with open("1.txt", "r") as f: # Opening the file in read mode, we don't use r+ because file already exists, r+ is used when file doesn't exists then assigning it a variable named f
    content = f.read() # Reading the contents of the file and storing it in a variable, we use read instead of readlines because readlines gives each line as a list element
    return HttpResponse(content)

    • @pushkarpatil6123
      @pushkarpatil6123 ปีที่แล้ว

      This code where exactly we have to write ?

    • @ektapatil5574
      @ektapatil5574 7 หลายเดือนก่อน

      do we need to make file as 1.txt ?

    • @notrudraxd
      @notrudraxd 7 หลายเดือนก่อน

      @@ektapatil5574 yep, "r" mode reads an already existing file. So have "1.txt" in the directory with some content in it.

  • @ashishsingla4697
    @ashishsingla4697 3 ปีที่แล้ว +6

    9:45
    def index(request):
    with open('../1.txt') as file:
    data = file.read()
    return HttpResponse(data)

    • @arnavsaxena6080
      @arnavsaxena6080 ปีที่แล้ว

      can you explain me what is he trying to ask exactly?

  • @SahilKumar-rz3th
    @SahilKumar-rz3th 4 ปีที่แล้ว +11

    def goal(request):
    fp = open("sahilsite/one.txt","r")
    f = fp.read()
    fp.close()
    return HttpResponse(f)

    • @abhaykanwasi881
      @abhaykanwasi881 2 ปีที่แล้ว

      Thanks dude.. That's what I needed

  • @anshultripathi7121
    @anshultripathi7121 4 ปีที่แล้ว +1

    apke videoes and explaning ka tarika bhut hi majedar h ..keep on harry sir.

  • @anuragdewarde567
    @anuragdewarde567 ปีที่แล้ว +1

    def index(request):
    f=open("D:\\Django MA\\textutils\\textutils\\textutils\\info.txt")
    c = f.read()
    return HttpResponse(c)
    Harry bhai work done successfully.

  • @kunaldange7645
    @kunaldange7645 2 หลายเดือนก่อน

    i was stuck with view and url you explained it perfectly
    thankyou

  • @AatifRazaKagzi
    @AatifRazaKagzi 4 ปีที่แล้ว +1

    Bhai well Done bhai kyaa Explain karte hoo bhaiiii puraaa......no questions remaining to do google after watching your Videos

    • @shubhamsharma5549
      @shubhamsharma5549 4 ปีที่แล้ว

      Achha fir btao k dusre textiles tk kese pahuche

  • @pranavyeole102
    @pranavyeole102 3 ปีที่แล้ว

    thank you so much harry, tumhari excitement aur passion k bayehse ye sikhne mein aur bhi majha ata hai

  • @sandeepkumar-br9sm
    @sandeepkumar-br9sm 2 หลายเดือนก่อน

    added below in Index function and worked like charm
    def index(request):
    f = open(r'C:\Users\kumarsan\PycharmProjects\DjangoCourse\TestUtils\textutils\textutils\Homepage.txt', 'r')
    data = f.read()
    return HttpResponse(data)

  • @appschoolss
    @appschoolss 3 ปีที่แล้ว

    def index(request):
    with open("1.txt","r") as f:
    return HttpResponse(f)
    Assignment done harry bhai

  • @nischalbaligatti8638
    @nischalbaligatti8638 3 ปีที่แล้ว

    def index(request):
    f = open("locoStart/1.TXT")
    return HttpResponse(f.read())
    f.close()
    harry bhai big fan

  • @shrinivasbutla5093
    @shrinivasbutla5093 2 ปีที่แล้ว

    I did Harry Bro yours last query...iwill...iam excited to doing this query...🙏

  • @PeaceYourSoul
    @PeaceYourSoul ปีที่แล้ว

    Harry Vai, this helps me a lot. I solved this problem by watching this video.

  • @m.laxminarayanreddy
    @m.laxminarayanreddy ปีที่แล้ว

    from django.shortcuts import render , HttpResponse
    def temp(request):
    return render(request, file.txt)
    it may works !

  • @muhammadnajamulislam2823
    @muhammadnajamulislam2823 4 ปีที่แล้ว

    i used this method
    def file_content(request):
    file = "C:\\Najam\\Web developement course\\Django Course\\one.txt"
    with open(file, 'r', encoding='utf-8') as f:
    read = f.readlines()
    return HttpResponse(read)

  • @suleman8681
    @suleman8681 4 ปีที่แล้ว +1

    cannot find any directory
    plz guide brother
    by the way I have tried too many web sites and channels to learn django but here I found it...love your cotent

  • @rupeshbhosale3142
    @rupeshbhosale3142 4 ปีที่แล้ว +1

    views.py =
    def index():
    file = open('one.txt')
    fh = file.read()
    return HttpResponse(fh)

  • @arpitsoni9378
    @arpitsoni9378 5 ปีที่แล้ว +13

    First I created one.txt where manage.py located
    Then in views.py
    def file(request):
    with open('one.txt') as f:
    return HttpResponse(f.read())

    • @jaishivnani7768
      @jaishivnani7768 4 ปีที่แล้ว

      yes i also have to do the same giving file not found error in internal path

    • @amitmodh167
      @amitmodh167 4 ปีที่แล้ว

      File can be opened with " with statement" is the best way.. Good choice buddy

    • @emperorgaming97
      @emperorgaming97 4 ปีที่แล้ว

      tysm bro....it really helps me..

    • @suryaaytha7376
      @suryaaytha7376 4 ปีที่แล้ว

      I am not getting it .Can u please xplain clearly

  • @anaskhan4841
    @anaskhan4841 3 ปีที่แล้ว

    You are best Teacher Harry Bhai

  • @anujmore7547
    @anujmore7547 4 ปีที่แล้ว

    from django.http import HttpResponse
    def rf(response):
    with open("filepath/one.txt") as f:
    f1 = f.read()
    return HttpResponse(f1)

  • @arunshet
    @arunshet 7 หลายเดือนก่อน +1

    we are going to raise the bar

  • @sumanghorui5502
    @sumanghorui5502 5 ปีที่แล้ว +6

    Wow 👍 I'm very excited for next video. because every day i learn something new. Good job Harry bhai :)

  • @arkodeepray6730
    @arkodeepray6730 3 ปีที่แล้ว +1

    We can read the txt file as text and store it as a string and we can use return HttpResponce with that string in our views.index function

    • @shubham6523
      @shubham6523 3 ปีที่แล้ว

      Bruh
      Mere pycharm me Ctrl + S press krne pr new development server generate nhi hora plz bataeya ke kese karu .
      Mee Kae bar try kr Chuka

    • @Ramesh-mg8fg
      @Ramesh-mg8fg 3 ปีที่แล้ว

      @@shubham6523 ctrl+s urls wale file me karne ke baad reload karo....agar ab bhi nahi hora to extensions install karo

  • @sourav1632
    @sourav1632 5 ปีที่แล้ว

    samaj aa raha hai dhere dhere, Thanks Harray Bhaii

  • @ACHTech20
    @ACHTech20 5 ปีที่แล้ว +1

    I have done the exercise by making a simple function using with open block and read the text file and save it in a variable and return it as a http response

  • @faizmohammad8079
    @faizmohammad8079 5 ปีที่แล้ว

    Bhai ... Seriously..you have awsm.. teaching skills..

  • @HariomSingh-ei4fb
    @HariomSingh-ei4fb 2 ปีที่แล้ว +1

    The way of explaination is from completely beginners to extremely advanced
    Thanks a lot Harry bhaii😎

  • @arz5944
    @arz5944 ปีที่แล้ว

    Thank you Harry Bhai - very simple and easy videos!

  • @mayuricodehub
    @mayuricodehub 2 ปีที่แล้ว

    Harry Bhai successfully run ho Gaya , thank uh so much!

  • @dipanshparmar3769
    @dipanshparmar3769 5 ปีที่แล้ว

    sol:
    def index(request):
    try:
    f = open('name.txt', 'w')
    f.write('Hello World, how are you?')
    except Exception as e:
    print(e)
    try:
    f = open('name.txt', 'r')
    return HttpResponse(f.read())
    except Exception as e:
    print(e)

  • @clashcloud5720
    @clashcloud5720 4 ปีที่แล้ว +4

    def txtfile(request):
    with open("1.txt", "r") as f:
    return HttpResponse(f.read())

  • @muhammednkazi
    @muhammednkazi 4 ปีที่แล้ว

    from django.http import HttpResponse
    def index(request):
    f=open("textutils/1.txt")
    filecontent=f.read()
    return HttpResponse(filecontent)

  • @bhavyakohli6212
    @bhavyakohli6212 4 ปีที่แล้ว

    from django.http import HttpResponse
    def index(request):
    with open("filepath/one.txt",'r') as f:
    var = f.read()
    return HttpResponse(var)

  • @rajmore4222
    @rajmore4222 ปีที่แล้ว

    hoooooooooo gaya
    learnt is first time without errors
    thanks bro

  • @NavneetaSinha
    @NavneetaSinha ปีที่แล้ว

    You are amazing at explaining

  • @themuslimview
    @themuslimview ปีที่แล้ว

    I was able to complete your assignment using Path from pathlib and read the txt file stored in the same folder and manage,py and then passing the string into the return HTTPResponse function

  • @bismeetsingh352
    @bismeetsingh352 5 ปีที่แล้ว +6

    def index(request):
    file=open("terms.txt",'r')
    return HttpResponse(file.readlines())

    • @MrRahul15937
      @MrRahul15937 5 ปีที่แล้ว

      Can also use
      with open

  • @macstocktech
    @macstocktech 4 ปีที่แล้ว +2

    If Anyone Want to Set Color Scheme Like Harry Bhai, then You Should Change Color Scheme to Monokai

  • @harshdurgude9900
    @harshdurgude9900 3 ปีที่แล้ว

    quiz ans = i will use open() to read file content and use that content in
    Httpresponse

  • @varunkrishnaKyathanpally
    @varunkrishnaKyathanpally 5 ปีที่แล้ว

    from django.http import HttpResponse
    def display_file():
    with open('abc.txt') as f:
    for i in f:
    return (i)
    def index(request):
    return HttpResponse(display_file())
    def about(request):
    return HttpResponse("about myself abc")

  • @irfanmohammad2132
    @irfanmohammad2132 9 หลายเดือนก่อน

    def index(request):
    f = open('textutils/1.txt', 'r')
    contents = f.read()
    return HttpResponse(contents)

  • @yogeshmittal2079
    @yogeshmittal2079 5 ปีที่แล้ว +2

    Bhai phle file open krenge read mode m uske bad read krenge
    Aur store krayenge variable m
    Fir pass kr denge httpresponse m

  • @ShahidQureshi-ee6wz
    @ShahidQureshi-ee6wz 2 ปีที่แล้ว

    one of the besxt series

  • @omsaimohapatra8171
    @omsaimohapatra8171 3 ปีที่แล้ว

    exercise ka ans-
    views wale file mein:
    def text(request):
    readfile = open('test.txt')
    areaded = readfile.readlines()
    return HttpResponse(areaded)
    aur urls wale file mein:
    path('text/', views.text, name='text')

  • @aniketshukla2767
    @aniketshukla2767 4 ปีที่แล้ว +3

    Texutils directory ke andhar ek aur directory kaise banaaya aapne
    Harry bhai plzzz explain

  • @emperorgaming97
    @emperorgaming97 4 ปีที่แล้ว

    def index(request):
    with open("one.txt") as f:
    return HttpResponse(f.read())

  • @shivanibalotra
    @shivanibalotra 4 ปีที่แล้ว +2

    Def view (request):
    File=open("io.txt",'r')
    return HttpResponse(file.readlines())
    Url patterns=[
    path(' ',io )
    ]

    • @nishantkumarjha7852
      @nishantkumarjha7852 4 ปีที่แล้ว

      I have some problem while executing. Can you help me so

  • @yashvarshneycreativities9888
    @yashvarshneycreativities9888 3 ปีที่แล้ว

    Very Nicely Explain Harte ho!
    Hands off!

  • @Studywithayaz1
    @Studywithayaz1 ปีที่แล้ว

    You ARE UNDERRATED

  • @shubhamkumarbatham4370
    @shubhamkumarbatham4370 3 ปีที่แล้ว +1

    def file(requet):
    with open('one.txt','w') as f:
    f.write("This is file content")
    with open("one.txt") as f:
    return HttpResponse(f.read())
    path('', vfir.file, name='file')

  • @AsadKhan-cw6ue
    @AsadKhan-cw6ue 3 ปีที่แล้ว

    def info(request):
    file = open('filepath', 'r+')
    Content= file.read()
    return HttpResponse(Content, content_type='text/plain')

    • @shubham6523
      @shubham6523 3 ปีที่แล้ว

      Bruh
      Mere pycharm me Ctrl + S press krne pr new development server generate nhi hora plz bataeya ke kese karu .
      Mee Kae bar try kr Chuka hu

  • @pande2600
    @pande2600 3 ปีที่แล้ว

    harry bhai django tutorial very good

  • @Allround-17
    @Allround-17 4 ปีที่แล้ว +5

    Harry bhai aap textutils ke andar dusri text utils par kaise aaye

    • @akshaydadwal6716
      @akshaydadwal6716 3 ปีที่แล้ว +1

      han bhai samaj nhi aya muje b

    • @namanjain943
      @namanjain943 ปีที่แล้ว

      Bro type { cd .\textutils\ } then enter

  • @_TechTraverse
    @_TechTraverse 2 ปีที่แล้ว

    thank you so much harry. I loved every course of yours.

  • @azharkhansaqi
    @azharkhansaqi ปีที่แล้ว

    my inspiration sir love you

  • @Grawish
    @Grawish 4 ปีที่แล้ว

    def index(request):
    f = open("1.txt", "r")
    f1 = f.readlines()
    y = ""
    for x in f1:
    y += x
    return HttpResponse(y)

  • @mansigupta4673
    @mansigupta4673 3 ปีที่แล้ว

    You teach so well bro....god bless you

  • @hrutikdhumal402
    @hrutikdhumal402 4 ปีที่แล้ว

    Bhai OP sikhata he tu ♥️♥️♥️....

  • @AryanGupta-ft5mp
    @AryanGupta-ft5mp 4 ปีที่แล้ว

    First we will open it in read mode with "open" function and read the content with read function and then return it in html response....

  • @shreyasd99
    @shreyasd99 4 ปีที่แล้ว

    from django.http import HttpResponse
    def index(request):
    fh=open('mywebsite/1.txt')
    return HttpResponse(fh.read())

  • @sunildhakad833
    @sunildhakad833 4 ปีที่แล้ว +1

    Hi herry,
    1. Need to creat a file name one.py in current directory
    2. Import that file in our urls.py
    3.create one function inside the one.py file
    4 . Save the program and the browser

  • @NitishKumar-xr9tx
    @NitishKumar-xr9tx 11 หลายเดือนก่อน

    ASSIGNMENT Solution :
    def text(request):
    f = open('./textutils/one.txt', 'r')
    file_content = f.read()
    f.close()
    return HttpResponse(file_content, content_type="text/plain")

  • @joelthomas8617
    @joelthomas8617 2 ปีที่แล้ว

    import os
    def file_opening(request):
    module_dir = os.path.dirname(__file__)
    file_path = os.path.join(module_dir, '1.txt') #full path to text.
    data_file = open(file_path , 'r')
    data = data_file.read()
    # context = {'rooms': data}
    return HttpResponse(data)
    This may help you

  • @payalkukreja8150
    @payalkukreja8150 3 ปีที่แล้ว

    def index(request):
    file = open('one.txt','r')
    return HttpResponse(file.read())

  • @shashikantbharti3157
    @shashikantbharti3157 5 ปีที่แล้ว

    You are Good Trainer Thanks For Making such tutorials

  • @divyanshdimri8567
    @divyanshdimri8567 4 ปีที่แล้ว

    bhaai dil se shukriya ❣️

  • @PrabalTiwarii
    @PrabalTiwarii 5 ปีที่แล้ว +5

    Sorry for delay thoda bahar chala gya tha. The approach will be to open the file first using open() method then read the contents of the file and save to a variable like content = f.read() then simply pass this content variable into the HttpResponse() method to display the actual content of the file. I tried with HTML code and it worked unexpectedly really well.

    • @pushkarpatil6123
      @pushkarpatil6123 ปีที่แล้ว

      Hi Can you tell me the deailed answer of the quiz because its confusing me?
      Im very new to it and i dont know the where i have to write this

  • @5adishapatil231
    @5adishapatil231 4 ปีที่แล้ว +1

    path('about', views.about, name ='about')
    ^
    SyntaxError: invalid syntax

  • @mayanksomani9226
    @mayanksomani9226 5 ปีที่แล้ว

    Def file1(request):
    Test=open("hello.txt","r+")
    return Http response(test.read())
    test.close()

  • @azharkhansaqi
    @azharkhansaqi ปีที่แล้ว

    iam form Pakistan big fan sir love you

  • @rogerthat2938
    @rogerthat2938 5 ปีที่แล้ว +1

    you always needs thumbs UP dude

  • @mayankkashyap253
    @mayankkashyap253 4 ปีที่แล้ว

    Harry sir you are the best🙏

  • @bitulbishnub1473
    @bitulbishnub1473 4 ปีที่แล้ว

    Harry Bhai?
    Thank you... many many many Thank you

  • @hirenmodhvadia
    @hirenmodhvadia 5 ปีที่แล้ว

    Read data from file,
    def index(request):
    file = open('1.txt', 'r')
    content = file.read()
    file.close()
    return HttpResponse(content)

    • @rajpanchal2169
      @rajpanchal2169 5 ปีที่แล้ว

      bhai muje .. bataoge ..
      muje samaj nai aaya..
      muje Question hi samaj nai aaya pls help

  • @BhagatBhutale..
    @BhagatBhutale.. ปีที่แล้ว

    I Love you Harry...❤❤❤

  • @shubhamsharma4336
    @shubhamsharma4336 2 ปีที่แล้ว +4

    bhai textutills k andar textutills file ko open karne k liye kya command hogi .becasuse jab m manage.py runserver kar rha hu to error aa rhah

  • @shubhimanocha2620
    @shubhimanocha2620 3 ปีที่แล้ว

    def about(request):
    txt_file=open(r"D:\Django_Project\project1\project1\1.txt",'r')
    data=txt_file.read()
    return HttpResponse(data)

  • @sangamchaurasiya6870
    @sangamchaurasiya6870 3 ปีที่แล้ว

    def index(request):
    try:
    with open('1.txt', 'r+') as f:
    data = f.read()
    except Exception:
    data = 'File is not present in the given directory'
    return HttpResponse(data)

  • @GrimSol
    @GrimSol 2 ปีที่แล้ว +1

    def index(request):
    path = r"C:\Users\Asus\PycharmProjects\DjangoCourse\mysite\mysite\1.txt"
    file = open(path, "r")
    return HttpResponse(file.read())

  • @ihtashamnoor
    @ihtashamnoor 4 ปีที่แล้ว

    Superb, simply wonderful... hats off to you, boy. keep it up.

  • @Pharma_Insights01
    @Pharma_Insights01 2 ปีที่แล้ว

    Write in urls file this:
    from . import txt, txt (Just below from statements)
    path('', txt.index, name='1.txt')(Just below path statements)
    Then write in txt file:
    from django.http import HttpResponse
    def index(request):
    return HttpResponse("AVIK MAHESHWARI")

  • @B_IKRAM
    @B_IKRAM 5 ปีที่แล้ว

    Thanks...... Best youtuber

  • @malleshbmashetty4601
    @malleshbmashetty4601 2 ปีที่แล้ว

    def index(request):
    with open('fun.txt','r') as f:
    return HttpResponse(f.read())

  • @rinkuu1111
    @rinkuu1111 4 ปีที่แล้ว +1

    def index(request)
    file= open("1.txt"," ")
    return HttpResponse(file.read())

    • @felix-ej9in
      @felix-ej9in 4 ปีที่แล้ว

      FileNotFoundError at /

  • @jaweriahussainpanhwar5460
    @jaweriahussainpanhwar5460 2 ปีที่แล้ว +1

    def web_doc(request):
    f = open('mysite/hello.txt')
    content = f.read()
    return HttpResponse(content)

  • @punittiwari7557
    @punittiwari7557 5 ปีที่แล้ว +2

    def read():
    with open("read.txt",'r') as f:
    File=f.read()
    return HttpResponse(File)

    • @tanishaagnihotri4954
      @tanishaagnihotri4954 3 ปีที่แล้ว

      I have save 1.txt inside the project even showing error file not found

    • @punittiwari7557
      @punittiwari7557 3 ปีที่แล้ว

      @@tanishaagnihotri4954 you should check the path of the file or show the error you are facing...

    • @tanishaagnihotri4954
      @tanishaagnihotri4954 3 ปีที่แล้ว +1

      @@punittiwari7557 thanks know its working

  • @lohithg.n.5544
    @lohithg.n.5544 4 ปีที่แล้ว

    def about(request):
    import os
    file_path =os.path.join(os.getcwd(), "_one.txt")
    with open(file_path) as f:
    op = f.read()
    return HttpResponse(op)

  • @pulkitsharma4003
    @pulkitsharma4003 4 ปีที่แล้ว

    def index(request):
    f=open('one.txt','r')
    text=''"
    for i in f:
    text=text+i
    return HttpResponse(text)

  • @purushottamprabhakar5397
    @purushottamprabhakar5397 5 ปีที่แล้ว

    i thin we have to implement file handling concept of python eg: OPEN FILE using open() method then it should be read the content so matter=read() after that we can pass it in HttpResponse(matter) may be its work but am not sure.

  • @naveenagrawal_nice
    @naveenagrawal_nice 5 ปีที่แล้ว +2

    Exception Value:
    [Errno 2] No such file or directory: 'first.txt'

    • @BrighterWay
      @BrighterWay 5 ปีที่แล้ว +1

      Use f = open('current-folder/1.text', 'r')
      And in return HttpResponse(f.read())

    • @naveenagrawal_nice
      @naveenagrawal_nice 5 ปีที่แล้ว

      @@BrighterWay will try it thanks buddy

    • @muhammadilyas2179
      @muhammadilyas2179 4 ปีที่แล้ว

      @@BrighterWay great

  • @gopalchaudhary6170
    @gopalchaudhary6170 2 ปีที่แล้ว

    Outstanding explanation 😍

  • @abduksam
    @abduksam 4 ปีที่แล้ว +1

    create a static folder and create a .txt file and enter the path of the file and type /static/filename.txt and I would display it