syedj
syedj
Sorry for being so naive but im learning things
syedj
syedj
ModelChoiceField has attributes but it takes from database
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?
Mirco
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
Mirco
Dante
Yet another error in django
Dante
@pyflare,can I send you my errors?
Anonymous
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
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
Mirco
Ajay
Username and password displaying side by side
Mirco
Ajay
In that I need to write as newline for username and password
Mirco
and adds styles to it
Ajay
Ok
Mirco
Ok
study it better on official docs
Anders (izzno / gooood) 🇳🇴
..
Because of techniqal requirements of the project, and also I am new to javascript in order to use Nodejs
..
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.
Anders (izzno / gooood) 🇳🇴
..
.
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
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})
Anonymous
Mirco
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
Mirco
Mirco
Anonymous
good :)
But it is not the actual reason for getting csrf error, right?
Anonymous
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