Christof
wouldn't surprise me
Anonymous
Depending on user last login and birth date,we have to generate the notification to the user based on weeks
Anonymous
Hi guys can any one help, why use socketio
Ghorz
John
class MessageSerializer(serializers.ModelSerializer):
receiver = serializers.SerializerMethodField()
class Meta:
model = Message
fields= ('receiver','message','timestamp',)
def get_receiver(self, obj):
user = self.context['request'].user
if user.is_brand or user.is_distributor:
users = User.objects.filter(is_retailer=True).exclude(email=user)
return users
else:
users = User.objects.all().exclude(email=user)
return users
John
KeyError at /messageview/2/1/
'request'
John
Can anyone help me what Is the problem with this, I want to get the current user in the serializer but I'm unable to get it
Mirco
it depends on the kind of view u have, the ListAPIView should already inject it via get_serializer_context
John
def post(self, request, sender,receiver):
if sender == request.user.id:
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save()
sender_message = Message.objects.filter(sender_id=request.user.id, receiver_id=receiver)
receiver_message = Message.objects.filter(sender_id=receiver, receiver_id=sender)
return Response({"Sender": MessageSerializer(instance=sender_message, many=True).data,
"Reciver": MessageSerializer(instance=receiver_message, many=True).data})
else:
return Response({'error': 'you are not allowed here'},
status=status.HTTP_400_BAD_REQUEST)
John
Is it required when I pass the serializer like this
John
In listapiview ??
John
Still the same issue
John
KeyError at /messageview/2/1/
'request'
John
John
This is the way to get the current user in a serializer right
John
?
Mirco
John
https://pastebin.com/Lk9y3saW
https://pastebin.com/c89WCuif
John
Mirco
?
John
John
Ashri
Mirco
Mr.TD
from django.shortcuts import render,redirect
from django.http import HttpRequest
from .models import form
# Create your views here.
def index(request:HttpRequest):
detail = form(request.POST['user'])
detail2 = form(request.POST['pass1'])
detail3 = form(request.POST['pass2'])
save = [detail, detail2, detail3]
save.save();
return render(request, 'index.html')
def chat(request):
return render(request, 'chat.html')
Mr.TD
i tried to store data in postgresql but the page through me an erro,
Mr.TD
MultiValueDictKeyError at /index/
'user'
Mr.TD
can any one help me in this
Mr.TD
pls guys
Mr.TD
ok i try
Mr.TD
super i got it
Mr.TD
thank you very much
John
class MessageSerializer(serializers.ModelSerializer):
class Meta:
model = Message
fields= ('receiver','message','timestamp',)
Here receiver is users and I wanna filter these users based on some features like if user is a brand in input
And return the users to receiver
how do I do that ??
John
Please suggest some effective and efficient way
Mr.TD
def index(request):
if request.method == 'POST':
detail = form(request.POST['user'])
detail2 = form(request.POST['pass1'])
detail3 = form(request.POST['pass2'])
master = [detail, detail2, detail3]
master.save();
return render(request, 'index.html')
Mr.TD
the data is not storing in postgresql
Mr.TD
can any one help
Mr.TD
pls
Jack
can anyone help me i been 3 hours and i dont know the error css dont work for me
Li
Jack
can anyone please help me
Mr.TD
Jack
anyone can help me please :(
Li
I haven't use like that before
Mr.TD
Jack
can anybody help me html only loads, css dosnt
Mirco
Doragonsureiyā
can anybody help me html only loads, css dosnt
Don't ask meta questions like:
"Any user of $x here?"
"Anyone used technology $y?"
"Hello, I need help on $z!"
Just ask directly! The better you are at explaining the problem, the more likely you are to get help.
Asking smart questions
Jack
I have folder/index.html, index is loading OK. Then static/css/styles.css but it's not loading
Jack
Here is my index.html
And my styles.css:
Jack
{% load static %}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href"{% static 'css/styles.css' %}"/>
</head>
<div class="vertical-align">
<div class="container">
<div class="avatar"></div>
<form method="POST">
<input type="text" placeholder="Username">
<input type="password" placeholder="Password">
<input type="button" value="Login">
</form>
</div>
</div>
</html>
Jack
body {
padding: 0;
margin: 0;
font-family: 'Source Sans Pro', Arial, sans-serif;
background-color: #84c196;
}
.vertical-align {
display: table-cell;
vertical-align: middle;
height: 100vh;
width: 100vw;
}
.container{
width: 400px;
margin: 0 auto;
background-color: #ffffff;
box-sizing: border-box;
padding: 30px 20px;
border-radius: 3px;
}
.avatar {
height: 100px;
width: 100px;
margin: auto;
border-radius: 100px;
margin-top: -85px;
margin-bottom: 25px;
background-color: #588465;
box-sizing: border-box;
border: 5px solid #588465;
Jack
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
Jack
But its not working, only html is loading...
Son
Li
Son
Janmay
I want to make a custom field model which seperate input from text field by comma seperator and return as list
May someone help me out with it...
Jack
Mounted
Hello everyone, I can't make an infinite scroll datatable. Maybe someone did it? Examples?
Thanks in advance
Mounted
I read this article but there is about https://dev.to/coderasha/infinite-scroll-with-django-d0a infinite scrolling of the page, but I need it for the table
The
Jack
no
Jack
;/
The
Check on the path if it's the correct one in the settings file
Jack
it is
Jack
sorry still not solved, my bad
Mounted
Janmay