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
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.
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.
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!
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???
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
Love your manner of explanation, Max! Thank you.
These videos have been very helpful with forms. Thanks!
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
WENA GASPARIN Y LA CTM ME RE FUNCIONO, TE GANASTE UN LIKE
Sir you have saved me 10hrs of work. Subscribing now! Thank you
Thank you, Max. Very clear explanation.
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.
You look like *Jordi El Nino*
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.
Thanks so much Max, love your explanations
in my case case page refreshes but the text doesn't display in the h2 tag..I don't what is the problem..???
thanks panita
I'm getting an Error 》 local variable 'text' refrenced before assignment. ;-;
Same ! How to fix this error ?
@@yashgupte5425 Maybe you forgot this: form = HomeForm(request.POST)
how to hidden values pass-through post to get
I downloaded ur django tutorials code but while running it showing an error
commandError: you must set settings.ALLOWED_HOST if DEBUG is False
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!
how can i show post created only by logged in user
how can I hide label "Post" next to form field?
I get "local variable 'text' referenced before assignment"
same is happening with me any clues? Anyone ?
hey i fixed it i had forgot to enter args into the parameters for the render method
return render(request,self.template_name,args)
@Daugirdas Kuprionis thanks you
@@shivamlakhwara5080 it wont still work :(
Same. How to fix this error ?
You are the man!!!
Nice bro 👍
how yo display on the another page ?
how can I call a function on submitting the form?
NoReverseMatch at /home/ ? Send help.
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?
Ahhhh. I got it. In my urls.py, i needed to reference the as_view() method:
url(r'^$', views.HomeView.as_view())
Is there way to handle HttpResponse returned by post form ?
Every time I refresh the page the Terminal says "GET" instead of "POST". What happen?
Did you add tag to your html template? Does it look like this?
Home
{% csrf_token %}
{{ form.as_p }}
Submit
{{ text }}
How can I remove that 'Post' word before my form?
Change the name of the variable. The html label will reflect whatever you named the variable in Python.
In css type: form label {display: none;}
You can also handle the form without using Django Form
django get form data in dict type
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
show the url.py I got the error __init__() takes 1 positional argument but 2 were given
you must have wrong path in urls.py. I changed mine and it works
show me ur urls.py code
dude, u need to add .as_view() to your urlpatterns in urls.py. wish it helps
そして、頑張った先が子作りだったの草
Hey , could you do a python with sql tutorial ?
um, next video... like part 47 ... OMG
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???
that's a nice way... I couldn't find a solution so I created a POST function to every single form.
Max, I like your beatiful eyes! :)
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