Skip to content

Tag: django

Django DateTimeField auto_now_add not working

In one of the model i have set one timestamp field as follows: While in shell i am able to create a obj and save it, however in my application it is raising a exception that created_datetime field cannot be null. Confused where things went wrong!! How to reslove it. Answer You can do something like this

Generating PDFs from SVG input

I am trying to generate a PDF from a SVG input file with Python in a Django application. I have already found 2 working solutions: cairo+rsvg and imagemagick but they both have one problem: They have …

Change text_factory in Django/sqlite

I have a django project that uses a sqlite database that can be written to by an external tool. The text is supposed to be UTF-8, but in some cases there will be errors in the encoding. The text is from an external source, so I cannot control the encoding. Yes, I know that I could write a “wrapping layer”

How does Django save decimal values?

What am I doing wrong? I do something like that: count is the sum of all ratings of given MyModel and votes is an array of those ratings, their division gives an average rating for MyModel (sorry if I described it incorrectly due to my poor English). If i change previous to: Then ‘anything’ ends […]

django – inlineformset_factory with more than one ForeignKey

Im trying to do a formset with the following models (boost is the primary): class boost(models.Model): creator = models.ForeignKey(userInfo) game = models.ForeignKey(gameInfo) name = models.CharField(max_length=200) desc = models.CharField(max_length=500) rules = models.CharField(max_length=500) subscribe = models.IntegerField(default=0) class userInfo(models.Model): pic_url= models.URLField(default=0, blank=True) auth = models.ForeignKey(User, unique=True) birth = models.DateTimeField(default=0, blank=True) country= models.IntegerField(default=0, blank=True) class gameInfo(models.Model): psn_id = models.CharField(max_length=100) name = models.CharField(max_length=200) publisher =