how to create a model object in django code example
Example 1: django objects.create()
SomeModel.objects.create(firstname='ricky', lastname='ticky')
Example 2: get_absolute_url django
def get_absolute_url(self):
from django.core.urlresolvers import reverse
return reverse('', kwargs={'pk': self.pk})
Example 3: django model example
from django.db import models
class myModel(models.Model):
input1 = models.CharField(max_length=100)
input2 = models.TextField()
input3 - models.DateTimeField(auto_now=True)
def __str__(self):
return self.input1