1

голосов
0

ответ
52

Просмотры

order_by не сортировать Swedish UTF-8 символов Aao правильно на рабочем сервере

Я испытываю некоторые проблемы с моим производством капельного @ DigitalOcean при сортировке querysets. Шведские символы Aao рассматривается как А и О, которая не ожидаются или желательно. Это работает локально. Я баловался с локалями на сервере, и они, кажется, хорошо. версия Django: 1,11 Python версии: 3.5.2 Если кто-то испытал и решить подобные проблемы, было бы здорово, чтобы услышать, как вы ее решили! Определение класс модели County (TimeStampedModel): Имя = models.CharField (max_length = 200, уникальный = True) Защита __str __ (Я): возвращение self.name Как сортируются QuerySet. County.objects.all (). Order_by ( 'имя')
oalsing
1

голосов
3

ответ
112

Просмотры

Saving already calculated values

Basically I have a list of items and, which have parameters of size and value that needs to fit with a lot of other items in the best way, to reach the highest value possible but staying under a maxSize. To explain the issue, see the following explanation. Item 1: Size 1, Value 1; Item 2: Size 2, Value 4: Max Size: 11; Best solution: 1xItem1, 5xItem2. But in this very case, the limit is higher and the items are many more. My problem is to find the best possible mix. So far I've created a algorithm that does this, but since the complexity is so bad, it only works with a few items. I am basically trying every possible combination, which creates a lot of calculations on higher numbers of items. I am saving the path taken as a string (Item2->Item2->Item1->Item2...), until the total size is higher then the limit. If the value is higher then some other found value, it is saved as well as the string. What I do want to do is the save all calculations already done, here is an example. A -> A -> A -> A -> A A -> B -> A -> A -> A In the last case, it is not necessary to re-calculate A -> A -> A, and what I want to do is to save it away. What would be the best way to do this? Currently, my recursion looks something like this recursion(Item item, int size, int value, String s){ s += cust.getName() + "-"; if(value is bigger) bestMix = s for(Item item : itemList){ if(!(we break the limit){ recursion(item, size + item.getSize(), value + item.getValue(), s); } } } What I want to do, is to fetch already calculated values when doing the recursion. What would be the simplest and smartest way to do this in order to lower the time complexity?
oalsing