Repository: netbox-community/netbox

Issue:
Exception when adding ?sort=ports to Service and ServiceTemplate list view
### NetBox version

v3.2.4

### Python version

3.8

### Steps to Reproduce

1. Login netbox
2. Select "IPAM"
3. Select "Service Templates" or "Services"
4. Append ?sort=ports to the URL

### Expected Behavior

Show the list of configured templates.

### Observed Behavior

<class 'django.core.exceptions.FieldError'>

Cannot resolve keyword 'port_list' into field. Choices are: created, custom_field_data, description, id, journal_entries, last_updated, name, ports, protocol, tagged_items, tags

Python version: 3.8.10
NetBox version: 3.2.4


Discussion:
I'm not able to reproduce this on v3.2.4. Could you provide the complete stack trace? (Enable debugging by setting `DEBUG = True` in `configuration.py`)
After I enabled debugging, I got the attached stack-trace.



-----Ursprüngliche Nachricht-----
Von: Jeremy ***@***.***>
Gesendet: Fre 3 Juni 2022 22:22
An: netbox-community/netbox ***@***.***>
CC: Uwe Soemer ***@***.***>; Author ***@***.***>
Betreff: Re: [netbox-community/netbox] Get error: Cannot resolve keyword 'port_list' into field. (Issue #9480)


I'm not able to reproduce this on v3.2.4. Could you provide the complete stack trace? (Enable debugging by setting DEBUG = True in configuration.py)

—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>


FieldError at /ipam/service-templates/

Cannot resolve keyword 'port_list' into field. Choices are: created, custom_field_data, description, id, journal_entries, last_updated, name, ports, protocol, tagged_items, tags

Request Method:	GET
Request URL:	https://netbox.soe.priv/ipam/service-templates/
Django Version:	4.0.4
Exception Type:	FieldError
Exception Value:	

Cannot resolve keyword 'port_list' into field. Choices are: created, custom_field_data, description, id, journal_entries, last_updated, name, ports, protocol, tagged_items, tags

Exception Location:	/opt/netbox/venv/lib/python3.8/site-packages/django/db/models/sql/query.py, line 1677, in names_to_path
Python Executable:	/opt/netbox/venv/bin/python3
Python Version:	3.8.10
Python Path:	

['/opt/netbox/netbox',
 '/opt/netbox',
 '/opt/netbox/venv/bin',
 '/usr/lib/python38.zip',
 '/usr/lib/python3.8',
 '/usr/lib/python3.8/lib-dynload',
 '/opt/netbox/venv/lib/python3.8/site-packages']

Server time:	Sat, 04 Jun 2022 20:24:48 +0000

Traceback Switch to copy-and-paste view
*	/opt/netbox/venv/lib/python3.8/site-packages/django/core/handlers/exception.py, line 55, in inner
	1.	

                response = get_response(request)

…Local vars
 	 
	

 
	

 
	

 
*	/opt/netbox/venv/lib/python3.8/site-packages/django/core/handlers/base.py, line 197, in _get_response
	1.	

                response = wrapped_callback(request, *callback_args, **callback_kwargs)

…Local vars
 	 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
*	/opt/netbox/venv/lib/python3.8/site-packages/django/views/generic/base.py, line 84, in view
	1.	

            return self.dispatch(request, *args, **kwargs)

…Local vars
 	 
	

 
	

 
	

 
	

 
	

 
	

 
*	/opt/netbox/netbox/utilities/views.py, line 90, in dispatch
	1.	

        return super().dispatch(request, *args, **kwargs)

…Local vars
 	 
	

 
	

 
	

 
	

 
	

 
*	/opt/netbox/venv/lib/python3.8/site-packages/django/views/generic/base.py, line 119, in dispatch
	1.	

        return handler(request, *args, **kwargs)

…Local vars
 	 
	

 
	

 
	

 
	

 
	

 
*	/opt/netbox/netbox/netbox/views/generic/bulk_views.py, line 185, in get
	1.	

        table.configure(request)

…Local vars
 	 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
*	/opt/netbox/netbox/netbox/tables/tables.py, line 142, in configure
	1.	

                self.order_by = ordering

…Local vars
 	 
	

 
	

 
	

 
	

 
*	/opt/netbox/venv/lib/python3.8/site-packages/django_tables2/tables.py, line 543, in order_by
	1.	

        self.data.order_by(self._order_by)

…Local vars
 	 
	

 
	

 
	

 
	

 
	

 
	

 
*	/opt/netbox/venv/lib/python3.8/site-packages/django_tables2/data.py, line 226, in order_by
	1.	

            self.data = self.data.order_by(*order_by_accessors)

…Local vars
 	 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
*	/opt/netbox/venv/lib/python3.8/site-packages/django/db/models/query.py, line 1295, in order_by
	1.	

        obj.query.add_ordering(*field_names)

…Local vars
 	 
	

 
	

 
	

 
*	/opt/netbox/venv/lib/python3.8/site-packages/django/db/models/sql/query.py, line 2167, in add_ordering
	1.	

                self.names_to_path(item.split(LOOKUP_SEP), self.model._meta)

…Local vars
 	 
	

 
	

 
	

 
	

 
*	/opt/netbox/venv/lib/python3.8/site-packages/django/db/models/sql/query.py, line 1677, in names_to_path
	1.	

                    raise FieldError(

…Local vars
 	 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
	

 
	

 

Request information

USER

uwe


GET

No GET data


POST

No POST data


FILES

No FILES data


COOKIES
Variable	Value
csrftoken	

'DkBoqn497MSJK29SIJPZYjvKuwPmSEw5iwgh2ip6c9qzJYumcElvA0bLLUl2L3ng'

sessionid	

'skhdwbue1zoznjae117z4jdlyfxz41xe'

cockpit	

'dj0yO2s9ZDMyODRlMmYzZjM0MGUxZmE2ZTljY2JjZGYzNTkzNWIzNDg4NTYyZmFlMGQwNGExYTdjY2VjMjJhYjI2NDRjNQ=='


META
Variable	Value
CSRF_COOKIE	

'DkBoqn497MSJK29SIJPZYjvKuwPmSEw5iwgh2ip6c9qzJYumcElvA0bLLUl2L3ng'

HTTP_ACCEPT	

'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'

HTTP_ACCEPT_ENCODING	

'gzip, deflate, br'

HTTP_ACCEPT_LANGUAGE	

'de,de-DE;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6'

HTTP_CONNECTION	

'close'

HTTP_COOKIE	

('csrftoken=DkBoqn497MSJK29SIJPZYjvKuwPmSEw5iwgh2ip6c9qzJYumcElvA0bLLUl2L3ng; '
 'sessionid=skhdwbue1zoznjae117z4jdlyfxz41xe; '
 'cockpit=dj0yO2s9ZDMyODRlMmYzZjM0MGUxZmE2ZTljY2JjZGYzNTkzNWIzNDg4NTYyZmFlMGQwNGExYTdjY2VjMjJhYjI2NDRjNQ==')

HTTP_HOST	

'127.0.0.1:8001'

HTTP_REFERER	

'https://netbox.soe.priv/ipam/services/'

HTTP_SEC_CH_UA	

'" Not A;Brand";v="99", "Chromium";v="102", "Microsoft Edge";v="102"'

HTTP_SEC_CH_UA_MOBILE	

'?0'

HTTP_SEC_CH_UA_PLATFORM	

'"Windows"'

HTTP_SEC_FETCH_DEST	

'document'

HTTP_SEC_FETCH_MODE	

'navigate'

HTTP_SEC_FETCH_SITE	

'same-origin'

HTTP_SEC_FETCH_USER	

'?1'

HTTP_UPGRADE_INSECURE_REQUESTS	

'1'

HTTP_USER_AGENT	

('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like '
 'Gecko) Chrome/102.0.5005.63 Safari/537.36 Edg/102.0.1245.30')

HTTP_X_FORWARDED_HOST	

'netbox.soe.priv'

HTTP_X_FORWARDED_PROTO	

'https'

HTTP_X_REAL_IP	

'::ffff:192.168.1.24'

PATH_INFO	

'/ipam/service-templates/'

QUERY_STRING	

''

RAW_URI	

'/ipam/service-templates/'

REMOTE_ADDR	

'127.0.0.1'

REMOTE_PORT	

'41740'

REQUEST_METHOD	

'GET'

SCRIPT_NAME	

''

SERVER_NAME	

'127.0.0.1'

SERVER_PORT	

'8001'

SERVER_PROTOCOL	

'HTTP/1.0'

SERVER_SOFTWARE	

'gunicorn/20.1.0'

gunicorn.socket	

<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 8001), raddr=('127.0.0.1', 41740)>

wsgi.errors	

<gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7fa87eed7d30>

wsgi.file_wrapper	

<class 'gunicorn.http.wsgi.FileWrapper'>

wsgi.input	

<gunicorn.http.body.Body object at 0x7fa87eed7df0>

wsgi.input_terminated	

True

wsgi.multiprocess	

True

wsgi.multithread	

True

wsgi.run_once	

False

wsgi.url_scheme	

'https'

wsgi.version	

(1, 0)


Settings

Using settings module netbox.settings
Setting	Value
ABSOLUTE_URL_OVERRIDES	

{}

ADMINS	

[]

ALLOWED_HOSTS	

['*']

APPEND_SLASH	

True

AUTHENTICATION_BACKENDS	

['netbox.authentication.RemoteUserBackend',
 'netbox.authentication.ObjectPermissionBackend']

AUTH_PASSWORD_VALIDATORS	

'********************'

AUTH_USER_MODEL	

'auth.User'

BASE_DIR	

'/opt/netbox/netbox'

BASE_PATH	

''

CACHES	

{'default': {'BACKEND': 'django_redis.cache.RedisCache',
             'LOCATION': 'redis://localhost:6379/1',
             'OPTIONS': {'CLIENT_CLASS': 'django_redis.client.DefaultClient',
                         'PASSWORD': '********************'}}}

CACHE_MIDDLEWARE_ALIAS	

'default'

CACHE_MIDDLEWARE_KEY_PREFIX	

'********************'

CACHE_MIDDLEWARE_SECONDS	

600

CACHING_REDIS_DATABASE	

1

CACHING_REDIS_HOST	

'localhost'

CACHING_REDIS_PASSWORD	

'********************'

CACHING_REDIS_PORT	

6379

CACHING_REDIS_PROTO	

'redis'

CACHING_REDIS_SENTINELS	

[]

CACHING_REDIS_SENTINEL_SERVICE	

'default'

CACHING_REDIS_SKIP_TLS_VERIFY	

False

CORS_ORIGIN_ALLOW_ALL	

False

CORS_ORIGIN_REGEX_WHITELIST	

[]

CORS_ORIGIN_WHITELIST	

[]

CSRF_COOKIE_AGE	

31449600

CSRF_COOKIE_DOMAIN	

None

CSRF_COOKIE_HTTPONLY	

False

CSRF_COOKIE_NAME	

'csrftoken'

CSRF_COOKIE_PATH	

'/'

CSRF_COOKIE_SAMESITE	

'Lax'

CSRF_COOKIE_SECURE	

False

CSRF_FAILURE_VIEW	

'django.views.csrf.csrf_failure'

CSRF_HEADER_NAME	

'HTTP_X_CSRFTOKEN'

CSRF_TRUSTED_ORIGINS	

[]

CSRF_USE_SESSIONS	

False

DATABASE	

{'ATOMIC_REQUESTS': False,
 'AUTOCOMMIT': True,
 'CONN_MAX_AGE': 300,
 'ENGINE': 'django.db.backends.postgresql',
 'HOST': 'localhost',
 'NAME': 'netbox',
 'OPTIONS': {},
 'PASSWORD': '********************',
 'PORT': '',
 'TEST': {'CHARSET': None,
          'COLLATION': None,
          'MIGRATE': True,
          'MIRROR': None,
          'NAME': None},
 'TIME_ZONE': None,
 'USER': 'netbox'}

DATABASES	

{'default': {'ATOMIC_REQUESTS': False,
             'AUTOCOMMIT': True,
             'CONN_MAX_AGE': 300,
             'ENGINE': 'django.db.backends.postgresql',
             'HOST': 'localhost',
             'NAME': 'netbox',
             'OPTIONS': {},
             'PASSWORD': '********************',
             'PORT': '',
             'TEST': {'CHARSET': None,
                      'COLLATION': None,
                      'MIGRATE': True,
                      'MIRROR': None,
                      'NAME': None},
             'TIME_ZONE': None,
             'USER': 'netbox'}}

DATABASE_ROUTERS	

[]

DATA_UPLOAD_MAX_MEMORY_SIZE	

2621440

DATA_UPLOAD_MAX_NUMBER_FIELDS	

None

DATETIME_FORMAT	

'N j, Y g:i a'

DATETIME_INPUT_FORMATS	

['%Y-%m-%d %H:%M:%S',
 '%Y-%m-%d %H:%M:%S.%f',
 '%Y-%m-%d %H:%M',
 '%m/%d/%Y %H:%M:%S',
 '%m/%d/%Y %H:%M:%S.%f',
 '%m/%d/%Y %H:%M',
 '%m/%d/%y %H:%M:%S',
 '%m/%d/%y %H:%M:%S.%f',
 '%m/%d/%y %H:%M']

DATE_FORMAT	

'N j, Y'

DATE_INPUT_FORMATS	

['%Y-%m-%d',
 '%m/%d/%Y',
 '%m/%d/%y',
 '%b %d %Y',
 '%b %d, %Y',
 '%d %b %Y',
 '%d %b, %Y',
 '%B %d %Y',
 '%B %d, %Y',
 '%d %B %Y',
 '%d %B, %Y']

DEBUG	

True

DEBUG_PROPAGATE_EXCEPTIONS	

False

DECIMAL_SEPARATOR	

'.'

DEFAULT_AUTO_FIELD	

'django.db.models.BigAutoField'

DEFAULT_CHARSET	

'utf-8'

DEFAULT_EXCEPTION_REPORTER	

'django.views.debug.ExceptionReporter'

DEFAULT_EXCEPTION_REPORTER_FILTER	

'django.views.debug.SafeExceptionReporterFilter'

DEFAULT_FILE_STORAGE	

'django.core.files.storage.FileSystemStorage'

DEFAULT_FROM_EMAIL	

***@***.***'

DEFAULT_INDEX_TABLESPACE	

''

DEFAULT_SENTRY_DSN	

***@***.***/6396485'

DEFAULT_TABLESPACE	

''

DEPLOYMENT_ID	

'9d0f2aa5ad8f3e44'

DEVELOPER	

False

DISALLOWED_USER_AGENTS	

[]

DOCS_ROOT	

'/opt/netbox/docs'

EMAIL	

{'FROM_EMAIL': '',
 'PASSWORD': '********************',
 'PORT': 25,
 'SERVER': 'localhost',
 'TIMEOUT': 10,
 'USERNAME': '',
 'USE_SSL': False,
 'USE_TLS': False}

EMAIL_BACKEND	

'django.core.mail.backends.smtp.EmailBackend'

EMAIL_HOST	

'localhost'

EMAIL_HOST_PASSWORD	

'********************'

EMAIL_HOST_USER	

''

EMAIL_PORT	

25

EMAIL_SSL_CERTFILE	

None

EMAIL_SSL_KEYFILE	

'********************'

EMAIL_SUBJECT_PREFIX	

'[NetBox] '

EMAIL_TIMEOUT	

10

EMAIL_USE_LOCALTIME	

False

EMAIL_USE_SSL	

False

EMAIL_USE_TLS	

False

EXEMPT_EXCLUDE_MODELS	

(('auth', 'group'), ('auth', 'user'), ('users', 'objectpermission'))

EXEMPT_PATHS	

('/api/', '/graphql/', '/login/', '/oauth/', '/metrics')

EXEMPT_VIEW_PERMISSIONS	

[]

FIELD_CHOICES	

{}

FILE_UPLOAD_DIRECTORY_PERMISSIONS	

None

FILE_UPLOAD_HANDLERS	

['django.core.files.uploadhandler.MemoryFileUploadHandler',
 'django.core.files.uploadhandler.TemporaryFileUploadHandler']

FILE_UPLOAD_MAX_MEMORY_SIZE	

2621440

FILE_UPLOAD_PERMISSIONS	

420

FILE_UPLOAD_TEMP_DIR	

None

FILTERS_NULL_CHOICE_LABEL	

'None'

FILTERS_NULL_CHOICE_VALUE	

'null'

FIRST_DAY_OF_WEEK	

0

FIXTURE_DIRS	

[]

FORCE_SCRIPT_NAME	

None

FORMAT_MODULE_PATH	

None

FORM_RENDERER	

'django.forms.renderers.DjangoTemplates'

GRAPHENE	

{'DJANGO_CHOICE_FIELD_ENUM_V3_NAMING': True}

HOSTNAME	

'netbox'

HTTP_PROXIES	

None

IGNORABLE_404_URLS	

[]

INSTALLED_APPS	

['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'corsheaders',
 'debug_toolbar',
 'graphiql_debug_toolbar',
 'django_filters',
 'django_tables2',
 'django_prometheus',
 'graphene_django',
 'mptt',
 'rest_framework',
 'social_django',
 'taggit',
 'timezone_field',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'wireless',
 'django_rq',
 'drf_yasg']

INTERNAL_IPS	

('127.0.0.1', '::1')

LANGUAGES	

[('af', 'Afrikaans'),
 ('ar', 'Arabic'),
 ('ar-dz', 'Algerian Arabic'),
 ('ast', 'Asturian'),
 ('az', 'Azerbaijani'),
 ('bg', 'Bulgarian'),
 ('be', 'Belarusian'),
 ('bn', 'Bengali'),
 ('br', 'Breton'),
 ('bs', 'Bosnian'),
 ('ca', 'Catalan'),
 ('cs', 'Czech'),
 ('cy', 'Welsh'),
 ('da', 'Danish'),
 ('de', 'German'),
 ('dsb', 'Lower Sorbian'),
 ('el', 'Greek'),
 ('en', 'English'),
 ('en-au', 'Australian English'),
 ('en-gb', 'British English'),
 ('eo', 'Esperanto'),
 ('es', 'Spanish'),
 ('es-ar', 'Argentinian Spanish'),
 ('es-co', 'Colombian Spanish'),
 ('es-mx', 'Mexican Spanish'),
 ('es-ni', 'Nicaraguan Spanish'),
 ('es-ve', 'Venezuelan Spanish'),
 ('et', 'Estonian'),
 ('eu', 'Basque'),
 ('fa', 'Persian'),
 ('fi', 'Finnish'),
 ('fr', 'French'),
 ('fy', 'Frisian'),
 ('ga', 'Irish'),
 ('gd', 'Scottish Gaelic'),
 ('gl', 'Galician'),
 ('he', 'Hebrew'),
 ('hi', 'Hindi'),
 ('hr', 'Croatian'),
 ('hsb', 'Upper Sorbian'),
 ('hu', 'Hungarian'),
 ('hy', 'Armenian'),
 ('ia', 'Interlingua'),
 ('id', 'Indonesian'),
 ('ig', 'Igbo'),
 ('io', 'Ido'),
 ('is', 'Icelandic'),
 ('it', 'Italian'),
 ('ja', 'Japanese'),
 ('ka', 'Georgian'),
 ('kab', 'Kabyle'),
 ('kk', 'Kazakh'),
 ('km', 'Khmer'),
 ('kn', 'Kannada'),
 ('ko', 'Korean'),
 ('ky', 'Kyrgyz'),
 ('lb', 'Luxembourgish'),
 ('lt', 'Lithuanian'),
 ('lv', 'Latvian'),
 ('mk', 'Macedonian'),
 ('ml', 'Malayalam'),
 ('mn', 'Mongolian'),
 ('mr', 'Marathi'),
 ('ms', 'Malay'),
 ('my', 'Burmese'),
 ('nb', 'Norwegian Bokmål'),
 ('ne', 'Nepali'),
 ('nl', 'Dutch'),
 ('nn', 'Norwegian Nynorsk'),
 ('os', 'Ossetic'),
 ('pa', 'Punjabi'),
 ('pl', 'Polish'),
 ('pt', 'Portuguese'),
 ('pt-br', 'Brazilian Portuguese'),
 ('ro', 'Romanian'),
 ('ru', 'Russian'),
 ('sk', 'Slovak'),
 ('sl', 'Slovenian'),
 ('sq', 'Albanian'),
 ('sr', 'Serbian'),
 ('sr-latn', 'Serbian Latin'),
 ('sv', 'Swedish'),
 ('sw', 'Swahili'),
 ('ta', 'Tamil'),
 ('te', 'Telugu'),
 ('tg', 'Tajik'),
 ('th', 'Thai'),
 ('tk', 'Turkmen'),
 ('tr', 'Turkish'),
 ('tt', 'Tatar'),
 ('udm', 'Udmurt'),
 ('uk', 'Ukrainian'),
 ('ur', 'Urdu'),
 ('uz', 'Uzbek'),
 ('vi', 'Vietnamese'),
 ('zh-hans', 'Simplified Chinese'),
 ('zh-hant', 'Traditional Chinese')]

LANGUAGES_BIDI	

['he', 'ar', 'ar-dz', 'fa', 'ur']

LANGUAGE_CODE	

'en-us'

LANGUAGE_COOKIE_AGE	

None

LANGUAGE_COOKIE_DOMAIN	

None

LANGUAGE_COOKIE_HTTPONLY	

False

LANGUAGE_COOKIE_NAME	

'django_language'

LANGUAGE_COOKIE_PATH	

'/'

LANGUAGE_COOKIE_SAMESITE	

None

LANGUAGE_COOKIE_SECURE	

False

LOCALE_PATHS	

[]

LOGGING	

{}

LOGGING_CONFIG	

'logging.config.dictConfig'

LOGIN_PERSISTENCE	

False

LOGIN_REDIRECT_URL	

'/'

LOGIN_REQUIRED	

False

LOGIN_TIMEOUT	

None

LOGIN_URL	

'/login/'

LOGOUT_REDIRECT_URL	

None

MANAGERS	

[]

MEDIA_ROOT	

'/opt/netbox/netbox/media'

MEDIA_URL	

'/media/'

MESSAGE_STORAGE	

'django.contrib.messages.storage.fallback.FallbackStorage'

MESSAGE_TAGS	

{40: 'danger'}

METRICS_ENABLED	

False

MIDDLEWARE	

['graphiql_debug_toolbar.middleware.DebugToolbarMiddleware',
 'django_prometheus.middleware.PrometheusBeforeMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'netbox.middleware.ExceptionHandlingMiddleware',
 'netbox.middleware.RemoteUserMiddleware',
 'netbox.middleware.LoginRequiredMiddleware',
 'netbox.middleware.DynamicConfigMiddleware',
 'netbox.middleware.APIVersionMiddleware',
 'netbox.middleware.ObjectChangeMiddleware',
 'django_prometheus.middleware.PrometheusAfterMiddleware']

MIGRATION_MODULES	

{}

MONTH_DAY_FORMAT	

'F j'

NUMBER_GROUPING	

0

PARAMS	

(<netbox.config.parameters.ConfigParam object at 0x7fa882edf730>,
 <netbox.config.parameters.ConfigParam object at 0x7fa882edf970>,
 <netbox.config.parameters.ConfigParam object at 0x7fa882edf880>,
 <netbox.config.parameters.ConfigParam object at 0x7fa882edfaf0>,
 <netbox.config.parameters.ConfigParam object at 0x7fa882edfa90>,
 <netbox.config.parameters.ConfigParam object at 0x7fa882e7bb20>,
 <netbox.config.parameters.ConfigParam object at 0x7fa882e7bbb0>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd1c0>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd2b0>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd250>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd310>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd340>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd370>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd550>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd3d0>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd400>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd520>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd4c0>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd460>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd490>,
 <netbox.config.parameters.ConfigParam object at 0x7fa8816bd4f0>)

PASSWORD_HASHERS	

'********************'

PASSWORD_RESET_TIMEOUT	

'********************'

PLUGINS	

[]

PLUGINS_CONFIG	

{}

PREPEND_WWW	

False

PROMETHEUS_EXPORT_MIGRATIONS	

False

REDIS	

{'caching': {'DATABASE': 1,
             'HOST': 'localhost',
             'PASSWORD': '********************',
             'PORT': 6379,
             'SSL': False},
 'tasks': {'DATABASE': 0,
           'HOST': 'localhost',
           'PASSWORD': '********************',
           'PORT': 6379,
           'SSL': False}}

RELEASE_CHECK_URL	

'https://api.github.com/repos/netbox-community/netbox/releases'

REMOTE_AUTH_AUTO_CREATE_USER	

True

REMOTE_AUTH_BACKEND	

'netbox.authentication.RemoteUserBackend'

REMOTE_AUTH_DEFAULT_GROUPS	

[]

REMOTE_AUTH_DEFAULT_PERMISSIONS	

{}

REMOTE_AUTH_ENABLED	

False

REMOTE_AUTH_GROUP_HEADER	

'HTTP_REMOTE_USER_GROUP'

REMOTE_AUTH_GROUP_SEPARATOR	

'|'

REMOTE_AUTH_GROUP_SYNC_ENABLED	

False

REMOTE_AUTH_HEADER	

'HTTP_REMOTE_USER'

REMOTE_AUTH_STAFF_GROUPS	

[]

REMOTE_AUTH_STAFF_USERS	

[]

REMOTE_AUTH_SUPERUSERS	

[]

REMOTE_AUTH_SUPERUSER_GROUPS	

[]

REPORTS_ROOT	

'/opt/netbox/netbox/reports'

REST_FRAMEWORK	

{'ALLOWED_VERSIONS': ['3.2'],
 'COERCE_DECIMAL_TO_STRING': False,
 'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework.authentication.SessionAuthentication',
                                    'netbox.api.authentication.TokenAuthentication'),
 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',),
 'DEFAULT_METADATA_CLASS': 'netbox.api.metadata.BulkOperationMetadata',
 'DEFAULT_PAGINATION_CLASS': 'netbox.api.pagination.OptionalLimitOffsetPagination',
 'DEFAULT_PERMISSION_CLASSES': ('netbox.api.authentication.TokenPermissions',),
 'DEFAULT_RENDERER_CLASSES': ('rest_framework.renderers.JSONRenderer',
                              'netbox.api.renderers.FormlessBrowsableAPIRenderer'),
 'DEFAULT_VERSION': '3.2',
 'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.AcceptHeaderVersioning',
 'SCHEMA_COERCE_METHOD_NAMES': {'bulk_destroy': 'bulk_delete',
                                'destroy': 'delete',
                                'retrieve': 'read'},
 'VIEW_NAME_FUNCTION': 'utilities.api.get_view_name'}

REST_FRAMEWORK_VERSION	

'3.2'

ROOT_URLCONF	

'netbox.urls'

RQ_DEFAULT_TIMEOUT	

300

RQ_PARAMS	

{'DB': 0,
 'DEFAULT_TIMEOUT': 300,
 'HOST': 'localhost',
 'PASSWORD': '********************',
 'PORT': 6379,
 'SSL': False,
 'SSL_CERT_REQS': 'required'}

RQ_QUEUES	

{'default': {'DB': 0,
             'DEFAULT_TIMEOUT': 300,
             'HOST': 'localhost',
             'PASSWORD': '********************',
             'PORT': 6379,
             'SSL': False,
             'SSL_CERT_REQS': 'required'},
 'high': {'DB': 0,
          'DEFAULT_TIMEOUT': 300,
          'HOST': 'localhost',
          'PASSWORD': '********************',
          'PORT': 6379,
          'SSL': False,
          'SSL_CERT_REQS': 'required'},
 'low': {'DB': 0,
         'DEFAULT_TIMEOUT': 300,
         'HOST': 'localhost',
         'PASSWORD': '********************',
         'PORT': 6379,
         'SSL': False,
         'SSL_CERT_REQS': 'required'}}

SCRIPTS_ROOT	

'/opt/netbox/netbox/scripts'

SECRET_KEY	

'********************'

SECURE_CONTENT_TYPE_NOSNIFF	

True

SECURE_CROSS_ORIGIN_OPENER_POLICY	

'same-origin'

SECURE_HSTS_INCLUDE_SUBDOMAINS	

False

SECURE_HSTS_PRELOAD	

False

SECURE_HSTS_SECONDS	

0

SECURE_PROXY_SSL_HEADER	

('HTTP_X_FORWARDED_PROTO', 'https')

SECURE_REDIRECT_EXEMPT	

[]

SECURE_REFERRER_POLICY	

'same-origin'

SECURE_SSL_HOST	

None

SECURE_SSL_REDIRECT	

False

SENTRY_DSN	

***@***.***/6396485'

SENTRY_ENABLED	

False

SENTRY_SAMPLE_RATE	

1.0

SENTRY_TAGS	

{}

SENTRY_TRACES_SAMPLE_RATE	

0

SERVER_EMAIL	

''

SESSION_CACHE_ALIAS	

'default'

SESSION_COOKIE_AGE	

1209600

SESSION_COOKIE_DOMAIN	

None

SESSION_COOKIE_HTTPONLY	

True

SESSION_COOKIE_NAME	

'sessionid'

SESSION_COOKIE_PATH	

'/'

SESSION_COOKIE_SAMESITE	

'Lax'

SESSION_COOKIE_SECURE	

False

SESSION_ENGINE	

'django.contrib.sessions.backends.db'

SESSION_EXPIRE_AT_BROWSER_CLOSE	

False

SESSION_FILE_PATH	

None

SESSION_SAVE_EVERY_REQUEST	

False

SESSION_SERIALIZER	

'django.contrib.sessions.serializers.JSONSerializer'

SETTINGS_MODULE	

'netbox.settings'

SHORT_DATETIME_FORMAT	

'Y-m-d H:i'

SHORT_DATE_FORMAT	

'Y-m-d'

SHORT_TIME_FORMAT	

'H:i:s'

SIGNING_BACKEND	

'django.core.signing.TimestampSigner'

SILENCED_SYSTEM_CHECKS	

[]

SOCIAL_AUTH_JSONFIELD_ENABLED	

True

STATICFILES_DIRS	

('/opt/netbox/netbox/project-static/dist',
 '/opt/netbox/netbox/project-static/img',
 ('docs', '/opt/netbox/netbox/project-static/docs'))

STATICFILES_FINDERS	

['django.contrib.staticfiles.finders.FileSystemFinder',
 'django.contrib.staticfiles.finders.AppDirectoriesFinder']

STATICFILES_STORAGE	

'django.contrib.staticfiles.storage.StaticFilesStorage'

STATIC_ROOT	

'/opt/netbox/netbox/static'

STATIC_URL	

'/static/'

STORAGE_BACKEND	

None

STORAGE_CONFIG	

{}

SWAGGER_SETTINGS	

{'DEFAULT_AUTO_SCHEMA_CLASS': 'utilities.custom_inspectors.NetBoxSwaggerAutoSchema',
 'DEFAULT_FIELD_INSPECTORS': ['utilities.custom_inspectors.CustomFieldsDataFieldInspector',
                              'utilities.custom_inspectors.JSONFieldInspector',
                              'utilities.custom_inspectors.NullableBooleanFieldInspector',
                              'utilities.custom_inspectors.ChoiceFieldInspector',
                              'utilities.custom_inspectors.SerializedPKRelatedFieldInspector',
                              'drf_yasg.inspectors.CamelCaseJSONFilter',
                              'drf_yasg.inspectors.ReferencingSerializerInspector',
                              'drf_yasg.inspectors.RelatedFieldInspector',
                              'drf_yasg.inspectors.ChoiceFieldInspector',
                              'drf_yasg.inspectors.FileFieldInspector',
                              'drf_yasg.inspectors.DictFieldInspector',
                              'drf_yasg.inspectors.SerializerMethodFieldInspector',
                              'drf_yasg.inspectors.SimpleFieldInspector',
                              'drf_yasg.inspectors.StringDefaultFieldInspector'],
 'DEFAULT_FILTER_INSPECTORS': ['drf_yasg.inspectors.CoreAPICompatInspector'],
 'DEFAULT_INFO': 'netbox.urls.openapi_info',
 'DEFAULT_MODEL_DEPTH': 1,
 'DEFAULT_PAGINATOR_INSPECTORS': ['utilities.custom_inspectors.NullablePaginatorInspector',
                                  'drf_yasg.inspectors.DjangoRestResponsePagination',
                                  'drf_yasg.inspectors.CoreAPICompatInspector'],
 'SECURITY_DEFINITIONS': {'Bearer': {'in': 'header',
                                     'name': 'Authorization',
                                     'type': 'apiKey'}},
 'VALIDATOR_URL': None}

TASKS_REDIS	

{'DATABASE': 0,
 'HOST': 'localhost',
 'PASSWORD': '********************',
 'PORT': 6379,
 'SSL': False}

TASKS_REDIS_DATABASE	

0

TASKS_REDIS_HOST	

'localhost'

TASKS_REDIS_PASSWORD	

'********************'

TASKS_REDIS_PORT	

6379

TASKS_REDIS_SENTINELS	

[]

TASKS_REDIS_SENTINEL_SERVICE	

'default'

TASKS_REDIS_SENTINEL_TIMEOUT	

10

TASKS_REDIS_SKIP_TLS_VERIFY	

False

TASKS_REDIS_SSL	

False

TASKS_REDIS_USING_SENTINEL	

False

TEMPLATES	

[{'APP_DIRS': True,
  'BACKEND': 'django.template.backends.django.DjangoTemplates',
  'DIRS': ['/opt/netbox/netbox/templates'],
  'OPTIONS': {'builtins': ['utilities.templatetags.builtins.filters',
                           'utilities.templatetags.builtins.tags'],
              'context_processors': ['django.template.context_processors.debug',
                                     'django.template.context_processors.request',
                                     'django.template.context_processors.media',
                                     'django.contrib.auth.context_processors.auth',
                                     'django.contrib.messages.context_processors.messages',
                                     'netbox.context_processors.settings_and_registry']}}]

TEMPLATES_DIR	

'/opt/netbox/netbox/templates'

TEST_NON_SERIALIZED_APPS	

[]

TEST_RUNNER	

'django.test.runner.DiscoverRunner'

THOUSAND_SEPARATOR	

','

TIME_FORMAT	

'g:i a'

TIME_INPUT_FORMATS	

['%H:%M:%S', '%H:%M:%S.%f', '%H:%M']

TIME_ZONE	

'UTC'

USE_DEPRECATED_PYTZ	

True

USE_I18N	

True

USE_L10N	

False

USE_THOUSAND_SEPARATOR	

False

USE_TZ	

True

USE_X_FORWARDED_HOST	

True

USE_X_FORWARDED_PORT	

False

VERSION	

'3.2.4'

WSGI_APPLICATION	

'netbox.wsgi.application'

X_FRAME_OPTIONS	

'SAMEORIGIN'

YEAR_MONTH_FORMAT	

'F Y'

You’re seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard page generated by the handler for this status code.

*	Hide »
*	
History
*	Versions
Django 4.0.4
*	Time
CPU: 583.31ms (600.95ms)
*	Settings
*	Headers
*	Request
view
*	SQL
11 queries in 8.90ms
*	Static files
0 files used
*	Templates
*	Cache
2 calls in 2.25ms
*	Signals
52 receivers of 15 signals
*	Logging
1 message
*	
Intercept redirects
*	
Profiling




-----Ursprüngliche Nachricht-----
Von: Jeremy ***@***.***>
Gesendet: Fre 3 Juni 2022 22:22
An: netbox-community/netbox ***@***.***>
CC: Uwe Soemer ***@***.***>; Author ***@***.***>
Betreff: Re: [netbox-community/netbox] Get error: Cannot resolve keyword 'port_list' into field. (Issue #9480)


I'm not able to reproduce this on v3.2.4. Could you provide the complete stack trace? (Enable debugging by setting DEBUG = True in configuration.py)

—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>


I hid your comment as your 1700 line text dump makes the issue unreadable. 

However, found a way to replicate by adding ?sort=ports to the URL. The port column is not clickable, so not sure how you managed to sort by it.

As a fix to your immediate issue you can delete your preferences for the table in User -> Profile -> Preferences or just append ?sort=description to the URL.
Hello,
thanks for the tip. I removed the preset and the view appears. In the view, however, there is the problem that sorting by the "Ports" column is not possible. If I force it by appending "?sort=ports" to the URL, the stack trace appears again, although according to the error message "ports" is a possible field. Somewhere in the process "ports" is replaced by "port_list" which then leads to the error.

---
Environment:


Request Method: GET
Request URL: https://netbox.soe.priv/ipam/service-templates/?sort=ports

Django Version: 4.0.4
Python Version: 3.8.10
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'corsheaders',
 'debug_toolbar',
 'graphiql_debug_toolbar',
 'django_filters',
 'django_tables2',
 'django_prometheus',
 'graphene_django',
 'mptt',
 'rest_framework',
 'social_django',
 'taggit',
 'timezone_field',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'wireless',
 'django_rq',
 'drf_yasg']
Installed Middleware:
['graphiql_debug_toolbar.middleware.DebugToolbarMiddleware',
 'django_prometheus.middleware.PrometheusBeforeMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'netbox.middleware.ExceptionHandlingMiddleware',
 'netbox.middleware.RemoteUserMiddleware',
 'netbox.middleware.LoginRequiredMiddleware',
 'netbox.middleware.DynamicConfigMiddleware',
 'netbox.middleware.APIVersionMiddleware',
 'netbox.middleware.ObjectChangeMiddleware',
 'django_prometheus.middleware.PrometheusAfterMiddleware']



Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 84, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 90, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 119, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/bulk_views.py", line 185, in get
    table.configure(request)
  File "/opt/netbox/netbox/netbox/tables/tables.py", line 149, in configure
    tables.RequestConfig(request, paginate).configure(self)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django_tables2/config.py", line 42, in configure
    table.order_by = order_by
  File "/opt/netbox/venv/lib/python3.8/site-packages/django_tables2/tables.py", line 543, in order_by
    self.data.order_by(self._order_by)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django_tables2/data.py", line 226, in order_by
    self.data = self.data.order_by(*order_by_accessors)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/db/models/query.py", line 1295, in order_by
    obj.query.add_ordering(*field_names)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 2167, in add_ordering
    self.names_to_path(item.split(LOOKUP_SEP), self.model._meta)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1677, in names_to_path
    raise FieldError(

Exception Type: FieldError at /ipam/service-templates/
Exception Value: Cannot resolve keyword 'port_list' into field. Choices are: created, custom_field_data, description, id, journal_entries, last_updated, name, ports, protocol, tagged_items, tags
---

Sorry for the first stack trace, I hadn't seen the link. This is my first time using github for an error message.

Resolving patch:
diff --git a/netbox/ipam/tables/services.py b/netbox/ipam/tables/services.py
--- a/netbox/ipam/tables/services.py
+++ b/netbox/ipam/tables/services.py
@@ -14,7 +14,8 @@ class ServiceTemplateTable(NetBoxTable):
         linkify=True
     )
     ports = tables.Column(
-        accessor=tables.A('port_list')
+        accessor=tables.A('port_list'),
+        order_by=tables.A('ports'),
     )
     tags = columns.TagColumn(
         url_name='ipam:servicetemplate_list'
@@ -35,7 +36,8 @@ class ServiceTable(NetBoxTable):
         order_by=('device', 'virtual_machine')
     )
     ports = tables.Column(
-        accessor=tables.A('port_list')
+        accessor=tables.A('port_list'),
+        order_by=tables.A('ports'),
     )
     tags = columns.TagColumn(
         url_name='ipam:service_list'


Test patch: