class Model(ModelBase):
some = models.CharField(_("Что то "), max_length=250)
@classmethod
def get_model(cls):
return cls.objects.filter(title__icontains="123")
from core.models import Model
Model.get_model()
<QuerySet []>
m1 = Model(title="123")
m1.save()
Model.get_model()
<QuerySet [<Model: 123>]>
class ModelBase(models.Model):
title = models.CharField(_("Название"), max_length=250, blank=False)
def __str__(self):
return self.title
class Model(ModelBase):
some = models.CharField(_("Что то "), max_length=250)
class Model1(ModelBase):
some = models.CharField(_("Что то "), max_length=250)
m = models.ForeignKey(Model, on_delete=models.CASCADE)
class Model2(ModelBase):
some = models.CharField(_("Что то "), max_length=250)
m1 = models.ForeignKey(Model1, on_delete=models.CASCADE)
class Model3(ModelBase):
some = models.CharField(_("Что то "), max_length=250)
m2 = models.ForeignKey(Model2, on_delete=models.CASCADE)
from core.models import *
m1 = Model.objects.all()
m1[0].model1_set
<django.db.models.fields.related_descriptors.create_reverse_many_to_one_manager.<locals>.RelatedManager object at 0x00000296EFFAAE20>
m1[0].model1_set.all()[0].model2_set.all()[0].model3_set.all()[0].some
'some m3'
class SensorForm(ModelForm):
class Meta:
model = Sensors
fields = ['name ', 'x', 'y', 'h','sensors ']
from .forms import SensorForm
def sensortoroom(request, room_id):
room = Rooms.objects.filter(id=room_id)
form = SensorForm()
if request.POST:
pass
return render(request, 'room/addsensortoroom.html', {'form': form})
[mkr@mkr-gw] /ip firewall nat> add chain=dstnat protocol=tcp in-interface=ether1 port=33389 action=dst-nat to-addresses=192.168.192.
168 to-ports=3389
//Блочим всех кто в списке
[mkr@mkr-gw] /ip firewall filter> add chain=input address-list=block action=drop
//Добавим в список того, кто по новым соединениям собрался на 3389
[mkr@mkr-gw] /ip firewall filter> add dst-port=3389 connection-state=new in-interface=ether1 action=add-dst-to-address-list address-
list=block chain=input