Python Forum
How to make data coming from a database clickable giving more details
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make data coming from a database clickable giving more details
#1
There is no results in the dashboard.html and even if the result was given how can I make the name clickable so that I can see the details?
"views.py"


def add_family():
    """
    Add a family to the database
    """
    check_admin()

    add_family = True

    form = FamilyForm()
    if form.validate_on_submit():
        family = Family(name=form.name.data,
                    description=form.description.data,
                    address=form.address.data,
                    phone=form.phone.data)
        try:
            # add family to the database
            db.session.add(family)
            db.session.commit()
            flash('You have successfully added a new family.')
        except:
            # in case family name already exists
            flash('Error: family name already exists.')

        # redirect to families page
        return redirect(url_for('admin.list_families'))

    # load family template
    return redirect(url_for('dashboard.html'))



"models.py"


class Family(db.Model):
    """
    Create a Family table
    """

    __tablename__ = 'families'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(60), unique=True)
    description = db.Column(db.String(2000))
    address = db.Column(db.String(1000))
    phone = db.Column(db.Integer, unique=True)

    def __repr__(self):
        return '<Family: {}>'.format(self.name)


"dashboard.html"

{% import "bootstrap/utils.html" as utils %}
{% extends "base.html" %}
{% block title %}Families{% endblock %}
{% block body %}
<div class="content-section">
  <div class="outer">
    <div class="middle">
      <div class="inner">
        <br/>
        {{ utils.flashed_messages() }}
        <br/>
        <h1 style="text-align:center;">Families</h1>
          <hr class="intro-divider">
          <div class="center">
            <table class="table table-striped table-bordered">
              <tbody>
              {% for family in families %}
                <tr>
                  <td> {{ family.name }} </td>
                </tr>
              {% endfor %}
              </tbody>
            </table>
          </div>
          <div style="text-align: center">
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %}
There is no results in the dashboard.html and even if the result was given how can I make the name clickable so that I can see the details? (Family's name, address, phone ...).
(photo) Family1
        Name: Mustermann
        Address: abc
        Phone: 12345
(photo) Family2
(photo) Family3
.
.
.
Any tips/hints/steps and help will really be appreciated
Reply


Messages In This Thread
How to make data coming from a database clickable giving more details - by newbie1 - May-26-2020, 10:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Save JSON data to sqlite database on Django Quin 0 2,905 Mar-26-2022, 06:22 PM
Last Post: Quin
  how retrieve database save multiple data in web Django 2.1 taomihiranga 0 2,826 Jul-30-2019, 04:58 PM
Last Post: taomihiranga
  Need help to get product details using BeautifulSoup+Python3.6! PrateekG 2 2,898 Jun-27-2018, 08:52 AM
Last Post: PrateekG
  Getting 'list index out of range' while fetching product details using BeautifulSoup? PrateekG 8 8,201 Jun-06-2018, 12:15 PM
Last Post: snippsat
  Ho to get all the caontact details from exchange server in python ppsingh22688 0 1,980 Feb-13-2018, 09:20 AM
Last Post: ppsingh22688
  Execute using Html, Save data into Database and Download in CSV in Django --Part 1 Prince_Bhatia 0 3,859 Jan-19-2018, 06:05 AM
Last Post: Prince_Bhatia
  How do I make a Django model from a tab-delimited data file? newbietostuff 0 2,548 Jan-09-2018, 02:44 AM
Last Post: newbietostuff

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020