<div dir="ltr">Without diving into the django code, I'm guessing that the problem is the default value for text fields is a blank string. I bet if you set the default=None on fields that don't accept null, they would become 'required' (although I don't think this concept actually exists in django at the model level).<div><br></div><div>I think Fabricio's solution would work. However, it doesn't 'require' fields so much as prevent blank strings from being saved in the database. And I think that's what we want?<br><div><div><div><div><div dir="ltr" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><br></div><div>David<br></div></div></div></div></div></div></div></div><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 18, 2019 at 3:15 PM Fabricio Aguiar <<a href="mailto:fabricio.aguiar@redhat.com" target="_blank">fabricio.aguiar@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">the best way that I found so far is this:<div><a href="https://stackoverflow.com/a/56272674/5253051" target="_blank">https://stackoverflow.com/a/56272674/5253051</a><br><div><img src="cid:ii_k34v8x550" alt="image.png" width="562" height="356">4<br></div><div><a href="https://stackoverflow.com/a/56272674/5253051" target="_blank"></a><br></div><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><br>Best regards,</div><div dir="ltr"><span style="color:rgb(0,0,0);font-family:RedHatText,sans-serif;font-size:14px;font-weight:700;text-transform:capitalize">Fabricio</span><span style="color:rgb(0,0,0);font-family:RedHatText,sans-serif;font-size:14px;font-weight:700;text-transform:capitalize"> </span><span style="color:rgb(0,0,0);font-family:RedHatText,sans-serif;font-size:14px;font-weight:700;text-transform:capitalize">Aguiar</span><div>Software Engineer, Pulp Project</div><div><a href="https://www.redhat.com/" style="color:rgb(0,136,206);font-family:RedHatText,sans-serif;font-size:12px;margin:0px" target="_blank">Red Hat Brazil - Latam</a><br></div><div>+55 11 999652368</div><div><img src="https://marketing-outfit-prod-images.s3-us-west-2.amazonaws.com/f5445ae0c9ddafd5b2f1836854d7416a/Logo-RedHat-Email.png" width="96" height="22"></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 18, 2019 at 5:09 PM Tatiana Tereshchenko <<a href="mailto:ttereshc@redhat.com" target="_blank">ttereshc@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I noticed that there is no enforcement at the DB level to require certain fields to be present on a model.<div><br></div><div>I haven't checked all the field types but at least for TextField it's seems to be true.</div><div>Even though `null` is False by default (`blank` as well), I can save a model instance without most of fields set.</div><div><br></div><div>As an example, for UpdateRecord [0] in RPM plugin, plugin writer can do UpdateRecord().save() and it will be fine, all the fields are set to empty string :/ It wouldn't be possible to save it twice but it's due to the uniqueness constraints.</div><div><br></div><div>In case plugin writer doesn't set properly all the required fields, bad/corrupted model instances will be silently saved in the DB and plugin can potentially have data migration issues later.</div><div><br></div><div>Any suggestions how to handle that? Or do I miss anything?</div><div><br></div><div>Tanya</div><div><br></div><div>[0] <a href="https://github.com/pulp/pulp_rpm/blob/master/pulp_rpm/app/models.py#L440-L463" target="_blank">https://github.com/pulp/pulp_rpm/blob/master/pulp_rpm/app/models.py#L440-L463</a></div></div>
_______________________________________________<br>
Pulp-dev mailing list<br>
<a href="mailto:Pulp-dev@redhat.com" target="_blank">Pulp-dev@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-dev</a><br>
</blockquote></div>
_______________________________________________<br>
Pulp-dev mailing list<br>
<a href="mailto:Pulp-dev@redhat.com" target="_blank">Pulp-dev@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-dev</a><br>
</blockquote></div>