Pickling Error #5712
-
Hello, I am trying to make a plugin with an API, and I am getting a Pickling error. I was hoping for some assistance as I haven't been able to figure out why. I am still trying to make a plugin to track items as they are loaned. I have figured out how to create models and how to add their API URLs using setup_urls(). I am able to see the API and interact with it; that part works. However, in the plugin's settings, I am unable to change any of the settings my plugin exposes as it returns the error: I have looked through countless articles, Inventree source code, tutorials, stack overflow, etc, to no avail. I was hoping you guys may be able to figure out the issue or be able to tell me to use a different format to integrate with Inventree. Fragments of my code that I would believe to be useful follow. If you need more, let me know! Starting with the main plugin file, I was sure to extend both SettingsMixin and UrlsMixin. class LoaningManagementPlugin(AppMixin, ActionMixin, SettingsMixin, UrlsMixin, NavigationMixin, PanelMixin,
InvenTreePlugin): Further in the file, I have the setup URLs function that should call my API views. (This is the attempt that allows me to see the API but not change the plugin's settings) def setup_urls(self):
from . import api
loan_session_api_urls = [
path(r'<int:pk>/', include([
re_path(r'^.*$', api.LoanSessionDetail.as_view(), name='api-part-detail')
])),
re_path(r'^.*$', api.LoanSessionList.as_view(), name='api-loan-session-list'),
]
return [
re_path(r'^hi/', self.view_test, name='hi'),
re_path(r'^add/', self.add_loan, name='add'),
re_path(r'^get/', self.get_loan, name='get'),
re_path(r'^api/', include(loan_session_api_urls), name="api"),
# re_path(r'^test/', api.LoanSessionList.as_view(), name='api-loan-session-list')
] Also, I defined settings in the same file: SETTINGS = {
'DEFAULT_LOAN_DURATION_DAYS': {
'name': _('Default Loan Duration'), # TODO Rewrite
'description': "The default duration an item will be loaned for in days.", # TODO Rewrite
'default': 28,
'validator': [
int,
MinValueValidator(0)
]
}
} In my api.py file, I made a class for any LoanSession request then had subclasses for the endpoints themself in a very similar manner as the parts app does it: from .models import (LoanSession)
from .serializers import (LoanSessionSerializer)
class LoanSessionMixin:
"""Mixin class for LoanSession API endpoints"""
serializer_class = LoanSessionSerializer
queryset = LoanSession.objects.all()
class LoanSessionList(LoanSessionMixin, ListCreateAPI):
"""API endpoint for accessing a list of LoanSession objects, or creating a new LoanSession instance"""
pass
class LoanSessionDetail(LoanSessionMixin, RetrieveUpdateDestroyAPI):
"""API endpoint for detail view of a single LoanSession object."""
pass I understand that I am trying to make a plugin that does more than it is intended. I am starting to believe that is the reason why this is not working, and if that is the reason you come to aswell, let me know and I will try to find another way. I really truly appreciate any time you can spend helping me. I am asking as I have spent considerable time trying to figure this out myself and have made no progress. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@CodingPupper3033 what version are you running? This issue sounds like #5408 which was fixed in #5412 (and in the latest stable release) |
Beta Was this translation helpful? Give feedback.
-
Updating to the latest version fixed the issue. My apologies for my obvious blunders! |
Beta Was this translation helpful? Give feedback.
@CodingPupper3033 what version are you running? This issue sounds like #5408 which was fixed in #5412 (and in the latest stable release)