Ilsaf
How to set in ArrayAgg to return empty list not [None] if not values, I try to set default=Value([]) but it cant work
Azaan Aslam
Good morning everyone... I have completed my Django Devloper course with python language I need work can anyone help me
Charly
Azizbek Xushnazarov
What is the difference between Suggest and Functional Suggest in elasticsearch dsl drf?
svmr
Hi Is there a profit of using async django? When should i decide i need it? Like does it depend on requests per second or…?
Mr.
I have htm table which has so many tags i want to save all tage in db then load it. How its possible?
@The£B#ES£T@
What is the exact meaning of Post=post.objects.all()
@The£B#ES£T@
While we creating function in views.py
Rajat
What is the exact meaning of Post=post.objects.all()
We are fetching all the objects created by model post
@The£B#ES£T@
What is class meta?
@The£B#ES£T@
Can anyone explain?
Nasib
hi guys, I am creating a django website where a user can place a link of an image and then place upload then the django server will download the image from a particular website and save it to the database but I fail to save the image to the database . Can anyone help me please
() { :;}; echo Nickolas
Using django-channels, how can I determine how many socket connections are in my group?
Felix
Hello guys I have built an E-commerce site using Jinja but now I would like to give the administrator an options of adding products and any other things Would you recommend Post man or there is another option that is friendly
() { :;}; echo Nickolas
Allow administrators to create products there
Sibiselva
Hi guys, I've have an issue, css file is not updating properly on the browser, like I've changed the color but the browser still showing the old color , ive tried restarting the server but no changes. How to fix this
Mirco
Local
with runserver up and running ?
Sibiselva
Try on incognito if color is applied then make a hard refresh on your page
I've tried hard refresh one time by long pressing the refresh button and it updated but again got same issue but now long pressing refresh button doesn't show and empty cache and hard restart
Rajat
Yes
Please check you have configured static settings in settings.py
Sibiselva
Please check you have configured static settings in settings.py
Yes I've add static directory, the css file is working previously but suddenly i got this issue
Sibiselva
I think you should check your css file path in link tag
Yeah it linked correctly, ive completed half off the project with that css file
Brutus
Yes
Open dev tools then right click refresh button you'll get option to hard refresh
Brutus
For keyboard it's ctrl shift r
Sibiselva
For keyboard it's ctrl shift r
ctrl shift r ? Ive tried ctrl shift f5
Rajat
Many times
Then it is serious problem 😂
Sibiselva
But adding style on html file itself means, it working
Sibiselva
Then it is serious problem 😂
Even i tried restarting my laptop
Rajat
But adding style on html file itself means, it working
i.e there is only problem in changing color other css properties are working correctly
Sibiselva
i.e there is only problem in changing color other css properties are working correctly
No all properties like height, width font size everything, Even after commenting whole class on css , the browser showing the previous style
Sibiselva
Whole code or that particular page
Rajat
Particular static statement
Sibiselva
Particular static statement
https://dpaste.org/28E3S
() { :;}; echo Nickolas
apply python manage.py migrate. then run your server. May be it will work🙃
Migrations have nothing to do with CSS... low effort
George
Okay, i have a kind of hot question. I have a model with a M2M field. I have to order that field based of a custom metric. Like 1- get all the objects of that M2M 2 - calculate a score for each one 3 - order them based on the highest scores Right now i have a serializer like this class DealListSerializer(serializers.ModelSerializer): rank = serializers.SerializerMethodField() def get_rank(self, obj): rank = -1 for partners in obj.partners: if partner.experience > 5: rank += 10 elif 3 <= partner.experience < 5: rank += 5 return rank def get_partners(): self.obj.partners.all().order_by("rank") How to do this? I have thought of using annotate but the function i need is complex so idk. I know using a get_rank function is wrong but i needed to write something. I would like to use a function to get the score of each object in that M2M and order by it.
() { :;}; echo Nickolas
just order your queryset based on rank?
Sibiselva
ctrl shift r working When i add style directly in html and make input width to 50px its working but when i add style on css means max-width:50 px only making the input width to 50
George
just order your queryset based on rank?
Rank is an internal calculation not an actual field of my model.
() { :;}; echo Nickolas
Rank is an internal calculation not an actual field of my model.
Perhaps this helps? https://stackoverflow.com/questions/30041948/django-rest-framework-ordering-on-a-serializermethodfield
George
Perhaps this helps? https://stackoverflow.com/questions/30041948/django-rest-framework-ordering-on-a-serializermethodfield
Kinda similar, i ended up doing this. class BarListSerializer(serializers.ModelSerializer): def get_partners(self, obj): partners = self.obj.partners.all() rank = [0 * len(partners)] for i, partner in enumerate(partners): if partner.experience > 5: rank[i] += 10 elif 3 <= partner.experience < 5: rank[i] += 5 if ( self.obj.city and self.obj.city == partner.city ): rank[i] += 10 return sorted(zip(partners, rank), key=itemgetter(1)) I don't know if it's a valid answer but
George
Looking good
It might do the job, kinda slow but idk. Seems simple enough
() { :;}; echo Nickolas
It might do the job, kinda slow but idk. Seems simple enough
well I guess it's exponential growth depending on the # of partners
() { :;}; echo Nickolas
If you don't need them real time perhaps just schedule a job that calculates it for you with celery?
George
well I guess it's exponential growth depending on the # of partners
yes, i would prefer doing this in a query thing :<
() { :;}; echo Nickolas
and define it as a property on your model
George
This should be cached hmmm
Rajat
https://dpaste.org/28E3S
Where is load static tag
() { :;}; echo Nickolas
This should be cached hmmm
Use something like redis to cache it in? Schedule celery task every minute that calculates the rank Dump variable in redis Fetch every time you need it Celery task updates redis every minute and gives you an "up-to-date" rank
() { :;}; echo Nickolas
That approach won't make your request slower and you still have cached/semi real-time ranks
Sibiselva
Where is load static tag
Line 1 and line 9
XYZ🤠
how to make a unique name without changes in filleField
XYZ🤠
https/stackoverflow.com/questions/9214904/how-to-prevent-django-from-changing-file-name-when-a-file-with-that-name-already-exists
() { :;}; echo Nickolas
You can pass a method to upload_to
() { :;}; echo Nickolas
which is responsible for renaming the file
Chandra
Hello guys how to write a login ,logout , register user api
Farzin
Hi everyone In my Django API view I have couple of loggers, and it's in production, problem is when I make POST request for example by Postman with the api, I can see all request logs and headers in my log file, but there is another company that try to use the same API in our system but I can't see none of their Post requests in logs just the GETs, but when I'm checking Nginx logs I can see that they've sent POST request too.
Maset
How can I query like the YouTube/Google does like: If I type 'mr bounae' it will show all similar including 'mr bean' With django
Maset
Filter
But I couldn't find something like this one When I filter by 'mr bounae' it will return only matches 'mr bounae', 'mr bounaeer', 'mr bounae series' like that And not 'mr bean' or 'mr' or 'bean'