Arsen
item.id
Arsen
It is impossible that two rows have the same ID
They can have the same values if there is no unique fields
I suppose u just have the same values in db
Arsen
Vikash
How to fix 502 error in response?? In django rest framework
Caio
It’s bad gateway
Vikash
But without using filter in it .. it's working fine
Vikash
I need filter also here
Caio
Oh sorry I thought you wore in production already
Caio
Please send the code snippet that is causing the problem
Vikash
Yes it's in error come in production only
Vikash
Okay
☪️ جنت الفردوس
+
Vikash
def post(self, request):
try:
controller = CustomerListController(data=request.data)
paginator = Paginator(controller.get_data(),25)
page_number = request.GET.get('page')
page_obj = paginator.get_page(page_number)
data = []
for p in page_obj:
data.append(p)
return Response(data,status=status.HTTP_200_OK)
# return Response(status=status.HTTP_200_OK, data=controller.get_data())
except Exception as e:
# print(e)
return Response({"message": "Internal Server Error","error":str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Vikash
Caio
except Exception as e:
# print(e)
return Response({"message": "Internal Server Error","error":str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
if you are getting an error is because on the try block there is something wrong paginator = Paginator(controller.get_data(),25) maybe here, I'm not sure
Vikash
Before it was working fine
Vikash
After coming 10000 customer
Vikash
It's happening
502
Caio
what you can do is set DEBUG = True in your settings.py and see the message, but please don't do that in production,.
Phansivang
Hello I deploy my django to heroku but when i go to check heroku log it's say "Free app running time quota exhausted" what is that mean ?
Vikash
Vikash
In production it's its false
Caio
in the debug page there is more info about the error.. .
Vikash
But this error is coming in production only
Vikash
Not in development server
Caio
502 it's bad gatway, are you using nginx?
Caio
Phansivang
File "/app/main/settings.py", line 67, in <module>
2022-05-26T08:58:29.449581+00:00 app[web.1]: 'NAME': BASE_DIR / 'db.sqlite3',
2022-05-26T08:58:29.449581+00:00 app[web.1]: TypeError: unsupported operand type(s) for /: 'str' and 'str'
Phansivang
it's all fixed but now in my heroku log it show like this
Phansivang
😔
sdfwefersrsc
マクスイム • グセブ
OceanMan
You can use users api in users app, but if you want all the url to link to one root, you can use all in one urls
Ihor
Hello, is it possible in django to use dynamic data coming from another server. So that part of the page is updated every period of time without user intervention.
k
Anyone familiar with drf?
cj
Doragonsureiyā
Anyone familiar with drf?
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
k
I have created a serializer which has 2 methods. But it doesn't work if no object is returned from queryset.
I want it to work when there is no object sent.
How to make this happen ?
Phansivang
From my Heroku Logs it's says "django.db.utils.DataError: value too long for type character varying(20)"
Phansivang
Phansivang
Phansivang
my English not good
Владислав
Hello! How can I get the quantites of Posts in Group?
models.py:
https://linkode.org/#Esdle2Lz6RRYfT46enzJz
views.py:
https://linkode.org/#oPeGXnC11HvPWtKt4HpS04
Ihor
cj
you can use the one that fits better to you, there's nothing written in stone for that thing
OceanMan
For professional you have to do some internship
Anonymous
how can let user sign up by their choice i.e. username or email in drf
𝚂𝚘𝚑𝚛𝚎𝚝
Hello. I have a problem in Django.
image = ProductImages.objects.get(product_id=id, main_or_not=True)
The image url should come here, but the image name comes up. I can't understand what the problem is. Please help if anyone knows.
Alex
Alex
image.<field_name>.url can work in this case
𝚂𝚘𝚑𝚛𝚎𝚝
Alex image
Alex
Try image.image.url
𝚂𝚘𝚑𝚛𝚎𝚝
i tried but it didn't work
𝚂𝚘𝚑𝚛𝚎𝚝
This way data-img="{{ image.image.url }}"
Alex
Have you configured static and media URL?
𝚂𝚘𝚑𝚛𝚎𝚝
yes
𝚂𝚘𝚑𝚛𝚎𝚝
print(image.image.url) It shows url but not working in template
Alex
Also, check if the image appear on following the URL
𝚂𝚘𝚑𝚛𝚎𝚝
Other elements appear on the frontend. And 127.0.0.1:8000/media/media/products/banner10.jpg shows the image
Alex
Then something in the frontend is wrong.
𝚂𝚘𝚑𝚛𝚎𝚝
I got it. thank you so much for your help )
William
Hi Guys,
I have this function to calculate the sum of a column in my model, but when I apply a filter on the admin page the sum keeps the total column sum and not the column filtered, hoe should I proceed?
def total(self):
total = Batch.objects.aggregate(Sum('amount_company'))
return round(total["amount_company__sum"], 2)
Stefan
William
Hermann
hello everyone
Stefan
Stefan, I dont got how should I do.
First, filter your queryset then aggregate that filter.
So first line (batches = Batch.objects.filter(you_filter_here) will filter your query and the second line will apply aggregation of that filter.
Amarya
Good morning
Please how knows where I can get a detailed explanation on how to integrate paystack or Django futterwave on django
Ruslan
Hello. How i can put company in my vacancy.I use CreateView
Models company and vacancy has ForeignKey
https://github.com/RuslanZaremba/find_a_job_in_it/blob/master/app_work/models.py
Ruslan
https://github.com/RuslanZaremba/find_a_job_in_it/blob/master/app_work/views/my_company.py
MyCompanyCreateVacancy, it is last class
Anonymous
Hello everyone, I'm writing a site on Django and there was one problem. I put a link to a page in a button, but it doesn't open when the button is clicked.
Anonymous
{% extends 'glav/layout.html' %}
{% block title %}Связаться с нами{% endblock %}
{% block content%}
<form method="post">
{% csrf_token %}
<h1>Ваше письмо было успешно отправлено</h1>
<a href="{% url 'news_home' %}"><button class="btn btn-success">Другие Материалы</button></a>
</form>
{% endblock %}
Anonymous
my classes are so in a -_-
karakurt
No,
https://stackoverflow.com/questions/6393827/can-i-nest-a-button-element-inside-an-a-using-html5
Artur
Hello. Can someone help please. I need to track last user request. I find resolve with custom middleware. But in middleware i receive AnonymousUser. In view i have TokenAuthentication class, and send requests with obtain Token