Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too long text server error #177

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions collection/migrations/0008_auto_20190828_0450.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 2.0.1 on 2019-08-28 04:50

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('collection', '0007_auto_20181008_2042'),
]

operations = [
migrations.AlterUniqueTogether(
name='collection',
unique_together=set(),
),
]
15 changes: 15 additions & 0 deletions collection/migrations/0009_auto_20190828_0457.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by Django 2.0.1 on 2019-08-28 04:57

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('collection', '0008_auto_20190828_0450'),
]

operations = [
migrations.RunSQL(
"CREATE UNIQUE INDEX collection_collection_title_text_type_id_uniq ON collection_collection (title, md5(text), type_id)"),
]
2 changes: 0 additions & 2 deletions collection/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,3 @@ def repl(match):
text = Sentence(text=self.text).html # convert words to links
return re.sub(r"{{sentence:([0-9]+)}}", repl, text, flags=re.MULTILINE)

class Meta:
unique_together = ('title', 'text', 'type',)
5 changes: 4 additions & 1 deletion collection/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def keyword_filtered(request):
# eg. poem
collection_type = first_collection_obj.type
# eg. all poems
collections = Collection.objects.filter(type=collection_type)
collections = []
for collection_type in Collection.objects.all().distinct("type"):
collection_sample = Collection.objects.filter(type=collection_type.type).order_by("-id")[0:3]
collections.extend(list(collection_sample))
context["collections"] = collections
context["active_collection"] = collection_type
# to delete <br> from html text
Expand Down