How to Receive Data From a Django Form Using a POST Request (Django Tutorial) | Part 46

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ส.ค. 2024
  • Enjoyed my video? Leave a like!
    GitHub Link: github.com/max...
    Personal Website: maxgoodridge.com

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

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

    Love your manner of explanation, Max! Thank you.

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

    These videos have been very helpful with forms. Thanks!

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

    For anyone getting an error "local variable 'text' referenced before assignment", in my case the response in console showed:
    "GET /create/ HTTP/1.1" 500 63600
    where create is the viewmethod, called after clicking on url bar and pressing enter.
    To avoid this error I added the form field argument required=False

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

    WENA GASPARIN Y LA CTM ME RE FUNCIONO, TE GANASTE UN LIKE

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

    Sir you have saved me 10hrs of work. Subscribing now! Thank you

  • @Arsenico13
    @Arsenico13 6 ปีที่แล้ว

    Thank you, Max. Very clear explanation.

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

    I'm using postman to test my app. From there using form-data I will enter key one name and mention type is file. Values I will upload a file. How to get that key and value in the django app to perform operations on that file and resend the JSON response of that operation output.

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

    You look like *Jordi El Nino*

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

    For anybody getting that error involving 'text referenced before assignment', my issue was that my form was not passing the form.is_valid() conditional. What I did to fix it was get rid of my normal html form, and defined all the fields in the forms.py homeform class. Then, used {{ form.as_p }}. Hope this solves any problems.

  • @EatMyApplez
    @EatMyApplez 6 ปีที่แล้ว

    Thanks so much Max, love your explanations

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

    in my case case page refreshes but the text doesn't display in the h2 tag..I don't what is the problem..???

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

    thanks panita

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

    I'm getting an Error 》 local variable 'text' refrenced before assignment. ;-;

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

      Same ! How to fix this error ?

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

      ​@@yashgupte5425 Maybe you forgot this: form = HomeForm(request.POST)

  • @SC-su7lc
    @SC-su7lc 4 ปีที่แล้ว

    how to hidden values pass-through post to get

  • @Omkar-pj1vv
    @Omkar-pj1vv 3 ปีที่แล้ว

    I downloaded ur django tutorials code but while running it showing an error
    commandError: you must set settings.ALLOWED_HOST if DEBUG is False

  • @isabel4774
    @isabel4774 6 ปีที่แล้ว

    what if I wanted to create a form quiz in Django. So there is a multiple choice question and Django remembers the selection that the person chose and acts accordingly. the action would be different depending on the choice that the person chose. How would I implement this feature/function? Thanks!

  • @princenihith1175
    @princenihith1175 6 ปีที่แล้ว

    how can i show post created only by logged in user

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

    how can I hide label "Post" next to form field?

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

    I get "local variable 'text' referenced before assignment"

    • @shivamlakhwara5080
      @shivamlakhwara5080 6 ปีที่แล้ว

      same is happening with me any clues? Anyone ?

    • @shivamlakhwara5080
      @shivamlakhwara5080 6 ปีที่แล้ว

      hey i fixed it i had forgot to enter args into the parameters for the render method
      return render(request,self.template_name,args)

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

      @Daugirdas Kuprionis thanks you

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

      @@shivamlakhwara5080 it wont still work :(

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

      Same. How to fix this error ?

  • @armanigiles4953
    @armanigiles4953 7 ปีที่แล้ว

    You are the man!!!

  • @rahulsen-np8pq
    @rahulsen-np8pq 4 ปีที่แล้ว

    Nice bro 👍

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

    how yo display on the another page ?

  • @gourbera4635
    @gourbera4635 6 ปีที่แล้ว

    how can I call a function on submitting the form?

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

    NoReverseMatch at /home/ ? Send help.

  • @mrpmac
    @mrpmac 6 ปีที่แล้ว

    He didn't explain how it routes to the post method instead of the get method. When I submit the form, it just goes back to get. Frustrating. Any help?

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

      Ahhhh. I got it. In my urls.py, i needed to reference the as_view() method:
      url(r'^$', views.HomeView.as_view())

  • @sranstankovic233
    @sranstankovic233 6 ปีที่แล้ว

    Is there way to handle HttpResponse returned by post form ?

  • @ricardochirinos1382
    @ricardochirinos1382 6 ปีที่แล้ว

    Every time I refresh the page the Terminal says "GET" instead of "POST". What happen?

    • @headlikeahole6548
      @headlikeahole6548 6 ปีที่แล้ว

      Did you add tag to your html template? Does it look like this?
      Home
      {% csrf_token %}
      {{ form.as_p }}
      Submit
      {{ text }}

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

    How can I remove that 'Post' word before my form?

    • @marcushines1760
      @marcushines1760 7 ปีที่แล้ว

      Change the name of the variable. The html label will reflect whatever you named the variable in Python.

    • @aronkoppes3089
      @aronkoppes3089 6 ปีที่แล้ว

      In css type: form label {display: none;}

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

      You can also handle the form without using Django Form

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

    django get form data in dict type

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

    Can you send your urls.py file? When I put on my url it shows that it is not found as it is a correct one. Thanks in advance

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

    show the url.py I got the error __init__() takes 1 positional argument but 2 were given

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

      you must have wrong path in urls.py. I changed mine and it works

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

      show me ur urls.py code

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

      dude, u need to add .as_view() to your urlpatterns in urls.py. wish it helps

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

    そして、頑張った先が子作りだったの草

  • @DREADL
    @DREADL 7 ปีที่แล้ว

    Hey , could you do a python with sql tutorial ?

    • @scootndute579
      @scootndute579 6 ปีที่แล้ว

      um, next video... like part 47 ... OMG

  • @santoshpaul6443
    @santoshpaul6443 6 ปีที่แล้ว

    how do I go on to create a post code if I have multiple forms.
    GET REQUEST.
    def get(self, request):
    template_name = 'technology_list.html'
    context = {
    'aws': AwsuserForm(),
    'box': BoxuserForm(),
    'dropbox': DropboxuserFor() }
    return render(request, template_name, context).
    any suggestions???

    • @santoshpaul6443
      @santoshpaul6443 6 ปีที่แล้ว

      that's a nice way... I couldn't find a solution so I created a POST function to every single form.

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

    Max, I like your beatiful eyes! :)

  • @vineethsai1575
    @vineethsai1575 6 ปีที่แล้ว

    cleaned_data isn't even a method. It is a dictionary :/ When you call is_valid( ) on a form there are bunch of triggers that fill out the cleaned_data dictionary.
    maybe you should keep an annotation @MaxGoodridge