highnes
Is there a way to invoke a js function from views
George
Is there a way to invoke a js function from views
Well. if you use a framework i think you can send anything but at first i dont think so
highnes
I just want to display 'invalid username or password' under my login form if login failed.Is there some way to do it.
highnes
I mean on the same login page.
Alaa
https://hastebin.com/ibeqekahos
Alaa
this is the code for views
Rohan
this is the code for views
Probably form.is_valid() evaluated to False
Alaa
print(request.POST) i have included this in the code and the form isn't getting to the backend
Alaa
at all
cj
https://hastebin.com/ibeqekahos
why are you using forms if you're making an API? why don't you use serializers? (just curious)
Alaa
am making a contact us form
cj
https://hastebin.com/ibeqekahos
why do you do: if request.method == "POST" if you are already in the def post() function?
Rohan
What's the point of form then?
cj
am making a contact us form
it doesn't matter what you have in the frontend, you should use a serializer if you're making an API
Alaa
ok in this matter how to make a serializer for my form
Alaa
can you give me idea
Alaa
it's name message email
cj
https://hastebin.com/ibeqekahos
also, in an APIView you should use request.data instead of request.POST 🤔
cj
also you have a ContactUsSerializer that you never use 🤔
cj
I bet that is the serializer you want to use
Rohan
Copy pasta job?
Alaa
that was my bug
cj
Copy pasta job?
looks like 10/10
Alaa
thank you alot
cj
can you give me idea
https://www.django-rest-framework.org/api-guide/serializers/ read that
Rohan
Rohan
Your code needs cleanup
Rohan
:/
cj
that was my bug
you're doing your whole code in the wrong way... please refactor everything
cj
by doing a serializer right
and all the other things I told you
Alaa
ok
Alaa
thank you
cj
I just want to display 'invalid username or password' under my login form if login failed.Is there some way to do it.
use the context of the view and made your templates do what you want to do, no need of JS for that, just play with form_valid() and form_invalid() and the context data
𝑺𝑨𝑰𝑭 𝑯𝑰𝑲𝑴𝑨𝑻 𝑯𝑨𝑭𝑬𝑬𝑫
id
cj
id
10/10 arabs are spammers... so..... 🤔
cj
𝑺𝑨𝑰𝑭 𝑯𝑰𝑲𝑴𝑨𝑻 𝑯𝑨𝑭𝑬𝑬𝑫
Im arabe
V@RG..
https://github.com/alexsdutton/django-camera-imagefield I found this to capture photography with the browser, but I tried and it does not work, can you check it and see if it really works?
Sergey
10/10 arabs are spammers... so..... 🤔
what source of statistic do you use? wrong info.
cj
what source of statistic do you use? wrong info.
https://t.me/SpamWatchFederationLog
Sergey
probably they used simple passwords) antiofftopic: Do you use some antispam shield for forms. csrf will not protect from spam?
Sergey
Recaptcha?
maybe. but do not like trust any info 3rd-party services. api keys, email etc
Sergey
Ratelimit
interesting. I try. thank you! maybe "random question => answer in session" will be good too.
Oğuzhan
Guys i use Django drf and don’t want logout when user update their password.
Oğuzhan
How can I do that how to make an api that update password
Oğuzhan
Without logout
Felix
But if you like complexity, try hardware-token authentication
Sergey
"how much 7 plus 2 minus 3", "5 times by 3" etc :) if site is non english then complexity grown
Sergey
Not that secure 🙈
spammers became much smarter?
Felix
maybe for spammer its enought, but security is based on probability so lets increase it.
Felix
the harder you get it, the better it is. 😜🥳
Oğuzhan
Friends this group is for off-topic?
Doragonsureiyā
Friends this group is for off-topic?
looks like you need an offtopic group, please continue this conversation at @pythonofftopic
Anonymous
Hi how can i get user info with request in view function ?
Anonymous
Using request object 🤔
request.user? just this one is there? How about ip and browser?
Mirco
Anyway you should find them into request.META
Mirco
🤔
print request.META and you will find some interesting keys 😊