mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2025-06-28 16:15:44 +08:00
Clean up docker-compose and run Black formatter over entire codebase
This commit is contained in:
parent
6c232b3e89
commit
069aba80b1
60 changed files with 1946 additions and 1485 deletions
|
@ -7,12 +7,11 @@ from unfold.contrib.filters.admin import RangeDateFilter
|
|||
@admin.register(SearchResult)
|
||||
class SearchResultAdmin(ModelAdmin):
|
||||
model = SearchResult
|
||||
search_fields = ('id', 'title', 'link')
|
||||
list_display = ['id', 'title', 'timestamp']
|
||||
search_fields = ("id", "title", "link")
|
||||
list_display = ["id", "title", "timestamp"]
|
||||
|
||||
list_filter_submit = True
|
||||
list_filter = ((
|
||||
"timestamp", RangeDateFilter
|
||||
), (
|
||||
"timestamp", RangeDateFilter
|
||||
),)
|
||||
list_filter = (
|
||||
("timestamp", RangeDateFilter),
|
||||
("timestamp", RangeDateFilter),
|
||||
)
|
||||
|
|
|
@ -2,5 +2,5 @@ from django.apps import AppConfig
|
|||
|
||||
|
||||
class SearchResultsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'search_results'
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "search_results"
|
||||
|
|
|
@ -7,17 +7,24 @@ class Migration(migrations.Migration):
|
|||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
dependencies = []
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SearchResult',
|
||||
name="SearchResult",
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=1000)),
|
||||
('link', models.CharField(max_length=1000)),
|
||||
('timestamp', models.DateTimeField(auto_now_add=True)),
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("title", models.CharField(max_length=1000)),
|
||||
("link", models.CharField(max_length=1000)),
|
||||
("timestamp", models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
|
||||
|
||||
from celery import shared_task
|
||||
from .models import SearchResult
|
||||
|
||||
|
||||
@shared_task(autoretry_for=(Exception,), retry_kwargs={'max_retries': 0, 'countdown': 5})
|
||||
@shared_task(
|
||||
autoretry_for=(Exception,), retry_kwargs={"max_retries": 0, "countdown": 5}
|
||||
)
|
||||
def create_search_result(title, link):
|
||||
if SearchResult.objects.filter(title=title, link=link).exists():
|
||||
return ("SearchResult entry already exists")
|
||||
return "SearchResult entry already exists"
|
||||
else:
|
||||
SearchResult.objects.create(
|
||||
title=title,
|
||||
link=link
|
||||
)
|
||||
SearchResult.objects.create(title=title, link=link)
|
||||
return f"Created new SearchResult entry titled: {title}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue