-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac0c037
commit 1ad1954
Showing
4 changed files
with
44 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
from django.contrib import admin | ||
from django.utils.html import escape, mark_safe | ||
|
||
from sublet.models import Amenity, Favorite, Offer, Sublet, SubletImage | ||
|
||
class SubletAdmin(admin.ModelAdmin): | ||
def image_tag(self, instance): | ||
images = ['<img src="%s" height="150" />' for image in instance.images.all()] | ||
return mark_safe('<br>'.join(images)) | ||
|
||
image_tag.short_description = "Sublet Images" | ||
readonly_fields = ("image_tag",) | ||
|
||
admin.site.register(Offer) | ||
admin.site.register(Amenity) | ||
admin.site.register(Sublet) | ||
admin.site.register(Sublet, SubletAdmin) | ||
admin.site.register(SubletImage) | ||
admin.site.register(Favorite) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 3.2.21 on 2023-10-24 21:54 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('sublet', '0004_alter_sublet_favorites'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='sublet', | ||
name='favorites', | ||
field=models.ManyToManyField(blank=True, null=True, related_name='sublets_favorited', through='sublet.Favorite', to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AlterField( | ||
model_name='sublet', | ||
name='sublettees', | ||
field=models.ManyToManyField(blank=True, null=True, related_name='sublets_offered', through='sublet.Offer', to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
This file contains 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
This file contains 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