Kapil
can it be done with some queryset?
محمد دلشاد
Kapil
idk about that
ok thanks for your efforts I will try something and update you if I'm able to resolve it
محمد دلشاد
محمد دلشاد
and thats no effort
Kapil
Mehmet
can it be done with some queryset?
Item.objects.values("id").annotate(avg1=models.Avg("shipping_cost"))
That is sample query for grouped aggregation
Pam
Mehmet
Place your group fields in values and annotate with a fictive key and db function as above.
Kapil
Kapil
can you please send any useful link ?
I don't have any link with me you can search for "post request in django" or something like that an go though some videos you will get the idea
Kapil
*think
Kapil
Mehmet
No, you should not use aggregate function but annotate function.
Mehmet
Sample above is obvious enough, it extracts the avg shipping cost per id.
Felipe
Hey guys, I hope you're all good! I'm facing a weird behavior on my Django application. I'm using the Django rest framework.
I have an endpoint that receives a POST and creates a resource. Running the server and testing by Postman making the requests manually everything works just fine, but when I try to run tests using py.test it's failing.
Now comes the weird part...
One of the parameters sent on the payload is missing on the tests and is present on the regular requests made by the postman.
I've checked the validated_data['parameter_name'] and on Postman it's coming correctly, but on the tests, it's not coming.
I already checked the data that is being sent and it's ok.
Does someone already get some error like this? Any idea of what could be the problem?
Mehmet
Mehmet
Kapil
Teacher.objects.values("id").annotate(avg1=Rating.Avg("value"))
Mehmet
is Rating connected to Teacher with foreign key? I mean one teacher instance has many Rating. Am I right?
Kapil
yes
Mehmet
Rating.objects.values("teacher_id").annotate(avg_rating=models.Avg("value"))
Mehmet
this will fetch lazy queryset of dictionaries not Rating object.
Kapil
models should be as it is or replace it with rating?
Kapil
yes
Mehmet
Then there should not be issue left.
Kapil
rating model has teacher which takes id of teachers
Mehmet
Have you got the approach I prepared or do you want me to create an exact query for you?
Kapil
Anonymous
Do anyone have any idea how to mock a function in testing?
Mirco
Kapil
Kapil
I just wanted to know one thing , it is possible to create a query to get my desired outcome?
M
hi anyone willing to teach me practical Django web development ( 0 to web application development ) or can suggest a learning path .
PS: I tried online resources in pin post but not moving more on satisfactory level
Doragonsureiyā
Anonymous
So I'm writing testcases for my project..to create a user Im using serializer to save data...in the serializer I overidden create method which calls a sendEmail function wen the user is Created..the email will be sent using aws
I configured aws credentials in my local using aws config file
Wen I push into git the test cases r failing
How to mock the email send function inorder to pass the testcase?
Mirco
Felipe
Abdullah
hi guys.i tried deploy my django site with pythonanywhere but i get a this result:
Abdullah
Something went wrong :-(
This website is hosted by PythonAnywhere, an online hosting environment. Something went wrong while trying to load it; please try again later.
Nikita Deriabin
Hi guys, I have problem.I get syntax error") from exc", when I write a command "python manage.py collectstatic". Can you help me with it?
Muflone
محمد دلشاد
Anonymous
Manuel
someone can help me please
Manuel
class UserAPI(viewsets.ViewSet):
def list(self, request):
queryset = User.objects.all()
serializer = UserSerializer(queryset, many=True)
return Response(serializer.data)
Manuel
class UserSerializer(serializers.Serializer):
class Meta:
model=User
fields="all"
Manuel
and I got no json on my DRF
Manuel
this is the result
Manuel
HTTP 200 OK
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
[
{},
{},
{},
{},
{},
{},
{},
{}
]
Manuel
I don't understand
Manuel
why is not working properly
Manuel
someone can help me please
Mehmet
Manuel
ok ok
Manuel
how would it be
Abel
Hey guys how can I make progress request from django rest framework
Mehmet
What do you mean by progress request?
abcde
In many tutorials they use ArticleListView(ListView) for using generic list view and ArticleDetailView(DetailView) for using generic detail view . Is it compulsory to use it that way . Can we write just Article(ListView) for using generic list view
Pam
Hello guys
can anyone tell me how to fetch django rest api in frontend ?
Pam
Like i want to use that rest api which i have created using django rest framework in frontend of my application.
Pam
React js
Pam
Any idea
Pam
ok
Anonymous
Hi all I am learning Django framework I have a one doubt please clarify
Aman
Anonymous
Why Cloudnot send photo this group
Karthik
Karthik
Media
Doragonsureiyā
This group don't allow medi
To share code or error tracebacks please use an online pasting service, here is a list of suggested sites:
- https://del.dog
- https://dpaste.org
- https://linkode.org
- https://hastebin.com
- https://bin.kv2.dev
Yesu
Hi all,
I have to display the image in Django template and I am retrieving it using db
{{model.imagefield.url}}
But it is not shown in front end.
Steps tried,
1- media URL and root are defined
2- static(settings.media_url, document_root=settings.media_root) defined in urlpatterns
3- image also Been upload to media folder
When I am checking the google console I couldn't see media folder
Yesu
Can anyone help on this