Re: TypeError: object() takes No Parameters
The error lies in the following line >>> queryset = monthlyCostTable(getMonthlyCostQuery(2020, 'region')) Your class monthlyCostTable does not take any parameter while you are passing getMonthlyCost... you know better what your doing but this line is the root cause... On Thursday, September 17, 2020 at 4:00:08 PM UTC-4 pcar...@gmail.com 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 + > > 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': >>>
Re: TypeError: object() takes No Parameters
[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 + > > 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':
Re: TypeError: object() takes No Parameters
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 + 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
Re: TypeError: object() takes No Parameters
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')]}) >