My DataBase has the dates like "2003-08-31" and the django take them like this: "May 9, 2024".How can i change that in Django? At first i was trying something like this date=models.DateField(default="%Y-%m- %d)
Next is try this: from django import forms from django.forms.fields import DEFAULT_DATE_INPUT_FORMATS from django.db import models class EuDateFormField(forms.DateField): def __init__(self, *args, **kwargs): kwargs.update({'input_formats': ("%Y-%m-%d")}) super(EuDateFormField, self).__init__(*args, **kwargs) class EuDateField(models.DateField): def formfield(self, **kwargs): kwargs.update({'form_class': EuDateFormField}) return super(EuDateField, self).formfield(**kwargs) class england(models.Model): div = models.CharField(max_length=2) date = EuDateField('Date Played', null=True, blank=True, help_text="") hometeam = models.CharField(max_length=50) awayteam = models.CharField(max_length=50) fthgoals = models.IntegerField() ftagoals = models.IntegerField() ftresult = models.CharField(max_length=1) ftgoals = models.IntegerField() hthgoals = models.IntegerField() htagoals = models.IntegerField() htresult = models.CharField(max_length=1) hredcards = models.IntegerField() aredcards = models.IntegerField() htrating = models.FloatField() atrating = models.FloatField() rating_diff = models.FloatField() home_team_form = models.IntegerField() away_team_form = models.IntegerField() form_diff = models.IntegerField() htform_at_home = models.IntegerField() atform_at_away = models.IntegerField() home_away_form_diff = models.IntegerField() def over_under(self): if(self.ftgoals>2): return('Over') else: return('Under') over_under.short_description = 'Over/Under' def __unicode__(self): return self.hometeam I try this but nothing change... :( What to do to make DJango read date in Y-m-d form??? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.