Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 18995

Insert only to specific fields in formModel in django

$
0
0

I have a django model and its corresponding form to insert into and read value from a table with three columns in database. My requirement is I only need to insert in to say two column using form, leaving the third column which is a date field. But I have a requirement to read all three column to display it in html in later time. When I use exclude in the form it works good for the html part but when trying to save the form using form.save(), it tries to insert null in the the third column and raise error. Can anybody please help me to omit the third column completely while saving the form.

Class sales(models.Model)    product_name = models.CharField(max_length=500)    quantity=models.FloatField()    sale_date=models.DateField()

I was looking for a solution where one override the save() to omit this field before saving. But I am not able to find it.


Viewing all articles
Browse latest Browse all 18995

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>