Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
how to access 2 models attributes through foreignkey in django
Django learner here, I am trying to build a simple blog website in which i have created two models: one is Post: class Post(models.Model): title = models.CharField(max_length=255) author= models.ForeignKey(User, null=True, blank=True , on_delete=models.CASCADE) article = models.TextField() created_on = models.DateTimeField(auto_now_add=True) slug = AutoSlugField(populate_from='title', unique=True, null=True, default=None) category = models.ForeignKey(Category, null=True, blank=True, on_delete=models.CASCADE ) def __str__(self): return self.title second is category: class Category(models.Model): categories = models.CharField(max_length=24, blank=True) def __str__(self): return self.categories all i am trying to do is to show Category on home page, and when someone click on any category it will open up all the post related to that category. This is home.html : {% extends 'blog_pages/base.html' %} {% block content %} <div class = "container p-3"> <h3> This is your home page</h3> </div> <div class = "container p-1"> <table class="table table-hover table-bordered"> <thead> <tr> <th scope="col">Categories</th> <th scope="col">About</th> </tr> </thead> <tbody> {% for c in cat %} <tr> <th scope="row"><a href="{% url 'all_articles' c %}" ><p> {{c}}</P></a></th> <td> How you can win in life</td> </tr> {% endfor %} </tbody> </table> </div> this is views.py : def home(request): cat = Category.objects.all() return render(request, 'blog_pages/home.html',{'cat': cat}) def all_articles(request, c): post = Post.objects.filter(category__contains = c).values() return render(request,"blog_pages/all_articles.html",{'post':post}) I am getting this error … -
AttributeError at /addtowatchlist/5: 'QuerySet' object has no attribute 'listings'
Within my app, I'm allowing any given user to add an auction listing to their watch list, but no matter what I have tried, it does not seem to work and I keep getting the error in the title. I am simply trying to access the user thats making the request and adding the listing to their watchlist and redirecting them to the main page. views.py from .models import * def add_to_watchlist(request, listing_id): listing = Listing.objects.get(id=listing_id) # Retrieving the user watchlist (where it always fails) watchlist = PersonalWatchList.objects.filter(user=request.user) # Fails here too if (watchlist.listings.all() == None) or (listing not in watchlist.listings.all()): watchlist.listings.add(listing) watchlist.save() else: messages.error(request, "Listing is already in your Watchlist.") return redirect(reverse('index')) messages.success(request, "Listing added to your Watchlist.") return redirect(reverse('index')) models.py class PersonalWatchList(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) listings = models.ManyToManyField(Listing, blank=True) def __str__(self): return f"Watchlist for {self.user}" urls.py from django.urls import path from . import views urlpatterns = [ path("", views.index, name="index"), path("login", views.login_view, name="login"), path("logout", views.logout_view, name="logout"), path("register", views.register, name="register"), path("create", views.createListing, name="create"), path("view/<str:listing_title>", views.view, name="view"), path("addtowatchlist/<int:listing_id>", views.add_to_watchlist, name="add_to_watchlist") ] Section of template used to add listing to watchlist <div class="listing-actions"> <a href= {% url 'view' listing.title %} class="btn btn-primary view-button">View</a> <!--TODO: Make watchlist--> <a href={% url 'add_to_watchlist' … -
Connect Django-sql-explorer using Pyodbc connection instead of default Database
I want to connect Django-SQL-explorer using Pyodbc connection instead of Django default database. Django Database connection and Django-SQL-explorer connection Pyodbc connection -
Assign foreing keys of both instances in the same time Django REST
I need a help, please. So I have 2 classes class Pokemon(models.Model): """Pokemon object""" pokedex_creature = models.ForeignKey( PokedexCreature, on_delete=models.CASCADE, ) trainer = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True, ) team = models.ForeignKey( Team, on_delete=models.SET_NULL, blank=True, null=True, ) and class Team(models.Model): """Team model""" name = models.CharField(max_length=100) trainer = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, blank=True, null=True, ) pokemon_1 = models.ForeignKey( Pokemon, on_delete=models.SET_NULL, blank=True, null=True, ) pokemon_2 = models.ForeignKey( Pokemon, on_delete=models.SET_NULL, blank=True, null=True, ) pokemon_3 = models.ForeignKey( Pokemon, on_delete=models.SET_NULL, blank=True, null=True, ) I want to put a ForeingKey of Team to Pokemon model when I add this Pokemon to the team. I use ForeingKey in Team model to assign a Pokemon to this Team so I would like to make the same this Pokemon instance to see to what Team he is assigned. What is the best way to do that? I use Django 3.2.12 and REST Framework 3.13.1 -
Why is google trying to access my backend server?
I have a productionized Django backend server running as on Kubernetes (Deployment/Service/Ingress) on GCP. My django is configured with something like ALLOWED_HOSTS = [BACKEND_URL,INGRESS_IP,THIS_POD_IP,HOST_IP] Everything is working as expected. However, my backend server logs intermittent errors like these (about 7 per day) DisallowedHost: Invalid HTTP_HOST header: 'www.google.com'. You may need to add 'www.google.com' to ALLOWED_HOSTS. DisallowedHost: Invalid HTTP_HOST header: 'xxnet-f23.appspot.com'. You may need to add 'xxnet-f23.appspot.com' to ALLOWED_HOSTS. DisallowedHost: Invalid HTTP_HOST header: 'xxnet-301.appspot.com'. You may need to add 'xxnet-301.appspot.com' to ALLOWED_HOSTS. DisallowedHost: Invalid HTTP_HOST header: 'www.google.com'. You may need to add 'www.google.com' to ALLOWED_HOSTS. DisallowedHost: Invalid HTTP_HOST header: 'narutobm1234.appspot.com'. You may need to add 'narutobm1234.appspot.com' to ALLOWED_HOSTS. DisallowedHost: Invalid HTTP_HOST header: 'z-h-e-n-116.appspot.com'. You may need to add 'z-h-e-n-116.appspot.com' to ALLOWED_HOSTS. DisallowedHost: Invalid HTTP_HOST header: 'www.google.com'. You may need to add 'www.google.com' to ALLOWED_HOSTS. DisallowedHost: Invalid HTTP_HOST header: 'xxnet-131318.appspot.com'. You may need to add 'xxnet-131318.appspot.com' to ALLOWED_HOSTS. DisallowedHost: Invalid HTTP_HOST header: 'www.google.com'. You may need to add 'www.google.com' to ALLOWED_HOSTS. DisallowedHost: Invalid HTTP_HOST header: 'stoked-dominion-123514.appspot.com'. You may need to add 'stoked-dominion-123514.appspot.com' to ALLOWED_HOSTS. My primary question is: Why - what are all of these hosts?. I certainly don't want to allow those hosts without understanding their purpose. Bonus question: What's the … -
Cannot establish incoming connections to docker container
I have a Django app running on docker that requires access to the Azure Storage Accounts from it. It runs fine when the Django server runs from the host computer, but, the connection to the Azure Storage Account fails when running from the container. I guess, somehow Docker is blocking the incoming traffic, as I can perform ping www.google.com.br from the container, but I never get the response back. I used to work with this very same app from a MacOS laptop with no issues (the app establishes connection to the Azure Service), but it does not works since I changed my development setup to Linux (Linux KDE Neon). Any ideas on how can I allow docker containers to receive traffic from the internet? Thanks. This is the error I see that indicates me that Azure Storage Account connection is not allowed (plus the fact this works when I run the same from my MacOs notebook). <urllib3.connection.HTTPSConnection object at 0x7f1286429e10>: Failed to establish a new connection: [Errno -3] Try again')> This is my Docker compose file: the Celery workers are the containers attempting to establish connection with Azure: `version: '3.8' services: web-server: build: ./apps ports: - 8000:8000 - 5678:5678 - … -
Listing profiles and show related user email field in template
Need to list my profilemodel-records. Would like to include the user.email field in the template.(The users email related to the profile...) To get the users email is just {{ user.email }} I was sure I had done it like this before, but now nothing..... {{ profile.user.email }} This is my view: def profileall(request): profilelist = Profile.objects.all() return render(request, 'docapp/profilelist.html',{'profilelist':profilelist}) -
Is there a way to use an abstract value in field in Django Framework?
I have a code like this: class Food(models.Model): ... class Meta: abstract = True class Pizza(Food): ... class Burger(Food): ... class Order(models.Model): ... food_type = models.OneToOneField(Food, on_cascade=CASCADE) So, I'm wondering, if there is a way to set food_type, so it will point either at pizza or at burger model. I've tried to do it like: class Food(models.Model): order = models.OneToOneField(Order, on_delete=CASCADE) class Meta: abstract = True But that allows to have both 'Burger' and 'Pizza' be connected to 'Order', and that's not what I need. -
Jenkins pipeline does not create postgresql_data volume but running docker compose up -d commad manually creates volumes
I'm pretty new to whole docker,docker-compose,jenkins and whole CI-CD concept. So, I may be missing a very simple point. My application is a django web app with postgresql and nginx. If I run docker compose build and docker compose up -d, 3 containers runs and docker volumes are created without any problems. Now I am trying to run these 3 containers with jenkins. I clone my app's repo to jenkins and run docker compose build and docker compose up -d in my pipeline. My app works, static volume is created but postgresql_data docker volume is not created and it's gone if I restart my host machine I thought this might be because of user permissions but the static volume is created by the same jenkins task. Thanks in advance. jenkinsfile pipeline { agent { node { label 'agent-compose' } } environment{ DOCKERHUB_CREDENTIALS = credentials('DockerHub') } stages { stage('Build') { steps { sh 'docker compose build' echo 'Docker compose build is Completed, these images are created:' } } stage('Run The Services') { steps { sh 'docker compose up -d' } } stage('Login To Docker Hub') { steps { sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin' echo 'Login completed' } … -
How to Access method decorated with @action decorator of a view inherited from APIView Class in urls.py file in DRF?
I need to apply different permission on different methods of my View class which is inherited from APIView in a DRF application. To achieve this I am using @action decorator on my methods of view. Here is views.py code class UserView(APIView): @action(methods=['post'], detail=False, permission_classes=[AllowAny]) def create(self, request): serializer = UserRegSerializer(data=request.data) user_service = UserService() try: serializer.is_valid(raise_exception=True) serialized_data = serializer.validated_data registered_user = user_service.create_user(serialized_data) payload = registered_user.__dict__ response = ResponseGenerator(payload, constants.SUCCESS_KEY) except Exception as e: response = ResponseGenerator(e) return Response(data={"Response": response.get_custom_response()}) I am not getting that how could I access this method in my urls.py file against the pattern '/user', here is my urls.py code. urlpatterns = [ path('user', UserView.as_view()), ] I was using ChatGPT to answer this query of mine. It suggested some ways to use a dictionary object passed {'post':'create'} in as_view() method of View in urls.py as following. urlpatterns = [ path('user', UserView.as_view({'post':'create'})), ] In this it told me that key of the dictionary should be the http method used to access that method against the url pattern and value of dictionary should be the method which you want to access against the given url. But its not working, and gives me following error when I try to start my … -
Cannot display data from the database using id = pk in django
I am trying to fetch data from the database and display it in view_data.html. I cannot seem to do it. I am not sure if i understand the use case of id = pk at this point. I want to be able to display data containing particular host when i click on the view button under the 'host' Can anyone help me display the data. Here is what I have done so far: models.py from django.db import models from django.contrib.auth.models import User class Information(models.Model): host = models.CharField(max_length=200, null=True, blank=False) hostname = models.CharField(max_length=200, null=True, blank=False) port = models.IntegerField() platform = models.CharField(max_length=200, null=True, blank=False) username = models.CharField(max_length=200, null=True, blank=False) password = models.CharField(max_length=200, null=True, blank=False) groups = models.CharField(max_length=200, null=True, blank=False) def __str__(self): return self.host views.py from django.shortcuts import render, redirect from django.http import HttpResponse from .models import Information from .forms import MyForm def home(request): informations = Information.objects.all() context = {'informations':informations} return render(request, 'polls/home.html', context) def view_data(request, pk): information = Information.objects.get(id=pk) context = {'information':information} return render(request, 'polls/view_data.html') def my_form(request): if request.method == "POST": form = MyForm(request.POST) if form.is_valid(): form.save() return redirect('home') else: form = MyForm() return render(request, 'polls/room_form.html', {'form': form}) forms.py from django import forms from .models import Information class MyForm(forms.ModelForm): class Meta: model … -
I want to use decimal for currency but it throws error
I want to use decimal for currency but it throws error i do decimal 9.2 but it renders as 9.0 MySQL V 5.7.14 enter image description here -
Considerations of building an Android service as system app (OEM)
I'm working on an OEM project where we need a background service (no UI) to be working continuously. Of course it'll be an app signed with the OEM key, so it shouldn't be any trouble related to background services Android's restrictions. But, as it is the first time developing this, is there any consideration regarding the implementation of the service lifecycle and workflow? Plus, anything important to consider regarding the testing flow of the project? Thank you, any help related to OEM-apps development will be much appreciated. -
how to access all buttons in every container
I want to assign an event listener for every button in every container, but I don't want to loop through the buttons first, because Firstly I want to access the container to use hidden inputs to be passed as parameter to every event listener. for(var i = 0 ; i<products.length;i++) { var id= products[i].getElementsByClassName('pr_id')[0].value; var price = products[i].getElementsByClassName('pr_price')[0].value; var Pname = products[i].getElementsByClassName('pr_name')[0].value var btn = products[i].getElementsByTagName('button')[0]; btn.addEventListener('click',function() { openpopUp(id,price,Pname) }) } but this way the parameters of every button function will be over written. In the end they all have the same parameter ( parameter of last item in the list). HTML code: <div> <div class="productCard"> <img src="'.$row['Picture'].'"> <h3><a href="productDetails.php?id='.$row['Product_ID'].'">'.$row['Name'].'</a></h3> <h4>'.$row['price'].'</h4> <Button type="button" class="open">aa</Button> <input type="hidden" class="pr_id" id="producId" value="'.$row['Product_ID'].'"> <input type="hidden" class="pr_name" name="productName" value="'.$row['Name'].'"> <input type="hidden" class="pr_price" name="productPrice" value="'.$row['price'].'"> </div> </div> -
How to copy a custom .scss file's .css output to wwwroot in a Blazor app?
I have a Blazor WASM application that I'd like to have separate .scss files used for global styling that are not component specific CSS isolation files. Those are bundled and available at runtime, so no issue there. I'm looking for getting the transpiled .css file from it's corresponding .scss source file, and have that .css file copied to wwwroot so I can link to it in index.html. To hedge this a bit, I understand there already exists in wwwroot an app.css file where additional global styles can be applied. The problem with this is it's a .css file and I'd like the power of SASS so this isn't the option I'd like to use. You also can't put a .scss file inside wwwroot as it's not proper because files that need transpiled need to be outside that folder and in the project itself; wwwroot is a target for static files to be hosted, not raw .scss source files. I'm leveraging LibSassBuilder to transpile my .scss files to .css so that's all taken care of. In this example I have a custom.css that's been transpiled from custom.scss and ready for use, but I need it copied to wwwroot. It's been a … -
How to get data from XBRL file into PHP
Hello i want to create a php page to read the file xbrl and extract some information. Anyone have experience from XBRL? I have tried to use the xml standar decode but not work -
dyld[67423]: missing symbol called on Intel Mac
I have this problem when building a site with 11ty. I'm not sure what happened for this error to pop. I've found that most of people with that problem talk about M1 Macs. I'm on a 2020 Intel Macbook Air. Not sure which info/log could be helpful. Error: dyld[67423]: missing symbol called -
How can you set the parallelism for a specific ingress for an embedded statefun application
I have a custom ingress which for various reasons should be run as a singleton. While I understand how the default parallelism can be set I do not see a way of controlling this for a specific operator or ingress when imbedded. I have searched the documentation but have yet to find anything related to this. -
Cannot read PDF Data into Sheets with Gspread-DataFrame
I want to read data from a PDF I downloaded using Tabula into Google Sheets, and when I transfer the data as it was read into Google Sheets, I get an error. I know the data I downloaded is dirty but I wanted to just clean it up in Google Sheets. Downloading Data from Pdf df = tabula.read_pdf(file_path, pages='all', multiple_tables='FALSE', stream='TRUE') print (df) [ Anderson 19,212 9,013 74 1,034 42 174 189 28 0 0.1 0 Bedford 11,486 3,395 25 306 8 47 75 5 0 0 1 Benton 4,716 1,474 12 83 13 11 14 2 0 0 2 Bledsoe 3,622 897 7 95 4 9 18 2 0 0 3 Blount 37,443 12,100 83 1,666 72 250 313 51 1 1 4 Bradley 29,768 7,070 66 1,098 44 143 210 29 1 1 5 Campbell 9,870 2,248 32 251 25 43 45 5 0 0 6 Cannon 4,007 1,127 8 106 7 18 29 3 0 0 7 Carroll 7,756 2,327 22 181 20 18 39 2 0 0 8 Carter 16,898 3,453 30 409 20 54 130 26 0 0 9 Cheatham 11,297 3,878 26 463 13 50 99 8 0 0 10 Chester 5,081 1,243 5 … -
Error with Spring Ecossystem and OpenFeign
Stack trace: java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.openfeign.FeignAutoConfiguration.cachingCapability at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[spring-boot-autoconfigure-2.7.5.jar:2.7.5] at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.3.23.jar:5.3.23] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:193) ~[spring-context-5.3.23.jar:5.3.23] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:153) ~[spring-context-5.3.23.jar:5.3.23] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:129) ~[spring-context-5.3.23.jar:5.3.23] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:343) ~[spring-context-5.3.23.jar:5.3.23] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247) ~[spring-context-5.3.23.jar:5.3.23] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311) ~[spring-context-5.3.23.jar:5.3.23] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112) ~[spring-context-5.3.23.jar:5.3.23] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746) ~[spring-context-5.3.23.jar:5.3.23] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564) ~[spring-context-5.3.23.jar:5.3.23] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.5.jar:2.7.5] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.5.jar:2.7.5] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.5.jar:2.7.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.5.jar:2.7.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.5.jar:2.7.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~ I created this project following the Intellij interface. The only change I made was downgrade spring boot version, from 3.0.1 to 2.7.5 -
Count of specific value and count of individual value
I have a table like: Id type status 1 coach 1.0 2 coach True 3 client Null 4 coach False 5 client Null 6 coach False 7 client Null 8 coach True 9 coach 1.0 10 client Null I want to create a column where coach status is active when value is 1.0 and True else status should be inaactive. Also want to add count of active and inactive values in another column and and total coach count as another column I tried this code Select id,(case when status in (1.0,True) then 'Active' else 'Inactive' end) as Status from table Where type ='Coach' But unable to add count of active and inactive and total coach -
MySQL tune slow delete
I'm using MySQL InnoDB, one of the most important tables has over 700 million records with totally 23 actively used indexes. I am trying to delete the records in a batch of 2000 based on the record date (and order by on primary key column). Each date has around 6 million records, I delete it date by date. Each batch takes around 25 seconds to complete. Since it is a Production database, I want this delete operation to complete faster. Is there a better way to do this? -
Pytorch Results Differ in Training eval() vs Testing/inference eval()
I am trying to replicate the results I get on my evaluation dataset in training with the same dataset in testing. For context, I am trying to denoise images and they are being passed a simple NN consisting of a few conv, relu and BN layers. My problem is that my results are quite close but there is always some disparity. For instance in training the model gets 37.49 dB and in testing it gets 37.40. I have done a bit of reading and it seems that this has to do with batchnorm in the model but setting track_running_stats to false hasnt helped as some people suggest. I also make sure to call model.eval() on my model and I use with torch.no_grad(): The only method I have found to bring the PSNR close is to test using a small minibatch (3 images) but this is not practical as the end goal is to process images seperately. I think this increase might also be due to the PSNR function itself processing larger batches at a time. -
Can GNU Octave handle dynamical plots for the GUI?
I tested this logging software for Arduino and it works great, for a while. The problem with this logging software is that the plot make the application freeze and I don't know why. I have been testing the software for a while and it seems that the plot is the cause of the problem. It freeze and then the whole application freeze. It does not matter even if I plot with regular plot, or if I call an object of the plot and update its X, Y vectors. https://github.com/DanielMartensson/GNU-Octave-Logger/blob/1c6001c115f402a6c3ec71c2ac95817666ea615b/export/wnd/GNU_Octave_Logger_thread.m#L98 % Focus on plot axis(wnd.plot); h = plot(rand(2)); [ code ] set(h, {'YData'}, {analogInPlot; analogOutPlot}); set(h, {'XData'}, {L; L}); legend(h, 'Analog in', 'Analog out'); So my question is: Even if I update the vectors, the plot can still freeze and then the whole application freeze as well. This is a combination with the GUI running. Can it be that GNU Octave cannot handle dynamical plots for GUI? If I remove the plot, then the application works fine. So it must be that GNU Octave cannot handle dynamical plots for the GUI? %set(h, {'YData'}, {analogInPlot; analogOutPlot}); %set(h, {'XData'}, {L; L}); %legend(h, 'Analog in', 'Analog out'); -
Javascript: How to reduce json when consecutive key is the same?
I have a json where I need to reduce the items when they are of a type (isSender). I need to reduce them when they are occuring consecutively. The data can change. The data looks like this: "messages": [ { "content": ["Foo"], "isSender": true }, { "content": ["Bar"], "isSender": true }, { "content": ["Lorem"], "isSender": true }, { "content": ["Ipsum"], "isSender": true }, { "content": ["Dolor"], "isSender": false }, { "content": ["Sit Amet"], "isSender": false }, { "content": ["No"], "isSender": true } ] I need the content to be an array of messages when the consecutive "isSender" key is the same. The output should look like this: "messages": [ { "content": ["Foo", "Bar", "Lorem", "Ipsum"], "isSender": true }, { "content": ["Dolor", "Sit amet"], "isSender": false }, { "content": ["No"], "isSender": true } ] So far I have tried looping through the message array and checking if next messages have the same "isSender" key. However this does not work for more than 2 messages. let deleteIndex = []; for(let i = 0 ; i < messages.length - 1; i++) { const currMs = messages[i]; const nextMs = messages[i + 1]; if (nextMs.isSender == currMs.isSender) { currMs.content.push(nextMs) deleteIndex.push(i + 1) // saving …