Added PlaceImage model, admin stuff, migrations with reference to Place.
This commit is contained in:
parent
ad916af5fb
commit
acfdcd99ba
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@ local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
media
|
||||
uploads
|
||||
|
||||
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
|
||||
# in your Git repository. Update and uncomment the following line accordingly.
|
||||
|
@ -14,9 +14,11 @@ Including another URLconf
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.urls import path, include
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include('lostplaces_app.urls')),
|
||||
]
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
@ -4,3 +4,4 @@ from .models import *
|
||||
# Register your models here.
|
||||
|
||||
admin.site.register(Place)
|
||||
admin.site.register(PlaceImage)
|
@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.0.8 on 2020-07-27 17:58
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('lostplaces_app', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='PlaceImage',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('filename', models.ImageField(max_length=50, upload_to='places/%Y/%m/')),
|
||||
('description', models.TextField()),
|
||||
('place', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='lostplaces_app.Place')),
|
||||
],
|
||||
),
|
||||
]
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.8 on 2020-07-27 18:01
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('lostplaces_app', '0002_placeimage'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='placeimage',
|
||||
name='description',
|
||||
field=models.TextField(null=True),
|
||||
),
|
||||
]
|
@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.0.8 on 2020-07-27 18:03
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('lostplaces_app', '0003_auto_20200727_1801'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='placeimage',
|
||||
name='description',
|
||||
field=models.TextField(blank=True, default=''),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
@ -8,4 +8,14 @@ class Place (models.Model):
|
||||
latitude = models.FloatField()
|
||||
longitude = models.FloatField()
|
||||
description = models.TextField()
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class PlaceImage (models.Model):
|
||||
filename = models.ImageField(upload_to='places/%Y/%m/', max_length=50)
|
||||
place = models.ForeignKey(Place, on_delete=models.CASCADE, related_name='images')
|
||||
description = models.TextField(blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return ' '.join([self.place.name, str(self.pk)])
|
||||
|
Loading…
Reference in New Issue
Block a user