Link Disappearing in the browser instead of redirecting on button click

42 views
Skip to first unread message

Indrajeet Singh Yadav

unread,
Nov 1, 2021, 8:53:52 AM11/1/21
to Django users
So i have a html page rendered which has a <a> tag button. Earlier when i used to click on the button the browser would redirect to the link specified. But now when i am doin the same, the whole row (the button is in a column of a table) disappears and nothing happens. If i right click it then the link opens. What am i doing wrong?

Kasper Laudrup

unread,
Nov 1, 2021, 12:49:35 PM11/1/21
to django...@googlegroups.com
Hard for anyone to help since you're not sharing any code and you're not
really telling what you've done differently between "earlier" and "now".

Details like that will greatly improve your chances of getting help.

Kind regards,

Kasper Laudrup


> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/64567cf7-a468-4cc8-a481-9a4c76b07247n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/64567cf7-a468-4cc8-a481-9a4c76b07247n%40googlegroups.com?utm_medium=email&utm_source=footer>.
OpenPGP_0xE5D9CAC64AAA55EB.asc
OpenPGP_signature

Indrajeet Singh Yadav

unread,
Nov 2, 2021, 1:05:48 AM11/2/21
to Django users
Sorry about that I thought it wont be necessary.  
I haven't changed anything I used to get the same trouble when I used windows edge i.e. the row disappearing, but it wont  when I used the google chrome.
But since last Friday it started with the same issue in chrome.
Here's the relevant codes.

clientset.html :-

{% extends 'base.html' %}
{% block table_name %}Client Account Preference{% endblock %}
{% block table_view %}
    <thead style="background-color:#78b1ed">
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Company Name</th>
            <th>Accepted Currency</th>
            <th>Bank Account Number</th>
            <th>Bank Account Type</th>
            <th>Company's Linked Bank Account</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Company Name</th>
            <th>Accepted Currency</th>
            <th>Bank Account Number</th>
            <th>Bank Account Type</th>
            <th>Company's Linked Bank Account</th>
            <th>Actions</th>
        </tr>
    </tfoot>
    <tbody>
    {% for datadisplay in Client%}
        <tr>
            <td>{{datadisplay.0}}</td>
            <td>{{datadisplay.2}}</td>
            <td>{{datadisplay.3}}</td>
            <td>{{datadisplay.4}}</td>
            <td>{{datadisplay.5}}</td>
            <td>{{datadisplay.6}}</td>
            <td>{{datadisplay.7}}</td>
            <td>
                 <a href="/clientsetacc/{{datadisplay.0}}/{{datadisplay.1}}/" class="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-edit fa-fw" style="font-size:20px;color:blue"></i></a>
            </td>
        </tr>
        {% endfor %}
    </tbody>
<!--<center><a class="btn btn-primary" href="/addcompany">Add Record</a></center>-->
{% endblock %}
{% block add_record_btn %}
{% endblock %}
********************************************************************************************************

views.py (code rendering the above html and  the one which should execute on the button click):-

def clientset(request):
    cursor.execute(sql_client_set)
    result = cursor.fetchall()
    return render(request, 'clientset.html', {'Client': result})

def clientsetacc(request, id, id1):
    if request.method == 'POST':
        acc = request.POST.get('acc')
        cursor.execute(
            "select bank_name,bank_acc_name,bank_acc_number,bank_acc_type,bank_address,ifsc_code,swift_code,branch_name from Company where id =?",
            id1)
        result = cursor.fetchall()
        li = list(result[0])
        li1 = []
        for i in li:
            li1.append(i.split(sep="| "))
        li = li1
        ind = li[2].index(acc)
        result = []
        for i in li:
            result.append(i[ind])
        result.append(id)
        sql = '''update Client set cbank_name = ?, cbank_acc_name=?, cbank_acc_number=?, cbank_acc_type=?,
        cbank_address=?, cifsc_code=?, cswift_code=?, cbranch_name=? where id=?'''
        cursor.execute(sql, result)
        cursor.commit()
        return redirect('/clientset')
    else:
        cursor.execute('select bank_acc_number from Company where id = {}'.format(id1))
        li = cursor.fetchall()
        li = list(li[0])
        li = li[0].split(sep='| ')
        result = []
        for i in li:
            result.append(i)
        cursor.execute("select name from Client where id = {}".format(id))
        name = cursor.fetchall()
        return render(request, 'setclientaccount.html', {'accounts': result, 'client': name})
********************************************************************************************************

invoice/urls.py (invoice is django app, urls calling the above function) :-

from django.urls import path, include
from .views import *
urlpatterns = [
    path('clientset/',clientset,name='clientset'),
    path('clientsetacc/<int:id>/<int:id1>/',clientsetacc,name='clientsetacc'),
]
********************************************************************************************************

mysite/urls.py :-

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('',include('invoice.urls')),
]
********************************************************************************************************

I hope this helps.
All of this was working fine till Tuesday mostly on chrome.
But it has stopped the since Friday.
If I right click the button and open it in a new tab, the 'clientsetacc()' runs.
But if I left click the button and try to open in the same tab the row in which the button is disappears. The whole row buttons and everything.
Any suggestion on how to improve the code are also welcome.

Thank You
Reply all
Reply to author
Forward
0 new messages