Re: django model method

2023-02-13 Thread Jason
there's alot to not like about the implementation here. You're effectively hiding queries and db hits with those methods, since the naming does not give any indication that its a db hit. So its really easy to forget that, and then after a while, you're wondering why your project is so slow

Re: django model method

2023-02-10 Thread Gabriel Araya Garcia
Allways there is a way to improve the code, but if that not run, then try with CYTHON Gabriel Araya Garcia GMI - Desarrollo de Sistemas Informáticos El jue, 9 feb 2023 a las 10:09, Andréas Kühne () escribió: > Not if you want it to be fast. Python itself is slow - so you should try > to

Re: django model method

2023-02-09 Thread Vitaly Bogomolov
You can look towards Django Q-objects . This filtering method is implemented in the MultiChoiceExt filter of my DjangoAdminFilters

Re: django model method

2023-02-09 Thread Andréas Kühne
Not if you want it to be fast. Python itself is slow - so you should try to offload most of the computation on the database. So filtering would need to be done on database fields as well. Otherwise you would need to load all of the rows into memory and then do the filtering there. If you want to

Re: django model method

2023-02-09 Thread Chelsea Fan
understood, is there any way to filter objects by method value? On Thu, Feb 9, 2023 at 4:42 PM Andréas Kühne wrote: > No. > > Ordering works by using the database to order the models. It therefore > needs to be a database field - otherwise the database can't order by the > field? > > Regards, >

Re: django model method

2023-02-09 Thread Andréas Kühne
No. Ordering works by using the database to order the models. It therefore needs to be a database field - otherwise the database can't order by the field? Regards, Andréas Den tors 9 feb. 2023 kl 12:09 skrev Chelsea Fan < allaberdi16yazha...@gmail.com>: > hello guys, Is it possible to use

django model method

2023-02-09 Thread Chelsea Fan
hello guys, Is it possible to use model method value to ordering model objects in meta class? class Post(models.Model): title = models.CharField(max_length=255, verbose_name="ady") text = RichTextField(verbose_name="text") tagList = models.ManyToManyField(Tag, verbose_name="taglar",

How to sort a column by Django model method using django-sortable-listview (SortableListView)?

2020-04-20 Thread Nancy Jenifer Benita S
Using *django-sortable-listview* package, I'm using *SortableListView *to sort out all the model fields. In my case, more than model fields, I want to sort it out by model method too. Models.py class Employee(models.Model): name = models.CharField() designation =

Re: search results from a Django model method including the results from earlier calls to the same method (x post StackOverflow)

2019-10-28 Thread yolabingo
Solved on SO, but an extremely educational response. I learned about mutable default argument gotcha https://stackoverflow.com/questions/1132941/least-astonishment-and-the-mutable-default-argument And Django Modified Preorder Tree Traversal https://github.com/django-mptt/django-mptt -- You

search results from a Django model method including the results from earlier calls to the same method (x post StackOverflow)

2019-10-28 Thread yolabingo
I also posted this to SO https://stackoverflow.com/questions/58600159/search-results-from-a-django-model-method-including-the-results-from-earlier-cal hope that's ok, let me know if not. I have a Django Model that tracks email message IDs as the message passes through different servers. It has

Re: problem with django model method save()

2012-07-04 Thread Tomas Neme
I don't see why wouldn't your model's .save() work, maybe we'd need to see the model code, but I know you probably want to read this: https://docs.djangoproject.com/en/dev/topics/forms/modelforms/ once you've implemented a ModelForm, you'd pretty much would just do form = RoomForm(request.POST)

problem with django model method save()

2012-07-04 Thread rafiee.nima
Hi Im some how new to django . I write a view to handle ajax request but I find out that save() method dose not save model instance in to the database here is my code def add_room(request): context={} status='' if request.is_ajax: if request.POST: