init new apps
This commit is contained in:
0
lettings/__init__.py
Normal file
0
lettings/__init__.py
Normal file
3
lettings/admin.py
Normal file
3
lettings/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
5
lettings/apps.py
Normal file
5
lettings/apps.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class LettingsConfig(AppConfig):
|
||||
name = 'lettings'
|
||||
36
lettings/migrations/0001_initial.py
Normal file
36
lettings/migrations/0001_initial.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# Generated by Django 3.0 on 2025-09-04 15:36
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Address',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('number', models.PositiveIntegerField(validators=[django.core.validators.MaxValueValidator(9999)])),
|
||||
('street', models.CharField(max_length=64)),
|
||||
('city', models.CharField(max_length=64)),
|
||||
('state', models.CharField(max_length=2, validators=[django.core.validators.MinLengthValidator(2)])),
|
||||
('zip_code', models.PositiveIntegerField(validators=[django.core.validators.MaxValueValidator(99999)])),
|
||||
('country_iso_code', models.CharField(max_length=3, validators=[django.core.validators.MinLengthValidator(3)])),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Letting',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=256)),
|
||||
('address', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='lettings.Address')),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
lettings/migrations/__init__.py
Normal file
0
lettings/migrations/__init__.py
Normal file
23
lettings/models.py
Normal file
23
lettings/models.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.db import models
|
||||
from django.core.validators import MaxValueValidator, MinLengthValidator
|
||||
|
||||
|
||||
class Address(models.Model):
|
||||
number = models.PositiveIntegerField(validators=[MaxValueValidator(9999)])
|
||||
street = models.CharField(max_length=64)
|
||||
city = models.CharField(max_length=64)
|
||||
state = models.CharField(max_length=2, validators=[MinLengthValidator(2)])
|
||||
zip_code = models.PositiveIntegerField(validators=[MaxValueValidator(99999)])
|
||||
country_iso_code = models.CharField(max_length=3, validators=[MinLengthValidator(3)])
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.number} {self.street}'
|
||||
|
||||
|
||||
class Letting(models.Model):
|
||||
title = models.CharField(max_length=256)
|
||||
address = models.OneToOneField(Address, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
3
lettings/tests.py
Normal file
3
lettings/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
lettings/views.py
Normal file
3
lettings/views.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
@@ -28,6 +28,8 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'lettings',
|
||||
'profiles'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
||||
0
profiles/__init__.py
Normal file
0
profiles/__init__.py
Normal file
3
profiles/admin.py
Normal file
3
profiles/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
5
profiles/apps.py
Normal file
5
profiles/apps.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ProfilesConfig(AppConfig):
|
||||
name = 'profiles'
|
||||
25
profiles/migrations/0001_initial.py
Normal file
25
profiles/migrations/0001_initial.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# Generated by Django 3.0 on 2025-09-04 15:36
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Profile',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('favorite_city', models.CharField(blank=True, max_length=64)),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
profiles/migrations/__init__.py
Normal file
0
profiles/migrations/__init__.py
Normal file
11
profiles/models.py
Normal file
11
profiles/models.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class Profile(models.Model):
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||
favorite_city = models.CharField(max_length=64, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.user.username
|
||||
|
||||
3
profiles/tests.py
Normal file
3
profiles/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
profiles/views.py
Normal file
3
profiles/views.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user