#data not displaying in live environment but it displays on local computer

18 messages · Page 1 of 1 (latest)

viral flume
#

I deployed a app locally and it works perfectly,,, but when i deploy it i realise that one of the tables is not displaying the data... any possible reasons why this happens ?

icy phoenix
#

Can you elaborate on "one of the tables is not displaying the data"?

viral flume
#

Meaning data is being displayed under certain tables of the app,,, but there is a specific table called list history that isnt displaying any data at all

icy phoenix
#

Have you recreated the data?

viral flume
#

No it should be pulling from the tables in the database

icy phoenix
#

Yes, but did you create that data?

viral flume
#

Yes it is created by the user in the app.. then pushed to the database... then it should pull from that table in the database and be displayed but it is not

icy phoenix
#

Can you add and view records in the admin?

viral flume
#

yes i can '

#

@icy phoenix

icy phoenix
#

Share your code here and please format it using the backticks `. #readme-1st shows how to do that. You deleted the one code block that was helping me understand your issue.

viral flume
#
 <body>
    {% include 'navbar.html' %} 


<main role="main" class="container">
  {% if messages %}
  <ul class="messages">
         {% for message in messages %}
               <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
         {% endfor %}
 </ul>
{% endif %}
  <div class="jumbotron">
    <div class="header">{{header}}</div>
    <div class="row">
      <div class="col-sm-2">
    <form method='POST' action= ''>{% csrf_token %}
      {{form|crispy}}
      <input class="btn btn-primary mybtn1" type="submit" value='Search'>
    </form>
    </div> <!--End col sm 2-->
    <br>
    <div class="col-sm-10"> 
  <br>
  <div class="display_table">
    <table class='table'>
      <thead>
        <tr>
          <th>NUMBER COUNT</th>
          <!-- <th>ID</th> -->
          <th>CATEGORY GROUP</th>
          <th>ITEM NAME</th>
          <th>QUANTITY IN STORE</th>
          <th>ISSUE QUANTITY</th>
          <th>RECEIVE QUANTITY</th>
          <th>RECEIVE BY</th>
          <th>ISSUE BY</th>
          <th>LAST UPDATED</th>
        </tr>
      </thead>
    {% for instance in queryset %}
        <tr>
          <td>{{ forloop.counter }}</td>
          <!-- <td>{{instance.id}}</td> -->
          <td>{{instance.category}}</td>
          <td>{{instance.item_name}}</td>
          <td>{{instance.quantity}}</td>
          <td>{{instance.issue_quantity}}</td>
          <td>{{instance.receive_quantity}}</td>
          <td>{{instance.receive_by}}</td>
          <td>{{instance.issue_by}}</td>
          <td>{{instance.last_updated}}</td>
        </tr>
    {% endfor %}
  </table>
</div><!--End of display table-->
</div>  <!--END COL SM-->
    </div> <!----END ROW-->
  </div>
</main>
#
def list_history(request):
    header = 'HISTORY OF DATA'
    queryset = StockHistory.objects.all()
    form = StockHistorySearchForm(request.POST or None)
    context = {
        "header": header,
        "queryset": queryset,
        "form": form,
    }
    if request.method == 'POST':
        category = form['category'].value()
        queryset = StockHistory.objects.filter(
                                item_name__icontains = form['item_name'].value(),
                                last_updated__range=[
                                        form['start_date'].value(),
                                        form['end_date'].value()
                                ]
        )

        if (category != ''):
            queryset = queryset.filter(category_id=category)

        if form['export_to_CSV'].value()== True:
            response = HttpResponse(content_type='text/csv')
            response['Content-Disposition'] = 'attachment; filename="Stock_History.csv"'
            writer = csv.writer(response)
            writer.writerow(
                ['CATEGORY',
                'ITEM NAME',
                'QUANTITY',
                'ISSUE QUANTITY',
                'RECEIVE QUANTITY',
                'RECEIVE BY', 
                'ISSUE BY',
                'LAST UPDATED'])
            instance = queryset
            for stock in instance:
                writer.writerow(
                    [stock.category, 
                    stock.item_name, 
                    stock.quantity,
                    stock.issue_quantity,
                    stock.receive_quantity,
                    stock.receive_by,
                    stock.issue_by,
                    stock.last_updated])
            return response
                
        context = {
        "form": form,
        "header": header,
        "queryset": queryset, 

    }
    return render(request, "list_history.html", context)

#
class StockHistory(models.Model):
    category = models.ForeignKey(Category, on_delete=models.CASCADE, blank=True, null=True)
    item_name = models.CharField(max_length=50, blank=True, null=True)
    quantity = models.IntegerField(default='0', blank=True, null=True)
    receive_quantity = models.IntegerField(default='0', blank=True, null=True)
    receive_by = models.CharField(max_length=50, blank=True, null=True)
    issue_quantity = models.IntegerField(default='0', blank=True, null=True)
    issue_by = models.CharField(max_length=50, blank=True, null=True)
    issue_to = models.CharField(max_length=50, blank=True, null=True)
    phone_number = models.CharField(max_length=50, blank=True, null=True)
    created_by = models.CharField(max_length=50, blank=True, null=True)
    reorder_level = models.IntegerField(default='0', blank=True, null=True)
    last_updated = models.DateTimeField(auto_now_add=False, auto_now=False, null=True)
    timestamp = models.DateTimeField(auto_now_add=False, auto_now=False, null=True)

icy phoenix
#

So if the rows aren't being rendered, it's likely because queryset doesn't include them. Have you run a python manage.py shell_plus with your production environment to explore how to craft a StockHistory queryset that will return the data you want?

viral flume
#

honestly i am not sure what you are talking about. I will have to research that

icy phoenix