[Django] Model definitions

Rex Chiang
Mar 8, 2021

--

class User_info(models.Model):
name = models.CharField(max_length = 32)
pwd = models.CharField(max_length = 32)

class Meta:
verbose_name = "Users Table"
verbose_name_plural = verbose_name

def __str__(self):
return self.name

Meta :

Relative setting of your model, and it’s completely optional.

verbose_name :

Alias with for your model, and default is your model name.

verbose_name_plural :

The plural of verbose_name, and the default is verbose_name + “s”.

__str__ :

The output when you print your instance, and also show in django-admin panel.

--

--

No responses yet