This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ceo(models.Model): | |
name = models.CharField(max_length=255, blank=True) | |
car = models.OneToOneField(Car, on_delete=models.SET_NULL, blank=True, null=True) | |
def __str__(self): | |
return self.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Car(models.Model): | |
name = models.CharField(max_length=255) | |
def __str__(self): | |
return self.name | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Car(models.Model): | |
name = models.CharField(max_length=255) | |
class Ceo(models.Model): | |
car = models.OneToOneField(Car, on_delete=models.CASCADE) | |
name = models.CharField(max_length=255, blank=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FuelType(models.Model): | |
name = models.CharField(max_length=255) | |
class CarModel(models.Model): | |
name = models.CharField(max_length=255) | |
car = models.ForeignKey(Car, on_delete=models.CASCADE) | |
fueltype = models.ManyToManyField(FuelType) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car(models.Model): | |
name = models.CharField(max_length=255) | |
class CarModel(models.Model): | |
name = models.CharField(max_length=255) | |
car = models.ForeignKey(Car, on_delete=models.CASCADE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car(models.Model): | |
name = models.CharField(max_length=255) | |
class CarInformation(models.Model): | |
car = models.OneToOneField(Car, on_delete=models.CASCADE) | |
address = models.TextField(blank=True) | |
phone = models.CharField(max_length=15, blank=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .models import UserProfile | |
class UserProfileSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = UserProfile | |
fields = ('user', 'bio', 'address', 'phone', 'gender') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Application definition | |
INSTALLED_APPS = [ | |
'django.contrib.admin', | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.messages', | |
'django.contrib.staticfiles', | |
'corsheaders', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.apps import AppConfig | |
class AuthConfig(AppConfig): | |
name = 'auth' | |
label = 'my_auth' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.contrib.auth.models import User | |
class UserProfile(models.Model): | |
user = models.OneToOneField(User, related_name='profile', on_delete=models.CASCADE) | |
bio = models.TextField(blank=True) | |
address = models.TextField(blank=True) | |
phone = models.CharField(max_length=15, blank=True) |