Add datetime object without timezone
django
Solution
Just create custom model field :) Easy and simple.
class MytypeField(models.Field):
def db_type(self, connection):
return 'timestamp'
class Test(models.Model):
name = models.CharField(max_length=80)
something_else = MytypeField()
"timestamp" is for postgresql, for mysql should "datetime"
Problem
i wanna add datetime object which i create from user input. But i wanna add this without timezone only in this model. I tried few different way but none working. models.py ``` class troops_command(models.Model): datetime = models.DateTimeField('ki') ``` How i create object: ``` datetime_object = datetime_module.datetime.strptime(datetime_string, format_datetime) import pytz datetime_object = pytz.timezone("Europe/London").localize(datetime_object, is_dst=None) ``` After this: ``` >>> print(datetime_object) 2014-11-22 14:49:00+00:00 ``` But when i add this to database: ``` Troops_command_model.objects.create(datetime=datetime) ``` Database return: ``` 2014-11-22 15:49:00+01 ``` settings.py ``` TIME_ZONE = 'Europe/Warsaw' ```