jeudi 22 avril 2021

Django model modification

Ok, i have this django app, where the user fills in their detail and then create a web profile(username and password)

from django.db import models

class UserDetail(models.Model):
    first_name = models.CharField(max_length=225)
    middle_name = models.CharField(max_length=255, blank=True, null=True)
    last_name = models.CharField(max_length=255)
    email = models.EmailField()

    def __str__(self):
        return self.first_name


class WebDetail(UserDetail):
    # user = models.OneToOneField(UserDetail, on_delete=models.CASCADE, primary_key=True,)
    username = models.CharField(max_length=255)
    password = models.CharField(max_length=255)

and when i create a user that has a webdetail, it shows empty in the database(django admin)

I need help to link the WebDetail to inherit from the userdetail and also they could show up in the database(django admin)

Thanks for your contribution :)




Aucun commentaire:

Enregistrer un commentaire