Anonymous
Decimal raise error if compared with non decimal instances
Anonymous
Have you tried field__gte=Decimal(0.1) ?
Sweetie
Have you tried field__gte=Decimal(0.1) ?
Sorry it worked. For some reason pycharm was not showing the gt lt eq filters in autocomplete but it worked.
Alex
Is there any way to so it through template any tag?
Sure. You can simply define a custom template tag and pass to it the request object {% mytag request %}. Or even simpler - define it with take_context and work with the context there. https://docs.djangoproject.com/en/3.0/howto/custom-template-tags/#django.template.Library.simple_tag But I would call it shit code decision - you really should not use it that way because it is really unobvious. Such actions should be done in views.
NR
Sure. You can simply define a custom template tag and pass to it the request object {% mytag request %}. Or even simpler - define it with take_context and work with the context there. https://docs.djangoproject.com/en/3.0/howto/custom-template-tags/#django.template.Library.simple_tag But I would call it shit code decision - you really should not use it that way because it is really unobvious. Such actions should be done in views.
Thanks for the reply.. scenario is like that. There is an edit page for post. If a user knows about link he can go to edit post page. Once he submit the change view will be able to block him and logout. But i want that user should not be able to access even edit page. I am using html tage if request.user html and else redirect. Is there any better way to check via view?
Valery
You can override dispatch
Valery
smth like that def dispatch(self, request, *args, **kwargs): obj = self.get_object() if obj.smth != self.request.user.smth: return HttpResponse(status=404) return super().dispatch(request, *args, **kwargs)
Владимир
Hello, please tell me how to configure django-autocomplete-light?
Alex
Hello, please tell me how to configure django-autocomplete-light?
I think you should read their doc first. And if any problems occur - ask in their repo. It is much straight forward way.
i hate milk
hello. i need to implement caching on my site, so i can do it via nginx or django. how will it be more optimized?
i hate milk
i mean client side caching
Alex
i mean client side caching
Let's start from scratch. What do you want to cache and why?
i hate milk
i want to cache static files for optimization
i hate milk
images and css
Hari
How to write test case for if condition
Alex
How to write test case for if condition
Google is right there -> google.com
Hari
If not settings.USE_ELASTIC SEARCH
Alex
images and css
You mean besides the caching the browser already does?
i hate milk
yes
Alex
You mean besides the caching the browser already does?
Hm, forgot that they do it by default. I'm dummy.
Alex
yes
Like caching you would do with redis?
i hate milk
i did not work with redis
Hari
If not settings.USE_ELASTIC SEARCH
For this how could we implement in test case
i hate milk
its easy
ok, thx. i'll google it
Alex
For this how could we implement in test case
https://lmgtfy.com/?q=how+to+test+if+statement
Anonymous
ok, thx. i'll google it
just search "python redis docs" in google
Ansab
How to filter using related name in django
Амантай
Hi everyone. I want to start Django, and first of all I would like to ask what kind video courses would you recommend?(can you share links and so on).
Alex
How to filter using related name in django
google "How to filter using related name in django"
Амантай
Or is it enough to read the documentation( is it easy to understand )
Амантай
google "django video courses"
I have watched some courses, there is a lot of unnecessary info
Амантай
I am ready to buy courses
Alex
Or is it enough to read the documentation( is it easy to understand )
Django is very fast developing software and tomorrow your video course will be outdated and obsolete. You WILL HAVE to rely on their docs eventually if you want to succeed.
Амантай
Thx
Alex
Ansab do not pm me.
Alex
-_-
Владимир
Possibly, better to google django rest framework or even fullstack projects which use react+django rest. Just a suggestion)
Abdu
https://stackoverflow.com/questions/60263570/pass-checked-items-to-python-using-json
Ram
How do add extra coloumn to the djangos build in auth user table(registration) I want to add full name to the database
cj
How do add extra coloumn to the djangos build in auth user table(registration) I want to add full name to the database
there's a post on SimpleIsBetterThanComplex blog exactly about that, first result using Google, don't miss it 😉
Francisco
please help!!!
Francisco
https://gist.github.com/FFloresM/2f413f68070635a42abb931ebf847ac0
Fabian
Hi, does anyone has deployed a dockerized django app on aws? Please I need a hand if anyone can help me
Doragonsureiyā
Hi, does anyone has deployed a dockerized django app on aws? Please I need a hand if anyone can help me
Please don't ask meta questions like: "Any user of $x here?" "Anyone used technology $y?" "Hello I need help on $z" Just ask about your problem directly! With 53k+ people the probability that someone will help is pretty high. Also please read: http://catb.org/~esr/faqs/smart-questions.html
pratheep
Can anyone help me , how to get the file name that have been selected to upload in HTML file and after pressing upload button in HTML , how should I handle that request in django
Ramziddin
Any way to make a field on admin page readonly?
Alex
Any way to make a field on admin page readonly?
ModelAdmin.read_only_fields = []
PV
Is there any package to create django backup and restore
Alex
Is there any package to create django backup and restore
The task is not related to django, but to your DB server. I've advised you to google smt '<dbname> auto backup' because there are really many solutions for that and you have to choice your own.
Anonymous
i have problem with docker
Anonymous
docker version and server version is not the same .How to cope with this problem
Anonymous
Hello,who can help set up Clickuz ? I have problem
Anonymous
hi to every body Im new to django I tried to make the django project I created it and then I made the superuser in my web browser but I had a problem that when i try to add user or add new group in admin page Isee this error: no such table: main.auth_user__old please help meee!!!
Anonymous
Did u run migrations ?
I searched it in stackoverflow and I knew maybe downgrading the mysql version may helps but i dont know how to do it? do u know how is it ??
pratheep
Getting” forbidden CSRF verification failed “in django while submitting a file
Mirco
yes
If I don't go wrong, it was a bug Try with postgres
Alex
hey, i need help. I need to change fields in two models and using just one form
Alex
1 form for changing 2 models at same time
Mikhail
you must create view and you form go to vis view
Valery
I have a ticket model with FK to User. I need to return id of ticket for every user start from ticket number one and so on. Now if user1 create ticket he get ticket1. And if user2 create ticket he get ticket2. But I need to save this ticket with number 1 for user2. I think I can override save method and do something like filtering by user and increment tickets count to +1. But I feel this is bad idea. What can I do in this case?
Manik
how to use ModelViewset n its all methods in REST