I want to add a field in the Post class that stores the ip of the person who sends the form. This is my "models.py" file
from django.db import models
from django.utils import timezone
class Post(models.Model):
author = models.ForeignKey('auth.User')
title = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(default=timezone.now)
published_date = models.DateTimeField(blank=True, null=True)
def publish(self):
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title
I have tried to put genericipaddress_field = models.GenericIPAddressField(blank=True, null=True)
in the Post model, but evidently it has not worked and you have saved it blank