note = Notes.objects.get()
from somemodule.models import SomeModel
, import somemodule.models as somemodule_models
somemodule_models.SomeModel.objects(...)...
banners = ['banner1', 'banner2', 'banner3']
posts = ['post1', 'post2', 'post3', 'post4', 'post5', 'post6', 'post7', 'post8']
banner_step = 2
for index, post in enumerate(posts):
print(post)
if (index+1) % banner_step == 0 and banners:
print(banners.pop(0))
post1
post2
banner1
post3
post4
banner2
post5
post6
banner3
post7
post8
from django.db import connection
with connection.cursor() as cursor:
cursor.execute('INSERT INTO sometable (somefield) VALUES (ping_list)');
from typing import Any, Dict, List
from django.db import connection
with connection.cursor() as cursor:
cursor.execute('SELECT DISTINCT category_name FROM some_table_name;')
columns = [col[0] for col in cursor.description]
rows: List[Dict[Any, Any]] = []
row = cursor.fetchone()
while row:
rows.append(dict(zip(columns, row)))
row = cursor.fetchone()
print(rows)
volumes:
static_volume:
/var/lib/docker/volumes/static_volume/_data
t = ('one', 'two', 'three')
a, _, b = t
>> a
>> 'one'
>>_
>>'two'
>>b
>>'three'
for _, value in some_dict.items():
pass
class StartPlace(models.Model):
start_point = models.ArrayField(max_length=10)
icon = models.CharField(max_length=50)
url = models.ArrayField(max_length=10)
class Point(models.Model):
end_place = models.ArrayField(max_length=10)
icon = models.CharField(max_length=50)
start_place = models.ManyToManyField(StartPlace)