Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Admins.py
- from django.contrib import admin
- from .models import users, libary, loan
- admin.site.register(users)
- admin.site.register(libary)
- admin.site.register(loan)
- #Models.py
- from django.db import models
- from django.utils import timezone
- class users(models.Model):
- IdOfUser = models.AutoField(primary_key = True)
- first_name = models.CharField(max_length = 50)
- surname = models.CharField(max_length = 50)
- def published(self):
- self.save()
- def __str__(self):
- return self.first_name + " " + self.surname
- class libary(models.Model):
- IdOfBook = models.AutoField(primary_key = True)
- NameOfBook = models.CharField(max_length = 50)
- Author = models.CharField(max_length = 50)
- def published(self):
- self.save()
- def __str__(self):
- return self.NameOfBook +" "+ self.Author
- class loan(models.Model):
- IdOfUser= models.ForeignKey(users, on_delete = models.CASCADE)
- IdOfBook = models.ForeignKey(libary, on_delete = models.CASCADE)
- def published(self):
- self.save()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement