I can't get the collapse
fieldset to show in the admin controls. To top things off, I also get an error on load every now and then, which only seems to appear, whenever I am in the admin controls. I can't piece together the errors to surmise what causes the problem, but I only seem able to reproduce it when I include the included code in admin.py
.
Admin Layout Error
admin.py
from forum.models import Category, Thread, Post from django.contrib import admin class PostAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['author']}), (None, {'fields': ['thread']}), (None, {'fields': ['creation_date']}), (None, {'fields': ['content'], 'classes': ['collapse']}), (None, {'fields': ['is_removed']}), (None, {'fields': ['agrees'], 'classes': ['collapse']}), (None, {'fields': ['thanks'], 'classes': ['collapse']}), (None, {'fields': ['saves'], 'classes': ['collapse']}), ] admin.site.register(Post, PostAdmin)
(Occasional) Error
Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 284, in run self.finish_response() File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 324, in finish_response self.write(data) File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 403, in write self.send_headers() File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 467, in send_headers self.send_preamble() File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 385, in send_preamble 'Date: %s\r\n' % http_date() File "C:\Python27\lib\socket.py", line 324, in write self.flush() File "C:\Python27\lib\socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 10053] An established connection was aborted by the software in your host machine ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 64523) Traceback (most recent call last): File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock self.process_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 310, in process_request self.finish_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 323, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 570, in __init__ BaseHTTPRequestHandler.__init__(self, *args, **kwargs) File "C:\Python27\lib\SocketServer.py", line 641, in __init__ self.finish() File "C:\Python27\lib\SocketServer.py", line 694, in finish self.wfile.flush() File "C:\Python27\lib\socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 10053] An established connection was aborted by the software in your host machine
Any ideas what might be causing this?
EDIT: Upon closer review, an error still persists, even when the collapsed fields are commented out. The layout problem may be related to this error or completely separate. Iād like to see both fixed, obviously.
Here is the seemingly different error:
Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 284, in run self.finish_response() File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 324, in finish_response self.write(data) File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 403, in write self.send_headers() File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 467, in send_headers self.send_preamble() File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 385, in send_preamble 'Date: %s\r\n' % http_date() File "C:\Python27\lib\socket.py", line 324, in write self.flush() File "C:\Python27\lib\socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 10053] An established connection was aborted by the software in your host machine ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 50055) Traceback (most recent call last): File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock self.process_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 310, in process_request self.finish_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 323, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 570, in __init__ BaseHTTPRequestHandler.__init__(self, *args, **kwargs) File "C:\Python27\lib\SocketServer.py", line 641, in __init__ self.finish() File "C:\Python27\lib\SocketServer.py", line 694, in finish self.wfile.flush() File "C:\Python27\lib\socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 10053] An established connection was aborted by the software in your host machine
And the related admin.py
:
from forum.models import Category, Thread, Post from django.contrib import admin class ThreadAdmin(admin.ModelAdmin): "Thread layout in the admin control panel." # Actions def admin_lock(self, request, queryset): rows_updated = queryset.update(is_locked=True) if rows_updated == 1: message_bit = "1 thread was" else: message_bit = "%s threads were" % rows_updated self.message_user(request, "%s successfully marked as locked" % message_bit) admin_lock.short_description = "Lock selected threads" def admin_unlock(self, request, queryset): rows_updated = queryset.update(is_locked=False) if rows_updated == 1: message_bit = "1 thread was" else: message_bit = "%s threads were" % rows_updated self.message_user(request, "%s successfully marked as unlocked" % message_bit) admin_unlock.short_description = "Unlock selected threads" def admin_remove(self, request, queryset): rows_updated = queryset.update(is_removed=True) if rows_updated == 1: message_bit = "1 thread was" else: message_bit = "%s threads were" % rows_updated self.message_user(request, "%s successfully marked as removed" % message_bit) admin_remove.short_description = "Remove selected threads" def admin_restore(self, request, queryset): rows_updated = queryset.update(is_removed=False) if rows_updated == 1: message_bit = "1 thread was" else: message_bit = "%s threads were" % rows_updated self.message_user(request, "%s successfully marked as restored" % message_bit) admin_restore.short_description = "Restore selected threads" actions = ['admin_lock', 'admin_unlock', 'admin_remove', 'admin_restore'] date_hierarchy = 'creation_date' list_display = ('title', 'category', 'author', 'relative_date', 'creation_date') list_filter = ('category',) # Doesn't work search_fields = ['title', 'author'] class PostAdmin(admin.ModelAdmin): "Post layout in the admin control panel." # Actions def admin_remove(self, request, queryset): rows_updated = queryset.update(is_removed=True) if rows_updated == 1: message_bit = "1 post was" else: message_bit = "%s posts were" % rows_updated self.message_user(request, "%s successfully marked as removed" % message_bit) admin_remove.short_description = "Remove selected posts" def admin_restore(self, request, queryset): rows_updated = queryset.update(is_removed=False) if rows_updated == 1: message_bit = "1 post was" else: message_bit = "%s posts were" % rows_updated self.message_user(request, "%s successfully marked as restored" % message_bit) admin_restore.short_description = "Restore selected threads" actions = ['admin_remove', 'admin_restore'] date_hierarchy = 'creation_date' list_display = ('thread', 'author', 'relative_date', 'creation_date') list_filter = ('thread',) search_fields = ['thread', 'author'] admin.site.register(Category) admin.site.register(Thread, ThreadAdmin) admin.site.register(Post, PostAdmin)