Django 2.2: generate model from table

2019-07-21 09:14:37+00


python3.6 manage.py inspectdb entry
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#   * Rearrange models' order
#   * Make sure each model has one field with primary_key=True
#   * Make sure each ForeignKey has `on_delete` set to the desired behavior.
#   * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models


class Entry(models.Model):
    id = models.CharField(primary_key=True, max_length=36)
    created = models.DateTimeField(blank=True, null=True)
    modified = models.DateTimeField(blank=True, null=True)
    etyp = models.CharField(max_length=1)
    etitle = models.CharField(max_length=80)
    eurl = models.CharField(max_length=255, blank=True, null=True)
    etext = models.CharField(max_length=12000, blank=True, null=True)
    etag2 = models.TextField(blank=True, null=True)  # This field type is a guess.

    class Meta:
        managed = False
        db_table = 'entry'

Tag: django2