[Thu Sep 17 23:07:26.870983 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] Internal Server Error: /functions/ClassMonthlyCost/
[Thu Sep 17 23:07:26.871052 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] Traceback (most recent call last):
[Thu Sep 17 23:07:26.871057 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py",
 
line 34, in inner
[Thu Sep 17 23:07:26.871060 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]     response = get_response(request)
[Thu Sep 17 23:07:26.871064 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py",
 
line 115, in _get_response
[Thu Sep 17 23:07:26.871067 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]     response = self.process_exception_by_middleware(e, 
request)
[Thu Sep 17 23:07:26.871070 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py",
 
line 113, in _get_response
[Thu Sep 17 23:07:26.871073 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]     response = wrapped_callback(request, 
*callback_args, **callback_kwargs)
[Thu Sep 17 23:07:26.871079 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] TypeError: object() takes no parameters


On Thursday, September 17, 2020 at 3:00:08 PM UTC-5 Patrick Carra wrote:

> The actual trace coolguy is 
>
> TypeError at /functions/ClassMonthlyCost/object() takes no 
> parametersRequest 
> Method: GETRequest 
> URL: http://98.8.61.133:8080/functions/ClassMonthlyCost/Django 
> Version: 2.2.4Exception 
> Type: TypeErrorException 
> Value: object() takes no parametersException 
> Location: 
> /home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py
>  
> in _get_response, line 113Python 
> Executable: /home/db_user/ciopsdb/venv/bin/pythonPython 
> Version:3.6.8
> Python Path:
> ['/home/db_user/ciopsdb', '/usr/lib64/python36.zip', 
> '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf']
> Server time: Thu, 17 Sep 2020 18:29:52 +0000  
>
> On Thursday, September 17, 2020 at 2:26:32 PM UTC-5 coolguy wrote:
>
>> is there any specific line number that message is pointing too. Can you 
>> share the actual error message and its trace...
>>
>> On Thursday, September 17, 2020 at 2:35:53 PM UTC-4 pcar...@gmail.com 
>> wrote:
>>
>>> Hello everyone, I am trying to utilize the SIngleTableMixin of 
>>> django_tables2 using a custom function that queries my database and 
>>> aggregates the data into a list of dictionaries.  I read to use the 
>>> SingleTableMixin that all I needed was an iterable containing a data 
>>> structure that has a key(a list of dicts) and then to instantiate a table 
>>> in tables.py and pass to a my views Class.  I am getting an error when I do 
>>> this TypeError: Object() takes no parameters.  I have included a link to 
>>> the django tables 2 doc and my code below:
>>>
>>> #views.py
>>> from django_tables2.views import SingleTableMixin
>>> from django_tables2.export.views import ExportMixin
>>> from django_filters.views import FilterView
>>> from django.views.generic.list import ListView
>>> from django.shortcuts import render
>>>
>>> from finance.models import Circuitinfotable, Budget
>>> from .forms import monthlyCostForm
>>> from .tables import CircuitTable, monthlyCostTable
>>> from .filters import CircuitinfotableFilter
>>>
>>> from datetime import datetime
>>> from decimal import Decimal
>>> from re import sub
>>> import calendar
>>>
>>> #convert a distinct queryset into a singular list of values
>>> def getList(qs, key):
>>>     resultsList = []
>>>     for each in qs:
>>>         resultsList.append(each[key])
>>>     return resultsList
>>>
>>>
>>> def getDistinct(key):
>>>     return Circuitinfotable.objects.all().values(key).distinct()
>>>
>>>
>>> def convertCurrency(val):
>>>     return Decimal(sub(r'[^\d.]', '', val))
>>>
>>>
>>> def getMonthlyCostQuery(year, field):
>>>     circuits = Circuitinfotable.objects.all()
>>>     field_list = getList(getDistinct(field), field)
>>>
>>>     results_list = []
>>>     resultsDict={'field': 'None', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 
>>> 0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
>>> 'Dec': 0,
>>>                  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
>>> 'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 
>>> 'Novbw': 0, 'Decbw': 0}
>>>     results_list.append(resultsDict)
>>>     for each in field_list:
>>>         if each!=None and each!='None':
>>>             resultsDict={'field': '', 'Jan': 0, 'Feb': 0, 'Mar': 0, 
>>> 'Apr': 0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 
>>> 'Nov': 0, 'Dec': 0,
>>>                          'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
>>> 'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 
>>> 'Novbw': 0, 'Decbw': 0}
>>>             resultsDict['field'] = each
>>>             results_list.append(resultsDict)
>>>
>>>     for circuit in circuits:
>>>         #If you add a field to forms.py to aggregate by then add here
>>>         if field=='region':
>>>             matchField = circuit.region
>>>         elif field=='carrier':
>>>             matchField = circuit.carrier
>>>         elif field=='bandwidth':
>>>             matchField = circuit.bandwidth
>>>         elif field=='status':
>>>             matchField = circuit.status
>>>         #get the budget for each circuit
>>>         for budgetItem in circuit.budget_set.filter(yearnum=year):
>>>             #if an item is budgeted for given month
>>>             if(budgetItem.actualmrc!=0):
>>>                 #Cycle through results_list to find the correct 
>>> dictionary
>>>                 for each in results_list:
>>>                     if each['field']==matchField:
>>>                         #update budgetItem and bw
>>>                         if budgetItem != None:
>>>                             
>>> each[calendar.month_abbr[budgetItem.monthnum]]+=convertCurrency(budgetItem.actualmrc)
>>>                         if circuit.bw!= None:
>>>                             
>>> each[calendar.month_abbr[budgetItem.monthnum] + 'bw']+=int(circuit.bw)
>>>                     elif matchField==None:
>>>                         if budgetItem != None:
>>>                             
>>> results_list[0][calendar.month_abbr[budgetItem.monthnum]]+=convertCurrency(budgetItem.actualmrc)
>>>                         if circuit.bw!= None:
>>>                             
>>> results_list[0][calendar.month_abbr[budgetItem.monthnum]+'bw']+=int(
>>> circuit.bw)
>>>
>>>     results_list = sorted(results_list, key=lambda i:i['field'])
>>>     return results_list
>>>
>>>
>>> class MonthlyCost(SingleTableMixin):
>>>     template_name = 'functions/ClassMonthlyCost.html'
>>>     context_object_name = 'qs'
>>>     queryset = monthlyCostTable(getMonthlyCostQuery(2020, 'region'))
>>>
>>>
>>> #tables.py
>>> import django_tables2 as tables
>>> from django_tables2.utils import A
>>> from .models import Circuitinfotable
>>>
>>> class CircuitTable(tables.Table):
>>>     class Meta:
>>>         model = Circuitinfotable
>>>         export_formats = ['csv', 'xlsx']
>>>         template_name = "django_tables2/bootstrap.html"
>>>         Id1 = tables.Column(linkify={"viewname": "viewLit", "args": 
>>> [tables.A('id1__pk')]})
>>>         fields = ("id1", "circuitid", "bandwidth", "region", "carrier", 
>>> "segmentname", "status", "mrcnew", "diversity", )
>>>
>>> class monthlyCostTable(tables.Table):
>>>     field = tables.Column()
>>>     Jan = tables.Column()
>>>     Janbw = tables.Column()
>>>     Feb = tables.Column()
>>>     Febbw = tables.Column()
>>>     Mar = tables.Column()
>>>     Marbw = tables.Column()
>>>     Apr = tables.Column()
>>>     Aprbw = tables.Column()
>>>     May = tables.Column()
>>>     Maybw = tables.Column()
>>>     Jun = tables.Column()
>>>     Junbw = tables.Column()
>>>     Aug = tables.Column()
>>>     Augbw = tables.Column()
>>>     Sep = tables.Column()
>>>     Sepbw = tables.Column()
>>>     Oct = tables.Column()
>>>     Octbw = tables.Column()
>>>     Nov = tables.Column()
>>>     Novbw = tables.Column()
>>>     Dec = tables.Column()
>>>     Decbw = tables.Column()
>>>
>>> Documentation Link that I am using:
>>> https://django-tables2.readthedocs.io/en/latest/pages/table-data.html 
>>>
>>> Anybody know where I went wrong??? If I can figure this out I really 
>>> feel like I can utilize django and django_tables2 to really improve! 
>>>
>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2f0345f6-51a7-4c24-9c6c-49219f6e2a71n%40googlegroups.com.

Reply via email to