You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
Navigating to the admin page for a model that includes 'id' column and choosing 'export selected' action proceeds to field selection dialog. However, attempting to export on a model that has a primary_key=True field with a name other than 'id' errors out on export.
What I Did
model:
class Computer(models.Model):
comp_id = models.AutoField(db_column='CompId', primary_key=True)
name = models.CharField(db_column='CompName', max_length=50)
domain = models.CharField(db_column='Domain', max_length=10, choices=DOMAIN_CHOICES, null=True)
infrastructure = models.CharField(db_column='Infrastructure', max_length=10,
choices=INFRASTRUCTURE_CHOICES, blank=True, null=True)
site = models.ForeignKey(DNUnits, db_column='site_id', related_name='computer_site', blank=True, null=True)
machine_type = models.CharField(db_column='MachineType', max_length=1,
choices=MACHINE_TYPE_CHOICES, blank=True, null=True)
OS = models.CharField(db_column='OS', max_length=50, blank=True, null=True)
CPU_count = models.IntegerField(db_column='CPUCount', blank=True, null=True)
class Meta:
unique_together = ('name', 'domain',)
ordering = ('name',)
def __unicode__(self):
return self.name + '.' + get_display(self.domain, DOMAIN_CHOICES)
Traceback:
Traceback (most recent call last):
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/contrib/admin/options.py", line 544, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 211, in inner
return view(request, *args, **kwargs)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 67, in _wrapper
return bound_func(*args, **kwargs)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 63, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1569, in changelist_view
response = self.response_action(request, queryset=cl.get_queryset(request))
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1305, in response_action
response = func(self, request, queryset)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/export_action/admin.py", line 10, in export_selected_objects
selected = list(queryset.values_list('id', flat=True))
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/db/models/query.py", line 729, in values_list
clone = self._values(*fields)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/db/models/query.py", line 712, in _values
query.add_fields(field_names, True)
File "/Users/msimons/Code/dn-sql-catalog/venv/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1644, in add_fields
"Choices are: %s" % (name, ", ".join(names)))
FieldError: Cannot resolve keyword 'id' into field. Choices are: CPU_count, OS, comp_id, domain, infrastructure, instance, machine_type, name, site, site_id
[28/Aug/2017 19:37:59] "POST /admin/dn_sql_catalog/computer/ HTTP/1.1" 500 129966
The text was updated successfully, but these errors were encountered:
Description
Navigating to the admin page for a model that includes 'id' column and choosing 'export selected' action proceeds to field selection dialog. However, attempting to export on a model that has a primary_key=True field with a name other than 'id' errors out on export.
What I Did
The text was updated successfully, but these errors were encountered: