- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
def add_services_to_context(context_dict):
services = Service.objects.filter(is_active=True)
try:
serv0 = services.get(service=0).content
except Service.DoesNotExist:
serv0 = ''
except Service.MultipleObjectsReturned:
serv0 = services.filter(service=0).first().content
try:
serv1 = services.get(service=1).content
except Service.DoesNotExist:
serv1 = ''
except Service.MultipleObjectsReturned:
serv1 = services.filter(service=1).first().content
try:
serv2 = services.get(service=2).content
except Service.DoesNotExist:
serv2 = ''
except Service.MultipleObjectsReturned:
serv2 = services.filter(service=2).first().content
try:
serv3 = services.get(service=3).content
except Service.DoesNotExist:
serv3 = ''
except Service.MultipleObjectsReturned:
serv3 = services.filter(service=3).first().content
try:
serv4 = services.get(service=4).content
except Service.DoesNotExist:
serv4 = ''
except Service.MultipleObjectsReturned:
serv4 = services.filter(service=4).first().content
try:
serv5 = services.get(service=5).content
except Service.DoesNotExist:
serv5 = ''
except Service.MultipleObjectsReturned:
serv5 = services.filter(service=5).first().content
try:
serv6 = services.get(service=6).content
except Service.DoesNotExist:
serv6 = ''
except Service.MultipleObjectsReturned:
serv6 = services.filter(service=6).first().content
try:
serv7 = services.get(service=7).content
except Service.DoesNotExist:
serv7 = ''
except Service.MultipleObjectsReturned:
serv7 = services.filter(service=7).first().content
try:
serv9 = services.get(service=9).content
except Service.DoesNotExist:
serv9 = ''
except Service.MultipleObjectsReturned:
serv9 = services.filter(service=9).first().content
try:
serv10 = services.get(service=10).content
except Service.DoesNotExist:
serv10 = ''
except Service.MultipleObjectsReturned:
serv10 = services.filter(service=10).first().content
try:
serv11 = services.get(service=11).content
except Service.DoesNotExist:
serv11 = ''
except Service.MultipleObjectsReturned:
serv11 = services.filter(service=11).first().content
services_dict = {
'0': serv0,
'1': serv1,
'2': serv2,
'3': serv3,
'4': serv4,
'5': serv5,
'6': serv6,
'7': serv7,
'9': serv9,
'10': serv10,
'11': serv11,
}
context_dict['services'] = services_dict
HomoAlbus 18.01.2016 11:22 # +2
roman-kashitsyn 18.01.2016 11:31 # +3
Vindicar 18.01.2016 13:44 # 0
gost 18.01.2016 16:16 # +1
KOCTbIJIb 18.01.2016 17:00 # +1
gost 18.01.2016 19:54 # +1
Я слышал, что dict очень быстрый! Аж O(1)!