-1

I want to make something like this: https://morelab.deusto.es/publications/ Something like the Advanced search of that page, but I don't know how can I make the 'navigation pages'. I am using Django 1.10.5, Python 3.6 and MongoDB with Pymongo. I just want to make click and open the form depending where I click on. I try:

<--html-->

<form class="form-search" action="http://127.0.0.1:8000/views/delete" method="post" role="form">
        <input type="hidden" name="csrfmiddlewaretoken" value="NQ7BUfEYmU7i1wcsAlkjEGfSrbHYYmxAe9tOJl2lvrbE0xgBPLhadk1l29r4SK91">

        <div id="search-text" class="input-group">
            <input class="form-control" id="id_text" maxlength="50" name="text" placeholder="Publication title or author name" type="text">

            <span class="input-group-btn">
                <button class="btn btn-default" type="submit">
                    <i class="fa fa-search"></i>
                </button>
            </span>
        </div>

        <div class="btn-group" id="expand-form-panel" role="group">
            <button id="expand-form-btn" type="button" class="btn btn-default">
                <i class="fa fa-minus"></i>
            </button>
        </div>

        <h2 id="extended-form-title" style="display: block;">Advanced Search</h2>

        <ul class="nav nav-tabs" id="extended-form-tabs" style="display: block;">
            <li class=""><a id="all-tab">All <i class="fa"></i></a></li>
            <li class="active"><a data-target="#basic-info-tab" data-toggle="tab">Basic Information <i class="fa"></i></a></li>
        </ul>
        <div id="extended-form" class="form-horizontal" style="display: block;">

            <div class="tab-content">
                <div class="tab-pane active" id="basic-info-tab">                     
                   {% csrf_token %}
                    <input name="id" value="{{id}}">
                    <p>Are you sure you want to delete this post?</p>
                    <input type="submit" value="Delete">
                </div>
            </div>
        </div>
    </form>

<--views-->

def delete(request):    
id = request.POST.get('id', False)
if request.method == 'POST':
    informe = Informes.objects(id=id)[0]
    informe.delete() 
    template = 'blog/index.html'
    params = {'Informes': Informes.objects} 
elif request.method == 'GET':
    template = 'blog/delete.html'
    params = { 'id': id } 
return render(request, template, params)

<--url-->

url(r'^views/delete$', views.delete)
Ana
  • 9
  • 4

1 Answers1

0

I've had a look at the page you gave as an example and I can give somewhat indications of what they are using and how you can accomplish it.

That page is using the django pagination package (django.core.paginator => https://docs.djangoproject.com/en/1.11/topics/pagination/) for it's pagination.

The search bar uses, most likely, solr, and I recommend you read the documentation for that in order to solve your problem. It's easy to use and implement!

It does not use JavaScript, as the other answer on this question has mentioned, because it doesn't have live reloading of the search results (meaning it doesn't use something such as AJAX or Angular).

Now, it would be a bit too much to put all of the code you need in this one answer. But I can recommend a very good book which uses all of the features you need.

The book is called Django by Example (https://www.packtpub.com/web-development/django-example) and by reading it, you get to build 5 or 6 projects which all use lots of interesting technologies which you can later use in your own projects.

I highly recommend you read that book and start from there!

Paul Andrei
  • 108
  • 7