It depends on what you want. You can set 'created_by' to blank=True and
null=False, so it doesn't have to be filled but it is still mandatory in the
database. Or, if you never want to set it in the form, you can make it
'editable=False' and it doesn't show up in the form, but it can still be NOT
NU
On 21 mar, 22:38, Bjunix wrote:
> You probably want to change the attributes of the model object
> directly.
>
> "If you call save() with commit=False, then it will return an object
> that hasn't yet been saved to the database."
> Source:http://docs.djangoproject.com/en/dev/topics/forms/modelfor
You probably want to change the attributes of the model object
directly.
"If you call save() with commit=False, then it will return an object
that hasn't yet been saved to the database."
Source:
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method
So I would do something
hi.
I have a ModelForm based on an Model like this:
class MyModel(models.Model):
attr1 = models.CharField()
attr2 = models.CharField()
attr3 = models.CharField()
createdby = models.ForeignKey(User, related_name='createdby',
db_column='createdbyid')
calculatedfield = models.CharField()
4 matches
Mail list logo