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

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2025

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

  • @CodeWithHarry
    @CodeWithHarry  6 ปีที่แล้ว +84

    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 6 ปีที่แล้ว +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 ปีที่แล้ว +113

    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 5 ปีที่แล้ว +108

    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())

  • @starboy_jb
    @starboy_jb 6 ปีที่แล้ว +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

  • @ashishsingla4697
    @ashishsingla4697 4 ปีที่แล้ว +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?

  • @rahulshukla5033
    @rahulshukla5033 6 ปีที่แล้ว +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

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

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

  • @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 2 ปีที่แล้ว

      This code where exactly we have to write ?

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

      do we need to make file as 1.txt ?

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

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

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

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

  • @AatifRazaKagzi
    @AatifRazaKagzi 5 ปีที่แล้ว +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

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

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

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

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

  • @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 4 หลายเดือนก่อน

    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)

  • @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

  • @anuragdewarde567
    @anuragdewarde567 2 ปีที่แล้ว +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.

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

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

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

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

  • @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

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

    You are best Teacher Harry Bhai

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

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

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

    samaj aa raha hai dhere dhere, Thanks Harray Bhaii

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

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

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

    Thank you Harry Bhai - very simple and easy videos!

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

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

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

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

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

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

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

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

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

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

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

    You are amazing at explaining

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

    hoooooooooo gaya
    learnt is first time without errors
    thanks bro

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

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

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

    Very Nicely Explain Harte ho!
    Hands off!

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

    bhaai dil se shukriya ❣️

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

    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)

  • @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

  • @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

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

    one of the besxt series

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

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

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

    my inspiration sir love you

  • @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

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

    you always needs thumbs UP dude

  • @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

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

    I Love you Harry...❤❤❤

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

    Thanks...... Best youtuber

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

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

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

    You ARE UNDERRATED

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

    harry bhai django tutorial very good

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

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

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

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

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

    Harry sir you are the best🙏

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

    When I did the whole process following you but I didn't get textutils two times in terminal and you cut that part in the video please tell me how you did it?

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

      If you are in first text utils then simply type ' cd textutils ' in the terminal. This will take you to the required directory. Now you can type ' python manage.py runserver ' to start the server. I hope this helps. If not then you're welcome.

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

      Thanks

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

      @@tusharkadam7471 thanks alot bro

  • @AkashRaj-if6di
    @AkashRaj-if6di 5 ปีที่แล้ว +2

    Harry bhai it's not working for me??
    I import
    from . import views
    Add path
    path(' '), views.index, name='index')
    And whatever you do in views. Py file,same I do in views. Py file but it's not gives any output in server

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

      hey bro, have you got the answer ? because i also face problem !!!

    • @AkashRaj-if6di
      @AkashRaj-if6di 4 ปีที่แล้ว

      @@iamaniketkr yes i got it

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

      @@AkashRaj-if6di whats thE solution

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

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

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

    i got error when ever i add another section like harry add about then I got error like can't reach file 127.0.0 refused to connect. please help me harry sir.

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

      use Comma( , ) before path like ,path('about',views.about,name='about')

  • @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)

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

    i'm having one issue. i'm running the same steps as shown in the video but hello is not printing. it is always showing the django admin page. what can I do?

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

      The same people occurred to me, after saving your work, try resorting your computer and opening Pycharm again, when the same prob occurs to me i gave up & then after a few days, I opened my project, reloaded (by saving), it worked for me

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

      hahaha ye to jaadu ho gya

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

      @@ladydimitrescu1155 did you get the solution for this? why did this problem occur? we need a quick solution for this.

    • @AryanYadav-wz1dv
      @AryanYadav-wz1dv 4 ปีที่แล้ว +1

      @@ananyavats6914 i am also getting the same problem. may be there is some changes in updated 3.0 version due to which we are getting this problem.

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

      You should restart your PC, I also faced such problem, when I restart my PC, it solved

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

    we are going to raise the bar

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

    Sir I have a problem occurs in our file is C:/New folder/37/python.exe: can't open file 'C://Users//abc//textutilise//manage.py': [Error 2] No such file or directory

    • @060_zeetukumar2
      @060_zeetukumar2 2 ปีที่แล้ว

      cd textutilise
      After that....
      python manage.py runserver

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

    hy I am not getting this hello printing in my website it is only showing that default website of django please tell me why

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

      Close your windows powershell and then try from pycharm terminal

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

    Hi, i am facing a problem while running server. when i save the code then i click on refresh but code is not working. only it shows first screen of congrats! message. plz help to fix it.

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

    Outstanding explanation 😍

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

    Maza aa gya Harry Bhai...

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

    You are Good Trainer Thanks For Making such tutorials

  • @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

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

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

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

    Great Start

  • @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)

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

    superb harry bro..👌

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

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

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

    *Sir me jab **manage.py** ka server run karta hun to wo run ho jata hai.. uske bad agar mene code me koi glti kardi to or browser pe reload kiya to "error loading page" ata hai or phir server chalta he nahi hai.. cmd ko restart kar k server chalana prta hai. Or sir na about ka page open ho raha hai or na home page pe code change karny se changing aarahi*

  • @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

  • @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

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

    Thanks Buddy😘😘

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

    Can anyone help me (Harry bhai aapne text utils ke andar text utils kaisr gaye

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

      i have the same question. how to go to textutils inside the textutils

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

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

  • @AbhinavSharma-dn9zh
    @AbhinavSharma-dn9zh 4 ปีที่แล้ว

    The video got cut @ 1:52. We're facing a problem because of that. I've got stuck here for 2 days. please resolve.

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

      I am having same problems.. anyone please please help me??

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

      I am having same problems.. anyone please please help me??

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

    Good job herry

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

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

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

      Can also use
      with open

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

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

  • @RishiKumar-ex8nl
    @RishiKumar-ex8nl 4 ปีที่แล้ว +1

    My code is running fine and i am also getting the correct output in the browser but my terminal shows 7-8 errors after closing/minimizing the browser.
    Is it only me or others are getting the same errors too??

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

    How to get inside your current file using the terminal? I am not able to go to manage.py because I am not able to get into the right file, can anyone help me, please?

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

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

  • @NitishKumar-xr9tx
    @NitishKumar-xr9tx ปีที่แล้ว

    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")

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

    1:55 how did you get inside the textutils directory

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

      Brother use cd textutiles correctly it will be run perfectly.

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

      @@yashchetwani2891 thanks

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

    Harry bhai, all code are same but its giving this error-ImportError: cannot import name 'views'.....where is the problem.

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

    Nice 👍👏😊

  • @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")

  • @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')

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

    Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
    admin/
    The current path, about, didn't match any of these.

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

      I got the same error,how did it solved?

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

    bhai 5:52 pe mere webpage pe koi text reflect nai ho ra h, same rocket bani hui h, any suggestions?

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

      Close the powershell or cmd and run in pycharm terminal

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

    Awesome tutorial sirji

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

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

  • @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')

  • @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....

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

    iam form Pakistan big fan sir love you

  • @PrabalTiwarii
    @PrabalTiwarii 6 ปีที่แล้ว +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 2 ปีที่แล้ว

      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

  • @preethamm.n1161
    @preethamm.n1161 4 ปีที่แล้ว

    Awesome bro 🌹