Sunday, November 28, 2010

Splitting date and time from Models

Hi,
suppose I have the models.py:

SHORT_DATE_FORMAT = "%d - %b - %y"
DATE_FORMAT= "%Y-%m-%d"
TIME_FORMAT= "%H:%M"

class Job(models.Model):
job_id = models.AutoField(primary_key=True)
job_title = models.CharField(max_length=50, verbose_name =
"Title")
job_desc = models.CharField(max_length=500, verbose_name =
"Description")
active_datetime_fr = models.DateTimeField()
active_datetime_to = models.DateTimeField()

def __unicode__(self):
return (self.job_title)
def From(self):
return self.active_datetime_fr.date().strftime(SHORT_DATE_FORMAT)
def To(self):
return
self.active_datetime_to.date().strftime(SHORT_DATE_FORMAT)
def editDatefr(self):
return self.active_datetime_fr.date().strftime(DATE_FORMAT)
def editDateto(self):
return self.active_datetime_to.date().strftime(DATE_FORMAT)
def editTimefr(self):
return self.active_datetime_fr.time().strftime(TIME_FORMAT)
def editTimeto(self):
return self.active_datetime_to.time().strftime(TIME_FORMAT)

how do I spit the active_datetime_fr model field into two possible
inputs, example:
Active Date From:
Date: (Date Input) Time: (Time Input)

Thanks in advance
Cheers,
Marge

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment