syedj
write that in a JS file, not directly on the python code
Method would be defined in js file how can I call it
syedj
Sorry for being so naive but im learning things
cj
Method would be defined in js file how can I call it
write in JS function myFunction(){ // your code here }
syedj
ModelChoiceField has attributes but it takes from database
inchidi
This is throwing error
🔮 let me see the error through my crystal ball first 😉
Srinivas
Hello guys, I am facing a small issue related to django forms.DateTimeInput(), when i am using this i got Invalid form, how to use forms.DateTimeInput, Can anybody help me?
Srinivas
If u explain your issue better , yes
I created a form to store some data, some are text input fields and other are datetime fields, Now I am facing issue with forms.DateTimeInput() in widgets of forms.py file, the issue is when i entered the data in form and click submit, i got invalid form
Dante
Yet another error in django
Dante
@pyflare,can I send you my errors?
Mirco
@pyflare,can I send you my errors?
Share them here and use code sharing tools pls
Anders (izzno / gooood) 🇳🇴
Django channels
Ooo, i just assumed this was websockets. Now I see its much mroe.
..
Hello colleagues! I would really appreciate if someone could consult me on my question. The point is I need to build a backend support for mobile app using django, websocket, and mongodb database. I found that django channels are pretty useful in this matter, but not so much resources on this topic and especially its integration with mongodb. Do you know any good materials regarding this topic? Thanks
Sulistyo
anyone can help me.. i have 2 forms.. with 2 tabel.. i successfully save in that 2 tabel, but not for the foreignkey field.. my question, how to foreignkey automatic fill when i save from forms.. thankss (sorry bad english)
Rohan
Maybe show your code so we understand what you're trying to do
Sulistyo
i try to upload image file.. but always error
inchidi
🔮 let me see the error through my crystal ball first 😉
Srinivas
can any one help me out, regarding how to use DateTimeInput() in forms.py, it has to take the value from datetime-local input tag from html, when i use it, i got "Enter valid date/time" errors
Rohan
We don't support piracy
Ronald
Buy it
Ajay
Guys I have created login page using django.. But username and password displaying side by side
Ajay
How to make it one by one
Ajay
In .py file
Ajay
Username and password displaying side by side
Ajay
fix it into template
I have taken in forms.py
Ajay
In that I need to write as newline for username and password
Mirco
I have taken in forms.py
yep, but you can choose how to render it into your template
Mirco
and adds styles to it
Ajay
Ok
Mirco
Ok
study it better on official docs
..
Because of techniqal requirements of the project, and also I am new to javascript in order to use Nodejs
Anders (izzno / gooood) 🇳🇴
Because of techniqal requirements of the project, and also I am new to javascript in order to use Nodejs
Well I have not used Django channels yet, but I spent the better part of the day going through the documentation and as I can see it you can do "business" as usual and implement bit by bit to async or just use the socket etc. It seems pretty straight forward. I Imagnine you plan to use socket.io JS in the frontend?
Anders (izzno / gooood) 🇳🇴
Thanks for your response. I'm sure about using socket.io
I am at this crossroad my self... Either rewriting in JS or using channels :)
Anders (izzno / gooood) 🇳🇴
I landed on the app that is heavily dependent on the Admin panel i will introduce channels and the one where I dont use it I will rewrite.
..
As I was looking it's much easier to use js with websocket. I asked the question because I am new very to Django world and overall to programming, and wanted to know the possibility of integrating all those features together. But I think I will stop on channels.
.
thanks man)
or learn aiohttp, great tool for async requests
Mirco
thanks man)
django-channels 2 should be good for you scenario
Oleg
=_=
Anonymous
What's through in a model For example my model name is Image it have a attribute named users_like. The book that I'm reading writes this line Image.users_like.through
Firdaus
https://github.com/encode/requests-async
Mirco
What's through in a model For example my model name is Image it have a attribute named users_like. The book that I'm reading writes this line Image.users_like.through
http://charlesleifer.com/blog/describing-relationships-djangos-manytomany-through/ read here to have a better idea
Anonymous
def register(request): if request.method == "POST": form = UserCreationForm(request.POST) if form.is_valid(): user = form.save() username = form.cleaned_data.get('username') login(request, user) return redirect("WebApp:index") else: for msg in form.error_messages: print(form.error_messages[msg]) return render(request=request, template_name="registration/registration.html", context={"form": form}) form = UserCreationForm return render(request = request, template_name = "registration/registration.html", context={"form":form})
Mirco
English pls
Anonymous
Template ? Have you include csrf_token ?
{% extends 'webapp/header.html' %} {% block content %} <br> <form method="POST"> {% csrf_token %} {{ form.as_table }} <button style="background-color:darkcyan; color:blue" class="btn btn-outline-info" type="submit">Sign Up</button> </form> <br><br> If you already have an account <a href="{% url 'login' %}" ><strong>login</strong></a> instead. <br><br> {% endblock %}
Anonymous
you don't have to remove it
Soory, it is solved, by changing return redirect to render(request, ....)
Anonymous
good :)
But it is not the actual reason for getting csrf error, right?
Anonymous
But it is not the actual reason for getting csrf error, right?
Wrong You get csrf error exactly because you did not render the HTML If you see the final HTML code which is rendered you won't see {% csrf_token %} You will see csrf token value
Anonymous
but why it didn't worked redirect("WebApp":index)
You get csrf error from Django debug? Anyway. You get error because your csrf tag is not rendered. The error is expected. You can ask why when it works with redirect
Tema
Hello! Is it possible to use “lazy-load” for serializers?
Tema
class NewsSerializer(serializers.ModelSerializer): images = ImgSerializer(many=True, read_only=True) class Meta: model = News fields = '__all__' class ImgSerializer(serializers.ModelSerializer):
Tema
I need to write NewsSerializer before ImgSerializer in my file… But I also need to use ImgSerializer in NewsSerialier…
Tema
How to do it?
Tema
don't understand
https://s3-eu-central-1.amazonaws.com/f.26x.ru/Screenshot_2019-03-28_at_19.18.02.png
Tema
Here is screenShot
Tema
in my NewsSerializer I use nested ImgSerializer...
Tema
and I get error 'ImgSerializer' is not defined because it is defined after NewsSerializer
.
It is circular nesting. If you place NewsSerializer in ImgSerializer and ImgSerializer in NewsSerializer it will be wrong, you cannot do that
Tema
But I can’t put NewSerializer below, because I have another serializers... and have the same error with them
.
Interesting problem. So you want to place s1 in s2 and s2 in s1? Or what?
Tema
actualy I have 3 of them, but yes,
Tema
s1 in s2, s2 in s3, s3 in s1
Tema
I can do some workarounds and solve it… but It’s strange that there is no good way to do it easy
Tema
It’s the same like ForeginKey in models… We use Quotes, to place the models where we want to