diff --git a/backend/houses/admin.py b/backend/houses/admin.py index 8c38f3f..f937bbe 100644 --- a/backend/houses/admin.py +++ b/backend/houses/admin.py @@ -1,3 +1,15 @@ from django.contrib import admin +from .models import House -# Register your models here. +@admin.register(House) +class HouseAdmin(admin.ModelAdmin): + fields = ( + "name", + "address", + ("price_per_night", "pets_allowed"), + ) + list_display = ("name", "price_per_night", "address", "pets_allowed") + list_filter = ("price_per_night", "pets_allowed") + search_fields = ("address",) + list_display_links = ("name", "address") + list_editable = ("pets_allowed",) \ No newline at end of file diff --git a/backend/houses/migrations/0001_initial.py b/backend/houses/migrations/0001_initial.py new file mode 100644 index 0000000..c1875c9 --- /dev/null +++ b/backend/houses/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.15 on 2024-08-11 01:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='House', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=30)), + ('price', models.PositiveIntegerField()), + ('description', models.TextField()), + ('address', models.CharField(max_length=30)), + ], + ), + ] diff --git a/backend/houses/migrations/0002_rename_price_house_price_per_night.py b/backend/houses/migrations/0002_rename_price_house_price_per_night.py new file mode 100644 index 0000000..d29b8a7 --- /dev/null +++ b/backend/houses/migrations/0002_rename_price_house_price_per_night.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.15 on 2024-08-11 01:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('houses', '0001_initial'), + ] + + operations = [ + migrations.RenameField( + model_name='house', + old_name='price', + new_name='price_per_night', + ), + ] diff --git a/backend/houses/migrations/0003_house_pets_allowed.py b/backend/houses/migrations/0003_house_pets_allowed.py new file mode 100644 index 0000000..9654b12 --- /dev/null +++ b/backend/houses/migrations/0003_house_pets_allowed.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.15 on 2024-08-11 01:36 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('houses', '0002_rename_price_house_price_per_night'), + ] + + operations = [ + migrations.AddField( + model_name='house', + name='pets_allowed', + field=models.BooleanField(default=True), + ), + ] diff --git a/backend/houses/models.py b/backend/houses/models.py index 4c4a959..be3ad55 100644 --- a/backend/houses/models.py +++ b/backend/houses/models.py @@ -1,9 +1,20 @@ from django.db import models class House(models.Model): + """Model Definition for Houses""" name = models.CharField(max_length=30) - price = models.PositiveIntegerField() + price_per_night = models.PositiveIntegerField( + verbose_name="Price", help_text="Positive Numbers Only" + ) description = models.TextField() - address = models.CharField(max_length=30) \ No newline at end of file + address = models.CharField(max_length=140) + pets_allowed = models.BooleanField( + verbose_name="Pets Allowed?", + default=True, + help_text="Does this house allow pets?", + ) + + def __str__(self): + return self.name \ No newline at end of file