Django получить всю связанную дату из Airtable - PullRequest
0 голосов
/ 03 февраля 2020

Могу ли я узнать, как искать дату из Airtable в Django?

ниже мой файл шаблона:

<form action="{% url 'date' %}" method="get" class="form-inline my-2 my-lg-0" style="padding-right: 35px">
          {% csrf_token %}
          <div class="form-group">
          <input class="form-control mr-sm-2" type="date" name="query" class="form-control" >
          <button class="btn btn-outline-primary my-2 my-sm-0" type="submit" value="Search">Search by Date</button>
          </div>
      </form>

мои URL:

urlpatterns = [
path('', views.home, name='home'),
path('create/', views.createoreder, name='order_create'),
path('<str:order_id>/', views.detail, name='detail'),
path('edit/<str:order_id>', views.edit, name='edit'),
path('delete/<str:order_id>', views.delete, name='delete'),
path('Dates/', views.search_by_date, name='date'),

]

my views.py:

def search_by_date(request):
if request.method == "GET":

    user_query = request.GET.get('query', '')
    date = AT.search('{Dates}', user_query)
    #date = AT.get_all(formula="FIND('" + user_query + "', {Dates})")
return render(request, 'search_by_date.html', {'date':date})

search. html:

{% extends 'base.html' %}
 {% block content %}
   {% for order in date %}
     order.fields.Name
   {% endfor %}
  {% endblock %}
...