Wednesday, May 30, 2018

Re: Django Model




import whois

class Domains(models.Model):
domainname = models.CharField(max_length=200, blank=True)
domainuser = models.ForeignKey(User, on_delete=models.CASCADE)
details = whois.whois(domainname)
w = str(details.expiration_date)
domainwhois = models.DateField(default=w)

def __str__(self):
return self.domainname

Domains.save()


after you definded the save method 


domaine=Domaine()
domaine.domainename=.....
domaine.domaineuser=User.objects.last()
domaine.details=.......

domaine.save()

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3d70235f-5c03-4f1d-85e6-b1132f3333de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment