<div dir="ltr"><div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Ho </span><a href="http://models.py/" target="_blank" rel="noopener noreferrer" style="box-sizing:border-box;background:0px 0px rgb(228,236,242);color:rgb(58,109,153);text-decoration-line:none;font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap">models.py</a><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> come il seguente</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">class Roles( models.Model ):</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> role = models.CharField( max_length=30 )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> level = models.IntegerField( default = 0 )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">class Operators( models.Model ):</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> login = models.CharField( max_length=30 )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> password = models.CharField( max_length=50 )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> role = models.ForeignKey( "Roles", related_name="Operators_Roles" )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> active = models.BooleanField( default=False ) </span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Definisco una funzione</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">def insert( table, data ):</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">  tab = table( **data )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">  </span><a href="http://tab.save/" target="_blank" rel="noopener noreferrer" style="box-sizing:border-box;background:0px 0px rgb(228,236,242);color:rgb(58,109,153);text-decoration-line:none;font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap">tab.save</a><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">()</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Provo a usarla e in effetti va tutto bene</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">insert( Roles, {'role': 'admin', 'level':1} )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">insert( Operators, {</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> 'login': 'administrator',</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> 'password': 'xxxxxxx',</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> 'role_id': 1,</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> 'active': True,</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">})</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Mi chiedo, perche' mi viene in mente che una cosa simile posa essere una bad practice?</span><br clear="all"></div><div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br></span></div><div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Si accettano crtiche e pomodorate</span><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br></span></div><div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br></span></div><div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Mi era venuto in mente per creare dei generici setters (Insert/Update e Delete) e getters (get_all, get_element_by_key, get_filtered_elements) e non dover fare la stessa cosa per ciascuna classe, ma ho idea che possa dare qualche problema</span><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br></span></div><div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br></span></div><div><div class="gmail_default" style="font-size:small">Carlos</div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">EZLN ... Para Todos Todo ... Nada para nosotros<br></div></div></div></div></div>