0

I have used Django to develop a webapp In the admin model, I used Django simple UI package, I want to choose the last 2rd one in the list(models)

How could I slice in the below?

                        <div v-for="(c,j) in models" :key="c.name" class="quick-wrap">
                        <a href="javascript:;" @click="openTab(c,(j+1)+'')">
                            <span class="icon" :class="c.icon"></span>
                            <span class="card-name" v-text="c.name"></span>
                        </a>
                    </div>
Django
  • 1
  • 6

1 Answers1

0

Not sure what last 2rd means, but if you want the last 2 items in what appears to be a context variable called models you can do that in the view you use to call this html file. Using a slice on your queryset you should be able to pass models[-2:] to get the last two and pass that instead of models. Vue may have a way to slice as well, but if you can do it in the view, it probably makes sense to do so.

AMG
  • 1,606
  • 1
  • 14
  • 25
  • this is from admin model in django, no view.py for this html – Django May 21 '21 at 08:47
  • ah. I missed that Django simple UI was a product you were using. I can't help here; maybe you could find slice it as described here: https://stackoverflow.com/questions/46622209/how-to-limit-iteration-of-elements-in-v-for. – AMG May 21 '21 at 14:27