Human Readable Values

35 views
Skip to first unread message

Mike Sacauskis

unread,
Nov 26, 2018, 6:40:58 PM11/26/18
to Django users

Screenshot.png

Hi

I'm new to DJango and have a question about how to display some model data in a human readable form.  I have three fields, one is an IP Address <django.db.models.fields.IPAddressField> and two are <django.db.models.fields.IntegerField>.  When I render the template I get the class name but no values.  How do I render the values?

Thanks

Mike

Nelson Varela

unread,
Nov 27, 2018, 8:15:12 AM11/27/18
to Django users
show your code that renders the values

Matthew Pava

unread,
Nov 27, 2018, 10:03:20 AM11/27/18
to django...@googlegroups.com

--
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.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e3067097-f156-43a9-9821-abda50b08b72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Sacauskis

unread,
Nov 29, 2018, 3:29:51 PM11/29/18
to Django users


On Tuesday, November 27, 2018 at 8:15:12 AM UTC-5, Nelson Varela wrote:
show your code that renders the values

This is the class

class Hardware(models.Model):
    hardware_id = models.AutoField(primary_key=True)
    compute_asset_name = models.TextField(blank=False, null=False)
    hardware_type = models.ForeignKey('HardwareAssetType',on_delete=models.CASCADE)
    project_id = models.ForeignKey('Project',on_delete=models.CASCADE)
    ipaddress = models.IPAddressField
    macaddress = models.CharField(max_length=16)
    version_number = models.CharField(max_length=128)
    enginering_build = models.BooleanField
    service_tag = models.CharField(max_length=128)
    serial_number = models.CharField(max_length=128)
    cpu_type = models.CharField(max_length=128)
    cores = models.IntegerField
    ramGB = models.IntegerField
   
    def __str__(self):
        return self.compute_asset_name

This is the template
{% extends 'labmanager/BasePage.html' %}
{% load labmanager_filters %}
{% block title %}Lab Assets{% endblock %}

{% block content %}
{% if user.is_authenticated %}
<title>Hardware Page</title>
<form action="{% url 'labmanager:HardwarePage' %}" method='post'>
<table align='center' border="1" cellspacing="0" cellpadding="0" bordercolor="#00338e" >
        <tr bgcolor="#00338e" >
            <td><b><font color="#ffffff">Hardware Item</font></b></td>
            <td><b><font color="#ffffff">Asset</font><b></td>
        </tr>

        <tr align="center">

            <td >
            Compute Asset Name
            </td>
            <td><p> {{ hardware.compute_asset_name }} </p> </td>
        </tr>        

        <tr align="center">

            <td >
            Hardware Type
            </td>
            <td><p> {{ hardware.hardware_type }} </p> </td>
        </tr>   

        <tr align="center">

            <td >
            IP Address
            </td>
            <td><p> {{ hardware.ipaddress }} </p> </td>
        </tr>   
        <tr align="center">

            <td >
            MAC Address
            </td>
            <td><p> {{ hardware.macaddress }} </p> </td>
        </tr>        

        <tr align="center">

            <td >
            Version Number
            </td>
            <td><p> {{ hardware.version_number}} </p> </td>
        </tr>   

        <tr align="center">

            <td >
            Release Type
            </td>
            <td><p> {{ hardware|build_type }} </p> </td>
        </tr>  

        <tr align="center">

            <td >
            Service Tab
            </td>
            <td><p> {{ hardware.service_tab }} </p> </td>
        </tr>   
        <tr align="center">

            <td >
            Serial Number
            </td>
            <td><p> {{ hardware.serial_number }} </p> </td>
        </tr>        

        <tr align="center">

            <td >
            CPU Type
            </td>
            <td><p> {{ hardware.cpu_type}} </p> </td>
        </tr>   

        <tr align="center">

            <td >
            cores
            </td>
            <td><p> {{hardware.cores}} </p> </td>
        </tr>
       
        <tr align="center">
            <td >
            RAM(GB)
            </td>
            <td><p> {{ hardware.ramGB}} </p> </td>
        </tr>     
</form>
</table>

{% endif %}
{% endblock %}

Reply all
Reply to author
Forward
0 new messages