This is the link to my previous question which will help you understand this question (How do I use localstorage.getItem or setItem to send a post request in my react application?). Thanks to you guys, I can successfully make a post request in the frontend (react). However, am unable to automatically include or save the user in the database record. The username field in the database table is blank. The username field is automatically included when creating a post request in the admin page but not in frontend react. The previous question includes all the relevant code. Below is the model class. I am using custom user model and hence the email is my username:
class ClientInformation(models.Model):
user = models.OneToOneField(
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True)
age = models.TextField(max_length=10)
phone_number = models.TextField(max_length=20)
country = models.TextField(max_length=30)
city = models.TextField(max_length=30, blank=False)
alergy = models.TextField(max_length=500, null=True, default=None)
gender = models.TextField(max_length=20, null=False, blank=False)
last_update = models.DateTimeField(default=now)