I am using angular js material for template and angular js for js. and since no timepicker in angular material js I am using a timepicker of moment.js I am using Django as a backend. I am puting data in the database through rest api the code of my angular template is here:
<md-input-container flex-gt-sm class="md-block">
<label>Opening Time</label>
<md-icon md-svg-src="/cityaplfreelisting/media/time.svg" class="mdicon"></md-icon>
<input required mdc-datetime-picker date="false" time="true" type="text" short-time="true"
show-todays-date click-outside-to-close="true"
auto-ok="true"
min-date="minDate" minute-steps="1"
format="hh:mm a"
ng-change="vm.saveChange()"
ng-model="data.openingTime ">
</md-input-container>
Actually my database is taking the value of openingTime in hh:mm:ss formar through rest api thats why I want to change the input format of time its showing in the format of 2018-01-23T12:38:07.439Z which is not acceptable for my django model
This is my django model
from django.db import models
from django.contrib.gis.db import models as gis_models
from django.contrib.postgres.fields import ArrayField
from django.conf import settings
from django.db.models.signals import pre_save
from django.utils.text import slugify
from multiselectfield import MultiSelectField
class Shop(models.Model):
city = models.ForeignKey(City, on_delete=models.CASCADE)
category = models.ForeignKey(Category, on_delete=models.CASCADE) # will change on_dlt method soon
subCategory = models.ManyToManyField(SubCategory)
filterTags = models.ManyToManyField(FilterTag, blank=True)
owner = models.ForeignKey(settings.AUTH_USER_MODEL,default=1)
slug = models.SlugField(unique=True, blank=True)
shopName = models.CharField(max_length=250)
tagline = models.CharField(blank=True, max_length=500)
bannerImage = models.ImageField(upload_to=upload_location,
default='shop/defaultimage/default.png',
width_field='widthField',
height_field='heightField')
widthField = models.IntegerField(default=0)
heightField = models.IntegerField(default=0)
likes = models.PositiveIntegerField(default=0)
dislikes = models.PositiveIntegerField(default=0)
email = models.EmailField(blank=True)
mobileNo = models.CharField(max_length=14)
alternateMobileNo = models.CharField(max_length=15, blank=True)
location = gis_models.PointField(u'longitude/latitude',
geography=True, blank=True, null=True)
ownerName = models.CharField(blank=True,max_length=250)
shopAddress = models.TextField()
shopPinCode = models.PositiveIntegerField()
openingTime = models.TimeField()
closingTime = models.TimeField()
closingDay = MultiSelectField(choices=DAYS,default=DAYS[7][0])
isActive = models.BooleanField(default=0)
updatedAt = models.DateTimeField(auto_now=True)
timestamp = models.DateTimeField(auto_now_add=True)
gis = gis_models.GeoManager()
objects = models.Manager()
def __str__(self):
return self.shopName
Here is the picture of my time picker
This is picture of json format of openingTime which I am putting through rset api
my django admin (only lower part
Please help by telling what I should do the make the acceptable input time format of time input field