Answer the question
In order to leave comments, you need to log in
How can such an object be created through v-model?
How can such an object be created through v-model?
where index is a randomly generated number.
In fact, you need to create an object of objects, each element of which has a property - a random number, a value - v-model="entity[index].name"
An example is hereentity = {index: entity[index].name}
Answer the question
In order to leave comments, you need to log in
1) entity[index].name
will not be reactive, because initially such a value did not exist, and you need to use it - v-model will not
work the model passed in the parameter (in fact, this is the "syntactic sugar" that is called v-model).
3) hang up an event on a component with a field and form it in the method. $set
{ entity[xxx].yyy }
Add a list of slides to the template context:
# views.py
def slider(request):
slides = Slide.objects.all()
return render(request, 'main.html', {'slides': slides})
and in the template refer to each of the list slides{# main.html #}
{% for slide in slides %}
<div class="item lifted">
<img class="lazyOwl" data-src="{{ slide.image.url }}">
<div class="caption-content">
<h1 class="caption lifted">{{ slide.header }} </h1><br>
<p class="caption2 lifted">{{ slide.caption }}</p>
</div>
</div>
{% endfor %}
Are you running, as I understand it, on the dev server (manage.py runserver)?
If so, then the Django web server does not know how to serve media files itself.
You can try the following in urls.py:
if settings.DEBUG:
urlpatterns += patterns(
'django.views.static',
(r'media/(?P<path>.*)',
'serve',
{'document_root': settings.MEDIA_ROOT}), )
from .models import Slide
def slider(request):
slides = Slide.objects.all()
return render(request, 'main.html', locals())
https://docs.djangoproject.com/en/1.8/topics/http/...
views.py
from .models import Slide
def slider(request):
context = {'slides': Slide.objects.all()}
return render(
request,
'main.html',
# context???
context
)
{% for slide in slides %}
<div class="item lifted">
<img class="lazyOwl" data-src="{{ slide.image.url }}">
<div class="caption-content">
<h1 class="caption lifted">{{ slide.header }} </h1><br>
<p class="caption2 lifted">{{ slide.caption }}</p>
</div>
</div>
{%endfor%}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question