browsers Browser objects all app Application objects get_or_create nam

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
browsers = Browser.objects.all()
app = Application.objects.get_or_create(name=app_name)[0]
#первый вариант:
supported_browsers = []
not_supported_browsers = []
for b in browsers:
if b in app.browsers.all():
supported_browsers.append(b.__unicode__())
else:
not_supported_browsers.append(b.__unicode__())
#второй вариант:
supported_browsers = [ b.__unicode__() for b in browsers if b in app.browsers.all() ]
not_supported_browsers = [ b.__unicode__() for b in browsers if b not in app.browsers.all() ]