Skip to content

Instantly share code, notes, and snippets.

@pedrohsbarbosa99
Created November 14, 2020 16:08
Show Gist options
  • Save pedrohsbarbosa99/393d4d9022fa8c3fc6dac16aaba11671 to your computer and use it in GitHub Desktop.
Save pedrohsbarbosa99/393d4d9022fa8c3fc6dac16aaba11671 to your computer and use it in GitHub Desktop.
from django.contrib import admin
from .models import Category, Contact
admin.site.register(Category)
admin.site.register(Contact)
from django.db import models
from django.utils import timezone
class Category(models.Model):
name = models.CharField(max_length=255)
def __str__(self):
return self.name
class Contact(models.Model):
name = models.CharField(max_length=255),
surname = models.CharField(max_length=255, blank=True),
phone = models.CharField(max_length=20),
email = models.CharField(max_length=100, blank=True),
created_at = models.DateTimeField(default=timezone.now),
description = models.TextField(blank=True),
categoty = models.ForeignKey(Category, on_delete=models.DO_NOTHING)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment