fix foreignkey and loadin
This commit is contained in:
parent
912cd4eea4
commit
528b623acd
19
app/website/migrations/0003_alter_talk_category.py
Normal file
19
app/website/migrations/0003_alter_talk_category.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.2.9 on 2021-11-20 23:04
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('website', '0002_alter_talk_author'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='talk',
|
||||
name='category',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='talk_category', to='website.category', verbose_name='Categoría'),
|
||||
),
|
||||
]
|
23
app/website/migrations/0004_auto_20211121_0751.py
Normal file
23
app/website/migrations/0004_auto_20211121_0751.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.2.9 on 2021-11-21 07:51
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('website', '0003_alter_talk_category'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='talk',
|
||||
name='author',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='talk',
|
||||
name='speaker',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='website.profile', verbose_name='Ponente'),
|
||||
),
|
||||
]
|
24
app/website/migrations/0005_auto_20211121_0757.py
Normal file
24
app/website/migrations/0005_auto_20211121_0757.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Generated by Django 3.2.9 on 2021-11-21 07:57
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('website', '0004_auto_20211121_0751'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='talk',
|
||||
name='category',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='talkcategory', to='website.category', verbose_name='Categoría'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='talk',
|
||||
name='speaker',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='talkspeaker', to='website.profile', verbose_name='Ponente'),
|
||||
),
|
||||
]
|
@ -41,15 +41,15 @@ class Talk(models.Model):
|
||||
Category,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
related_name="Categoría",
|
||||
related_name="talkcategory",
|
||||
verbose_name="Categoría",
|
||||
)
|
||||
author = models.ForeignKey(
|
||||
speaker = models.ForeignKey(
|
||||
Profile,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
related_name="talk_profile",
|
||||
verbose_name="Autor",
|
||||
related_name="talkspeaker",
|
||||
verbose_name="Ponente",
|
||||
)
|
||||
image = models.ImageField(verbose_name="Imagen", upload_to="uploads/talks/")
|
||||
is_draft = models.BooleanField(default=True, verbose_name="¿Es un borrador?")
|
||||
|
@ -1,4 +1,4 @@
|
||||
<form>
|
||||
<form class="link">
|
||||
{# Primary data #}
|
||||
<input type="hidden" name="action" value="{{ action }}">
|
||||
<input type="hidden" name="value" value="{{ value }}">
|
||||
@ -7,5 +7,5 @@
|
||||
<input type="hidden" name="page" value="{{ page }}">
|
||||
{% endif %}
|
||||
{# Button #}
|
||||
<button type="button" hx-ws="send" hx-trigger="click">{{ text }}</button>
|
||||
<button class="link__button" type="button" hx-ws="send" hx-trigger="click">{{ text }}</button>
|
||||
</form>
|
@ -9,12 +9,12 @@
|
||||
{{ profile.full_name }}
|
||||
</h2>
|
||||
<p>
|
||||
<img src="{{ profile.avatar.url }}" alt="{{ profile.full_name }}">
|
||||
{# <img src="{{ profile.avatar.url }}" alt="{{ profile.full_name }}"> #}
|
||||
</p>
|
||||
</header>
|
||||
<h3>Talks</h3>
|
||||
<ul>
|
||||
{% for talk in profile.talk_profile_set.all %}
|
||||
{% for talk in profile.talkspeaker.all %}
|
||||
<li>
|
||||
{{ talk.title }}
|
||||
</li>
|
||||
|
@ -44,12 +44,11 @@ def page_profiles():
|
||||
return render_to_string(
|
||||
"pages/profiles.html",
|
||||
{
|
||||
"profiles": Profile.objects.order_by("full_name"),
|
||||
"profiles": Profile.objects.filter(talkspeaker__isnull=False).order_by("full_name").distinct().all(),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
||||
def page_about():
|
||||
return render_to_string("pages/about.html", {})
|
||||
|
||||
|
@ -17,7 +17,7 @@ def run():
|
||||
my_talk = Talk(
|
||||
title=title,
|
||||
category=Category.objects.order_by("?")[0],
|
||||
author=Profile.objects.order_by("?")[0],
|
||||
speaker=Profile.objects.order_by("?")[0],
|
||||
is_draft=False,
|
||||
content=fake.paragraph(nb_sentences=randint(20, 100)),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user