Thank you very much Django family for your positive response, and
especially to *@Fabio C. Barrionuevo da Luz,*
Adding another field to the QuerySet using the *"**annotate"* function
really helped and solves the problem like a charm! as side by @Lalit Suthar
Thank you once again everyone for shar
you can use datetime.datetime.strptime to avoid this error. I resolved it
few days back.
for this you have to import datetime like this: import datetime
On Sat, Jan 22, 2022 at 12:19 PM Lalit Suthar
wrote:
> Fabio C. Barrionuevo da Luz's answer will work like a charm!
>
>
>
> On Fri, 21 Jan 2022
Fabio C. Barrionuevo da Luz's answer will work like a charm!
On Fri, 21 Jan 2022 at 21:04, Fabio C. Barrionuevo da Luz
wrote:
> this can be easily solved by using an annotation to calculate the
> difference and store it in a new temporary column, and then sort by it
>
>
> from django.db.models
this can be easily solved by using an annotation to calculate the
difference and store it in a new temporary column, and then sort by it
from django.db.models import F
from myapp.models import ExampleModel
queryset = ExampleModel.objects.annotate(
dt_difference=F('updated_at') - F('created_a
Try this:
ExampleModel.objects.all().order_by('updated_at' , '-created_at')
Gabriel Araya Garcia
GMI - Desarrollo de Sistemas Informáticos
El vie, 21 ene 2022 a las 1:54, Aadil Rashid ()
escribió:
> class ExampleModel(models.Model):
> is_active = models.BooleanField(default=True)
> created_at
Hi,
in VIEWS
def example=(request):
fm=ExampleModel.object.created_at
ExMd=ExampleModel.objects.filter(created_at__lt={'fm'})... ordering
conditions.
On Friday, January 21, 2022 at 10:25:13 AM UTC+5:30 aadil1...@gmail.com
wrote:
> class ExampleModel(models.Model):
> is_active =
This is nice idea, but I can't change the model, as discussed by teammates,
i need to figure out any other way to do it on the go.
On Fri, Jan 21, 2022 at 5:02 PM Lalit Suthar
wrote:
> won't be possible like this, It will be easy if you have another entry in
> models which stores the difference
won't be possible like this, It will be easy if you have another entry in
models which stores the difference between updated and created.
You can update that field whenever an object is updated. And then can run
order_by on that field directly
On Fri, 21 Jan 2022 at 10:24, Aadil Rashid wrote:
>
class ExampleModel(models.Model):
is_active = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
I want to query on UserModel such that the Query set which I get should be
orderable in terms of time difference o
9 matches
Mail list logo