Anders (izzno / gooood) 🇳🇴
You should learn the basics before moving in to frameworks ;). I can see you should work on your python syntax as well ;). Luckilly , python / js are forgiving languages.
Anders (izzno / gooood) 🇳🇴
anyway you need to wrap it in script tags at the bottom of your <body>, let me know if it works ;)
Anders (izzno / gooood) 🇳🇴
all the JS must be inside <script> CODE HERE </script>
Anders (izzno / gooood) 🇳🇴
and comment out your cpde.
Ashik
How we integrate js with django
007
Yes... My js is already inside script tag
Mirco
all the JS must be inside <script> CODE HERE </script>
I like more to move all js into a file More organized imho Related to a scope obviously
Anders (izzno / gooood) 🇳🇴
and with that I end my day with a favorit quote: "You have what you need daniel jackson, I suggest you act on it" ...
Anders (izzno / gooood) 🇳🇴
I like more to move all js into a file More organized imho Related to a scope obviously
yes, but theres so many things not "correct" in this code I did not think it mattered ;)
007
yes, but theres so many things not "correct" in this code I did not think it mattered ;)
Ok... I'll check it again.. and thank you once again 😄😄
Anders (izzno / gooood) 🇳🇴
Kaushal But for the record Mirco is correct, better to <script src=FILE .... your JS ;)
Anders (izzno / gooood) 🇳🇴
Ok... I'll check it again.. and thank you once again 😄😄
Np, I just did this so I could repeat for my self so it might stick better ;).
007
✌️✌️✌️
Anonymous
Turtle_In_Hurry
hey im working with celery anyone know how to invoke another task from within a running task
Anonymous
You can check the same with flower UI
Turtle_In_Hurry
No i don't want to monitor tasks
Turtle_In_Hurry
i have set of function calling each other
Perumal
Depends what you mean... You couild run them in a docker stack...
I had done one use case in Django and another use case in flask ...both integrated is possible
Perumal
??
cj
I had done one use case in Django and another use case in flask ...both integrated is possible
I'm pretty sure you can cover both use cases with only one of the frameworks
Perumal
Ok
Player
Hello! Django noob here. If I try to validate a form with is_valid(), do I need to use get_cleaned_data() as well? I read the docs and it says is_valid() executes 3 types of cleaning methods. I just want to make sure...
Puranjay
Hy everyone
Puranjay
I have just started learning django..I have a doubt.
Puranjay
How to link the html input fields with the model?
Puranjay
Somewhere I read that the value of "name" attribute should be same as that of model column names. Is it right?
007
"name" attribute of input field **
Call the Input field name attribute to views.py through request.method
Puranjay
https://drive.google.com/open?id=1Voj3a0MlkUZ6_E1gaWG5CbDDpaEYq4Oi
Puranjay
Kaushal can you tell whether I have done right in above 3 files or not?
007
do you want to store user data inti DB ?
Puranjay
do you want to store user data inti DB ?
yes...it's just a signup form
007
Show me your views.py
sravan
Somewhere I read that the value of "name" attribute should be same as that of model column names. Is it right?
You can get the value of the html form if give the name of the django form field and html field attribute "name" same...you make form validation also in form.py or you can get the value of the form in view.py through request.POST["name"]
Puranjay
Show me your views.py
uploaded in the drive link
007
form=userform() if request.method=="POST": form=userform(request.POST) if form.is_valid(): form.save()
007
return render(request,'app/form.html',context={'form':form})
007
index.html :- {{form.as_p}}
Puranjay
return render(request,'app/form.html',context={'form':form})
{{form.as_p}} should be the first line of form tag?
Puranjay
and should I also give the form name in form tag or is it not required?
007
<form action="{% url 'your_url' %}" method="POST"> {% csrf_token %} {{ form.as_p }} </form>
Puranjay
Also when I remove the "name" attribute from one of the input field, then also the data was been sent to the model for that field..how's that possible?
Puranjay
because model and input fields are linked to each other via name attribute only.
007
If you use normal custom form that time request.POST.get(' input-field-name ')
Puranjay
But with input fields "name" attribute is mandatory ?
007
But with input fields "name" attribute is mandatory ?
Only when you create your custom form.
Puranjay
Only when you create your custom form.
In the above drive files I have created my custom form only
007
Use name in input field and access that name in views.py by using request.POST.get('ip_name')
Puranjay
After that we have to store into model using form.save()?
007
After that we have to store into model using form.save()?
You have created mode form and you want to style it then use {{ form.user }} and then use form.save()
007
Model*
007
Otherwise you have to use field.objects.get_or_create( user = user)
Puranjay
I didn't get the {{form.user }} part
sravan
I didn't get the {{form.user }} part
If you are using html form then you can not use {{form.user}} and form.save()
sravan
You need to get the html form data using request.POST.get() and save it in the model
sravan
Like model.objects.create(field=fieldvalu)
007
yeah this is what i'am saying
d.l.c
Hello
d.l.c
I got an error like Reverse for 'post_detail' with no arguments not found .2 pattern(s) tried :['post/some regular expression]]
d.l.c
I'm doing a simple blog
d.l.c
When I used <int:pk> in URLs.py file I am getting this error
d.l.c
Help me plz
d.l.c
You are not giving the pk on the template/reverse function
You are talking about the views.py file right?
Guillermo
You are talking about the views.py file right?
or the template, wherever you are trying to resolve that url
d.l.c
Can I pm you ?
пантера
https://dpaste.de/A9UC
пантера
Can someone rectify the error, I am getting page not found error on running this url (http://127.0.0.1:8000/music/01)?
Guillermo
http://127.0.0.1:8000/music/1