Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django_tables2 in a tabbed html view with Charts.js?
so I'm trying to get Charts.js and django_tables2 in a tabbed view system where you can click on the different tabs to display dynamic data in either Charts.js or django_tables2, all in the same URL. So far I have Charts.js working the way I want it in one URL, I have Django_tables2 working the way I want it in another URL, and I have the HTML tabbed view system working along with an AJAX call. The part I'm struggling with is combining the Charts.js and djano_tables2 into one URL. Has anybody succeeded doing this before? I've hit so many walls trying to do this. I tried simply putting the code from data_list.html into my charts.html and restructuring my views but this lead me down a path of endless errors. I'm just really not sure how I could combine these two into one URL. This is my code so far: views.py # For initial rendering of HTML tabbed views and user input search fields @api_view(('GET',)) def ChartForm(request, *args, **kwargs): form = SearchForm(request.GET) context = { 'form': form } return render(request, "charts.html", context) # AJAX calls this view with new parameters, this view filters the results, returns JSON object class apiChart(APIView): def … -
How to use django markdown editor to mention or tag users
I am building a BlogApp and I found django-markdown to tag user using @. BUT i didn't find any tutorials to implement in Application. HERE is the the django-markdown-editor. I found using django-markdown-editor in THIS answer. WHY USE MARKDONN ?` Because it is used to tag users using @ and I am trying to implement it in my BlogApp I have no idea how to use this. Any help would be Appreciated -
How to get slope of variables and intercept from a stored(serialized using python pickle) ML model
I am a newbie to machine learning and python. I have a Python code snippet which loads stored ml model and predict with new inputs. mlModel = pickle.load(open('linear_model4.pickle','rb')) request_body = request.body.decode('utf-8') parsed_request = makePredictionInput(json.loads(request_body)) rb=json.loads(request_body) print(parsed_request) result = mlModel.predict(parsed_request) It uses 5 inputs for prediction. Is there a way to get the slopes and intercept from above loaded model sothat i can form the equation as y = intercept + slope1variable1+ slope2variable2+ slope3*variable4+..... -
How can change DateTimeField Format in django models.py file
change datetime "2019-08-19T11:26:44Z" to this "2019-08-19 11:26:44" -
Django Model fields - Imagefield and filefield
Does django saves files and images directly into database or in some local storage, and saves only path in database? (In imagefield and filefield) -
(django) context data not rendering to html
I have a dropdown menu where the user can select the orderID of a taxi ride, and the total distance travelled for that specific order ID will be rendered to the html. The total distance is already in my MySQL database and only needs to be rendered to the frontend, but I'm calling the variable and its not working. I've managed to get it to print to the terminal, but it's showing on my html file and I'm pretty sure I'm calling the variable wrong. Everything else renders, just not {{ total_distance}}. Any pointers? views.py def home(request): # limit query results to first 50 orders just to maximise performance orders = Distance.objects.all().order_by("order")[:50] if request.method == "POST": # code only enters if statement when an item from the dropdown menu is selected print("POST") order_id_selected = request.POST.get("order_id_selected", None) if order_id_selected: start_lat = Distance.objects.values_list( 'start_lat').filter(order_id__exact=order_id_selected) start_long = Distance.objects.values_list( 'start_long').filter(order_id__exact=order_id_selected) end_lat = Distance.objects.values_list( 'end_lat').filter(order_id__exact=order_id_selected) end_long = Distance.objects.values_list( 'end_long').filter(order_id__exact=order_id_selected) total_distance = Distance.objects.values_list( 'total_distance').filter(order_id__exact=order_id_selected) print(order_id_selected) print(total_distance) return render(request, 'base.html', { 'orders': orders, 'dropdown_menu': order_id_selected, 'total_distance': total_distance, }) else: # current view defaults to else print("not working") return render(request, 'base.html', { 'orders': orders, }) base.html <div class="container"> <div class="row"> <div class="col-9"> <div class="order"> <br> <h2>View and calculate … -
Failing to Use Foreign Key in Django-Forms & Getting Errors
I am making an application which will accept the inventory information like serial number and every other details and then I am making another form which will validate the entries from the previous form. I tried multiple resolution which were available on the same error but nothing is helping out here. I am pasting the code here. If there is anything else required, please do comment models.py/inventory_app from django.db import models #from reservation_app.models import Reserve class Form1(models.Model): item = models.CharField(max_length=125) quantity = models.IntegerField(default=0) vendor = models.CharField(max_length=125) inward = models.IntegerField(default=1234) sno = models.ManyToManyField(max_length=100, to='reservation_app.Reserve') date = models.DateField() date_received = models.DateField() def __str__(self): return self.item If I uncomment the line : #from reservation_app.models import Reserve I am getting error of circular import as ImportError: cannot import name 'Form1' from partially initialized module 'inventory_app.models' (most likely due to a circular import) (C:\Users\satharkar\Desktop\altiostar\inventory\inventory_app\models.py) models.py/reservation_app from django.db import models from inventory_app.models import Form1 # Create your models here. class Reserve(models.Model): company = models.CharField(max_length=125) sno = models.ForeignKey(to='inventory_app.Form1', null=True, on_delete= models.SET_NULL) date_req = models.DateField() All my changes created a huge mess, previously I was able to take input from models.py/inventory_app and was able to see it in models.py/reservation_app and now this is not the case. I am … -
Custom decorator with message
I have custom decorator as shown below def staff_member_required(view_func=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url='admin_login'): actual_decorator = user_passes_test( lambda u: u.is_active and u.is_staff, login_url=login_url, redirect_field_name=redirect_field_name ) if view_func: return actual_decorator(view_func) return actual_decorator it works and redirect to the login if user is not staff, here how can I add a message informing user to login as staff -
Django-allauth how to redirect to pervious page after login
I'm using Django-allauth , I can successfully redirect it to home page by adding this in settings.py: LOGIN_REDIRECT_URL = '/home' But is there anyway I can redirect it to pervious page? -
Counting. Django query optmization, Django ORM
can you tell me how to optimize these queries? What is the most efficient way? I want to render all values separately in a view. I attached the screenshot from django-debug-toolbar. I want to learn best practices. I as I see in the docs, this gives a dictionary rather than raw values. How would I pass these querysets in context? In my HTML I have a .js chart with data = [ {{ author_bsc_count }}, {{ author_bsc_count }}...] django-debug-toolbar-SQL-photo # These queries give the totals for each degree. authors = Author.objects.all() author_student_count = authors.filter(degree='Student').count() author_bsc_count = authors.filter(degree='BSc').count() author_msc_count = authors.filter(degree='MSc').count() author_phd_count = authors.filter(degree='PhD').count() # These queries give the manuscript totals for each volume. volumes = Manuscript.objects.all() volume_5 = volumes.filter(citation_volume='5').count() volume_4 = volumes.filter(citation_volume='4').count() volume_3 = volumes.filter(citation_volume='3').count() volume_2 = volumes.filter(citation_volume='2').count() volume_1 = volumes.filter(citation_volume='1').count() # These queries give the manuscript totals for each section. algology_total = volumes.filter(section__title='Algology').count() mycology_total = volumes.filter(section__title='Mycology').count() geography_total = volumes.filter(section__title='Geography').count() entomology_total = volumes.filter(section__title='Entomology').count() arachnology_total = volumes.filter(section__title='Arachnology').count() floristics_total = volumes.filter(section__title='Floristics').count() mammology_total = volumes.filter(section__title='Mammology').count() -
How can django-rest return a serializer error in the correct format for the frontend?
I don't like how django-rest returns a serialization erros JSON. For instance, if two fields are not provided in the request body, the default JSON response is the following: { "title": [ "This field is required." ], "contract_recipients_data": [ "This field is required." ] } I have read about custom exception handling, but I am not sure how can I flatten this error response. I would like for the error message to contain only a string so that my frontend app can handle it better ( how can the frontend handle this dynamic JSON? It seems difficult and not scalable). -
Adding two functions in one input tag
I am trying to add two two functions in one input tag. BUT failed many times. What i am trying to do ? There are two functions in different input tags in my HTML template. One for add tag by , . AND second for autocomplete. I am trying to add them together, So i can use autocomplete and add tag at same time. home.html #This function is for `autocomplete`. <form> <label for="product">Product</label> <input type="text" name="product" id="product"> </form> </form> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script> $(function () { $("#product").autocomplete({ source: '{% url 'autocomplete' %}', minLength: 2 }); }); </script> #This function is for `add tag` <b>Add Tags </b> <input type="text" data-role="tagsinput" class="form-control" name="tags"> <br> What have i tried ? I see an answer that if i add semicolons at the end of the both tag then it will work BUT it didn't work for me. <form> <label for="product">Product</label> <input type="text" name="product" id="product"; data-role="tagsinput";> </form> I don't know what to do. Any help would be Appreciated. -
django update form not all fields are autofill with existing data
iam a noobie in django, A query is why not all the fields are loading in the existing form when I click update .. Except for the profile pic, none of the fields related to the model ( eg, Mobile address, Skill ) are loading, what to change in the form. can someone guide me on how to load the remaining field data in the form? Model : class Mechanic(models.Model): user=models.OneToOneField(User,on_delete=models.CASCADE) profile_pic= models.ImageField(upload_to='profile_pic/MechanicProfilePic/',null=True,blank=True) address = models.CharField(max_length=40,null=True,blank=True) mobile = models.CharField(max_length=20,null=True,blank=True) skill = models.CharField(max_length=500,null=True) salary=models.PositiveIntegerField(null=True) status=models.BooleanField(default=False) @property def get_name(self): return self.user.first_name+" "+self.user.last_name @property def get_id(self): return self.user.id def __str__(self): return self.user.first_name View @login_required(login_url='adminlogin') def update_mechanic_view(request,pk): mechanic=models.Mechanic.objects.get(id=pk) print(mechanic) user=models.User.objects.get(id=mechanic.user_id) userForm=forms.MechanicUserForm(instance=user) mechanicForm=forms.MechanicForm(request.FILES,instance=mechanic) print('mechanicForm',mechanicForm) print('userForm', userForm) mydict={'userForm':userForm,'mechanicForm':mechanicForm} if request.method=='POST': userForm=forms.MechanicUserForm(request.POST,instance=user) mechanicForm=forms.MechanicForm(request.POST,request.FILES,instance=mechanic) if userForm.is_valid() and mechanicForm.is_valid(): user=userForm.save() user.set_password(user.password) user.save() mechanicForm.save() return redirect('admin-view-mechanic') return render(request,'vehicle/update_mechanic.html',context=mydict) Forms class MechanicUserForm(forms.ModelForm): class Meta: model=User fields=['first_name','last_name','username','password'] widgets = { 'password': forms.PasswordInput() } class MechanicForm(forms.ModelForm): class Meta: model=models.Mechanic fields=['address','mobile','profile_pic','skill'] Update mechanic.html {% extends 'vehicle/adminbase.html' %} {% load widget_tweaks %} {% block content %} <head> <style media="screen"> input[type=text], select,input[type=number] ,input[type=password], textarea{ width: 100%; padding: 12px 20px; margin: 8px 0; display: inline-block; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } input[type=submit] { width: 100%; background-color: #4CAF50; color: white; padding: 14px 20px; margin: 8px … -
Visual Studio Code Django debugging breakpoints not triggered on Views and Templates
I am facing a debugging issue with VsCode where it's failing to trigger any type of breakpoints (standard or log), but specifically on View calls and Templates. Breakpoints in other parts of the Django project structure work correctly. For example in this code sample: class HomeView(TemplateView): template_name = "home/home.html" def get(self, request, *args, **kwargs): return render(request, self.template_name, {}) A breakpoint on template_name = "home/home.html" will be triggered successfully when the Class is constructed. However a breakpoint on return render(request, self.template_name, {}) will never trigger (I would expect it to trigger when the user navigates to the URL this class renders). A few things I have already tried: Disable all other VsCode extensions aside from Python, Jupiter, and Pylance Revert to a 4-month-old (I'll explain why 4 months below) version of VsCode, the Python extension, PyLance, and Django Creating a function-based view of the above (which also doesn't trigger the breakpoint) Create a brand new Django project (been able to reproduce this on a brand new project, and two other existing projects) The 4-month-old timeline was because the last time I was working with Django and debugging Views was about 4 months ago so figured I would try those versions. I … -
Django - Limiting Selections Based on ManyToMany Association
Am a front end guy interface guy. Tried learning to program some time ago but gave up. Giving it another shot using Python/Django this time around. Going well. Been trying to overcome the following issue for the last few days. Tried applying possible solutions anywhere I could find them but no luck so far. I have a user model with a manytomany association with a region. A user can manage many regions. I have a site model where the logged in user can create a site and that site has a foreign key with one region. I am looking to limit the selections in the siteform drop down so it only shows the regions identified through the manytomany relationship on the user model. The form will be used on my sitecreate view. Absolutely any help that you can provide would be invaluable. I have no hair left. # users.models from worker.sites_projects.models import Region ... class User(AbstractUser): ... region = models.ManyToManyField( Region, blank=True ) # sites_projects.models ... class Region(models.Model): name = models.CharField("Region", max_length=25) class Site(TimeStampedModel): site_name = models.CharField("Site Name", max_length=200) ... region = models.ForeignKey( Region, ... ) # sites_projects.forms ... ... class SiteForm(forms.ModelForm): ... # region = forms.ModelChoiceField(queryset=Region.objects.all()) # def __init__(self, … -
How to install socket.io in Django Project?
I am building games with Django. But I have one problem https://pypi.org/project/django-socketio/ I follow this guide. But It's not working. As you can see, there are many issues. if you have experience to building socket.io sample, please share me, If so, I am really really thanks. -
Django Admin Inline Link to Specific Queryset?
Following the Django Polls app tutorial, you end up with 2 models as follows: class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField("date published") class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0) The Choice model can be registered with the Django Admin Site, but then you are browsing all Choice objects for all Question objects and this gets cumbersome very quickly. The Choice model could be inlined using InlineModelAdmin so that only related Choice objects appear directly on the Question change page. Though if the number of choices gets large, this can also get quite cumbersome. I'm wondering if there is instead a way to link to the list of related Choice objects from the Question page? -
Django Postgres Exclusion Constraint with ManyToManyField
I would like to use Django Exclusion Constraint with ManyToManyField. Unfortunatelly, so far my efforts were futile. This is my appointment model: from django.contrib.postgres.constraints import ExclusionConstraint from django.contrib.postgres.fields import DateTimeRangeField, RangeOperators class Appointment: patients = models.ManyToManyField(Patient, related_name='appointments' , blank=True ) datetimerange = DateTimeRangeField(null=False, blank = False ) doctor = models.ForeignKey(Doctor, related_name='doctor_appointments') class Meta: constraints = [ ExclusionConstraint( name='unique_doctor', expressions=[ ('datetimerange', RangeOperators.OVERLAPS), ('doctor ', RangeOperators.EQUAL), ], ), ExclusionConstraint( name='unique_patients', expressions=[ ('datetimerange', RangeOperators.OVERLAPS), ('patients', RangeOperators.CONTAINED_BY) ], condition= Q(is_archived=False) & Q(is_cancelled=False) ) ] Unfortunatelly this doesn't work. The first constraint that references the Doctor works perfectly, but the second one gives me this error during migration: return self.cursor.execute(sql, params) psycopg2.errors.UndefinedColumn: column "patient_id" named in key does not exist return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: column "patient_id" named in key does not exist This has been bogging me for quite some time. Any help appreciated. -
Coverage wrongly reports for Django rest framework
I tried to create simple api with Django Rest Framework and use structure like in book Two Scopes of Django 3.x. I tried to create simple test and coverage reports almost 100% coverage on all python sources in my app. Even if I completely remove that test. I tried pytest, nose, and anything what I found here and still same results. My project structure is following: . ├── api │ ├── apps.py │ ├── __init__.py │ ├── urls.py │ └── v1 │ ├── admin.py │ ├── __init__.py │ ├── migrations │ ├── models.py │ ├── serializers.py │ ├── tests │ │ ├── __init__.py │ │ ├── test_api.py │ │ ├── test_models.py │ │ ├── test_serializers.py │ │ └── test_views.py │ ├── urls.py │ └── views.py ├── config │ ├── asgi.py │ ├── __init__.py │ ├── settings │ │ ├── base.py │ │ ├── dev.py │ │ ├── __init__.py │ │ ├── production.py │ │ └── test.py │ ├── urls.py │ └── wsgi.py ├── manage.py ├── README.md ├── requirements │ ├── base.txt │ ├── dev.txt │ ├── production.txt │ └── test.txt └── venv I also tried to modify manage.py with following changes: is_testing = 'test' in sys.argv if is_testing: import coverage … -
Django ServiceWorker not in scope
Thanks for your time. i got a Django web app and am trying to set a PWA for it. I've been seting the files (sw.js, manifest.json, install_sw.html) through urls with TemplateView class: urls.py urlpatterns = [ path('admin/', admin.site.urls), path('config/', include('config.urls')), path('products/', include('products.urls')), path('cart/', include('cart.urls')), path('accounts/', include('allauth.urls')), path('home/', home_view, name='home'), path('sw.js/', (TemplateView.as_view(template_name="admin/sw.js", content_type='application/javascript', )), name='sw.js'), path('manifest.json/', (TemplateView.as_view(template_name="admin/manifest.json", content_type='application/json', )), name='manifestjson'), path('install_sw/', (TemplateView.as_view(template_name="admin/install_sw.html", content_type='text/html', )), name='install_sw'), ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) although i keep getting this error: no matching service worker detected. You may need to reload the page, or check that the scope of the service worker for the current page encloses the scope and start URL from the manifest and even with the serviceworker being found and his code running, i don't think its getting installed. Lighthouse told me so, and when i leave the page the service worker ain't in the list anymore, so im not able to run it offline because the cache gets deleted. files under: sw.js: { const cacheName = 'cache-v1'; const resourcesToPrecache = [ "{% url 'sw.js' %}", "{% url 'home' %}", "{% url 'install_sw' %}" ]; self.addEventListener('install', function (event) { console.log('sw install event!'); event.waitUntil( caches.open(cacheName) .then(function (cache) { console.log('cache added') … -
TemplateSyntaxError at /: Cannot Parse the remainder
I am trying to update my homepage whenever a new "article" is added, however it is giving me this error whenever I try to update the page using my updateHomepage view it doesn't work and I get the error TemplateSyntaxError at / Could not parse the remainder: ' 'update_homepage'' from 'url 'update_homepage'' I am very new to django so any help with this would be amazing. My Views.py def index(request): articles = Article.objects.all() context = {'articles': articles} return render(request, 'able/homepage.html', context) def updateHomepage(request, pk): form = EditorForm(instance=task) context = {'form': form} article = Editor.objects.get(id=pk) return render(request, 'able/update_homepage.html', context) if request.method == 'POST': form = EditorForm(request.POST, instance=task) if form.is_valid(): form.save() return redirect('/') def editorview(request): editor = EditorForm context = {'editor': editor} return render(request, 'able/editor.html', context) if request.method == 'POST': form = EditorForm(request.POST) if form.is_valid(): form.save() return redirect('/') urls.py urlpatterns = [ path('', views.index, name='homepage'), path('editor/', views.editorview), path('update_homepage/<str:pk>/', views.updateHomepage, name='update_homepage') ] homepage.html <h1>My Blog</h1> {% for article in articles %} <div class="article"> {% csrf_token %} <h1>{{ article.title }}</h1> <h3>{{ article.text }}</h3> </div> {% endfor %} <a href="{{ url 'update_homepage'}}">Update</a> update_homepage.html <h3>Update Homepage</h3> <form action="" method="POST"> {% csrf_token %} {{form}} <input type="submit"> </form> -
Render Django @property method in html template
I am relatively new to django. I am trying to render my @property method inside my django template. I am taking the difference between two dads to determine wether or not this object is suitable to be issued out or must recalibrated. I get an issue: 'int' object is not callable My model: class Tools_Calibrated(models.Model): description = models.CharField(max_length=50, blank=True, null=True) serial_number = models.CharField(max_length=50, blank=True, null=True) part_number = models.CharField(max_length=50, blank=True, null=True) recieved = models.DateTimeField(auto_now_add=False, auto_now=True) calibrated = models.BooleanField(default='True', blank=True, null=True) calibrated_date = models.DateTimeField( auto_now_add=False, blank=True, null=True) expiry_date = models.DateTimeField( auto_now_add=False, blank=True, null=True) cert_no = models.CharField(max_length=50, blank=True, null=True) range_no = models.CharField(max_length=50, blank=True, null=True) issued = models.BooleanField(default='False', blank=True, null=True) workorder_no = models.ForeignKey( WorkOrders, null=True, blank=True, on_delete=models.SET_NULL) def __str__(self): return self.description @property def timecalculated(self): exp = self.expiry_date cali = self.calibrated_date total = exp-cali return total.days() My Template: {% for tool in Cali %} <tr> <td style="text-align:center">{{tool.description}}</td> <td style="text-align:center">{{tool.part_number}}</td> <td style="text-align:center">{{tool.serial_number}}</td> <td style="text-align:center">{{tool.recieved|date:"M d, Y"}}</td> <td style="text-align:center">{{tool.calibrated_date|date:"M d, Y"}}</td> <td style="text-align:center">{{tool.expiry_date|date:"M d, Y"}}</td> <td>{{tool.timecalculated}}</td> <td style="text-align:center">{{tool.cert_no}}</td> <td style="text-align:center">{{tool.range_no}}</td> <td style="text-align:center"><a class="btn btn-sm btn-info sb-btn" href="{% url 'editCali' tool.id%}">Edit</a></td> <td style="text-align:center"><a class="btn btn-sm btn-danger sb-btn" onClick='return confirmDelete()' href="{% url 'deleteCali' tool.id %}">Delete</a></td> <td style="text-align:center"><a class="btn btn-sm btn-warning sb-btn" href="{% url 'change_calibration_status' tool.id%}" onClick='return confirmCali()'>Calibrate</a></td> <td style="text-align:center"><a … -
Best way to query Django ORM to sum items by category per year (for time series)
Assume we have the models: class Category(models.Model): description = models.CharField(...) # Ex: 'horror', 'classic', 'self-help', etc. class Book(models.Model): category = models.ForeignKey(Category, ...) written_date = models.DateField(...) I want to make a query that will eventually get me the total number of books per category per year! Like so: { '2019-01-01': { 'horror': 2, 'classic': 1}, '2020-01-01': { 'horror': 2, 'classic': 1, 'self-help': 4}, ... } I was only able to come up with the following query: Book.objects \ .annotate(year=TruncYear('written_date')) \ .values('year', 'category__description') \ .order_by('year') \ .annotate(total=Count('id')) However this only gets me { { "category__description": "Horror", "year": "2019-01-01", "total": 2 }, { "category__description": "Classic", "year": "2019-01-01", "total": 1 }, { "category__description": "Horror", "year": "2020-01-01", "total": 2 }, ... } Is there any way to do this via ORM? Or I have to do this by manipulating the result directly? Thanks! -
Should small specific views be implemented with Function Based views or CBVs?
I'm developing an app in Django and would like to know what is the correct way to implement some small views that need to implement some specific function. I'm still a beginner and I've been using CBVs from the start but I'm not sure if I should use FBVs for this. I now need to implement some specific functions when integrating Stripe, for example, to reactive a canceled subscription or to upgrade a subscription and was wondering if I should use FBVs for this? If not, should I for example use the POST of class SubscriptionView(APIView): def post(self, request): # Make a new subscription... that I use to create a subscription and just check if the user is trying to reactive/upgrade with a parameter or something like that? -
Django: Making sure a complex object is accessible throughout multiple view calls
for a project, I am trying to create a web-app that, among other things, allows training of machine learning agents using python libraries such as Dedupe or TensorFlow. In cases such as Dedupe, I need to provide an interface for active learning, which I currently realize through jquery based ajax calls to a view that takes and sends the necessary training data. The problem is that I need this agent object to stay alive throughout multiple view calls and be accessible by each individual call. I have tried realizing this via the built-in cache system using Memcached, but the serialization does not seem to keep all the info intact, and while I am technically able to restore the object from the cache, this appears to break the training algorithm. Essentially, I want to keep the object alive within the application itself (rather than an external memory store) and be able to access it from another view, but I am at a bit of a loss of how to realize this. If someone knows the proper technique to achieve this, I would be very grateful. Thanks in advance!