Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango/MySQL time datatype
    primarykey
    data
    text
    <p>I´m using Django to import from an existing mysql database thats already created and is used by somebody else. Im using:</p> <pre><code>python manage.py inspectdb &gt; models.py </code></pre> <p>And the class from my model in question is the following:</p> <pre><code>class Funciones(models.Model): idfuncion = models.IntegerField(primary_key=True) idpelicula = models.ForeignKey(Peliculas, db_column='idpelicula') idcine = models.ForeignKey(Cines, db_column='idcine') hora = models.TextField() # This field type is a guess. tipo_3d = models.IntegerField(null=True, db_column=u'3d', blank=True) # Field renamed xd = models.IntegerField(null=True, blank=True) gtmax = models.IntegerField(null=True, blank=True) vip = models.IntegerField(null=True, blank=True) idioma = models.CharField(max_length=33) idciudad = models.ForeignKey(Ciudades, db_column='idciudad') class Meta: db_table = u'funciones' </code></pre> <p>Now this attribute: <strong><em>hora = models.TextField() # This field type is a guess</em></strong> </p> <p>corresponds to a <em>time</em> dataType in MYSQL. Now, since I cant change the dataType in MYSQL because somebody else has already created a number of queries to the database from another app, I would like to know what would be the appropriate corresponding django datatype that I should use in my django model. I was thinking <em>DateTimeField</em> but then I should have to somehow truncate the date part before writing to the database.</p> <p>Any ideas?</p> <p>Thanks</p> <p><strong>Edit:</strong></p> <p>As pointed out by Pedro: </p> <p>Django actually has a TimeField, why not use that? – Pedro Romano</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload