C
C
Cyber_bober2016-02-11 12:23:13
Django
Cyber_bober, 2016-02-11 12:23:13

How to upload data for such grids?

Hello, I've been wondering about this for a long time, but I haven't come up with a solution yet. Let's take such a piece of design as an example
11f51acfc788470fb878a24509cc8357.png
. We have two types of blocks with different appearance, let's say in the admin panel, when creating, we set the checkbox parameter that this is a block with an image stretched over it. What should the output to the template engine look like in the current case?
Okay, let's say this case seems simple, but here's another offtopic, how then are data uploaded to such grids as, for example, in LAM?
0071da55f1084f5681f0eb4262110ece.png
As you can see, there are three pieces of news under the big material. Let's assume that these are two different types of content, POST and NEWS. How should the selection and output to the template engine look like? Measure the first 3 news and display them in the first block, then measure from 3 to 6 and display them in the next?
I speak Python (Django) or PHP. But the Django tag, so if possible - examples on it.
I would be very grateful, I've been scratching my head over this for a long time.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Voronkov, 2016-02-16
@Cyber_bober

models.py:

...
class SomeModel(models.Model):
    ...
    type_content = models.BooleanField(default=False, label='Type Content')

...
{% block content %}
...
{% if somemodel_list %}
    {% for item in somemodel_list %}
        {% if item.type_content %}
            <div class="class1">Content 1</div>
        {% else %}
            <div class="class2"> Content 2</div>
        {% endif %}
    {% endfor %}
{% endif
...
{% endblock %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question