I am implementing a 'load more' button for my posts.

With ajax this is what I'm doing to display the loaded posts into my html:

```
success:function(res){
                var _html='';
                var json_data=$.parseJSON(res.posts);
                $.each(json_data,function(index,data){
                _html+='<div class="post-box col-md-1">\
                  <div class="info-box mb-4">\
                  <div>\
                    {% if '+data.fields.cantidad+' == 1 %}\
                      <h3>'+data.fields.donador+'</h3><text>te donó '+data.fields.cantidad+' '+data.fields.objeto+'.</text>\
                    {% else %}\
                    <h3>'+data.fields.donador+' </h3><text>te donó '+data.fields.cantidad+' '+data.fields.objeto+'s.</text>\
                    {% endif %}\
                      <br>\
                      <text>'+data.fields.whenpublished+' </text>\
                      {% if '+data.fields.message+' != "" %}\
                      <hr>\
                    <text>'+data.fields.message+'</text>\
                    {% endif %}\
                  </div>\
                  </div>\
              </div>';
                              };

```

This is my model:

```
class Donacion(models.Model):
    creador_d = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    creation_date = models.DateTimeField(auto_now_add=True, blank=True)
    message = models.CharField(max_length=300, null=True, blank=True)
    donador = models.CharField(max_length=30, null=True, blank=True)
    cantidad = models.IntegerField()
    objeto = models.CharField(max_length=30, null=True, blank=True)

    def whenpublished(self):
        now = timezone.now()

        diff = now - self.creation_date

        if diff.days == 0 and diff.seconds >= 0 and diff.seconds < 60:
            seconds= diff.seconds

            if seconds == 1:
                return "Hace " + str(seconds) +  " segundo"

            else:
                return "Hace " + str(seconds) +  " segundos"

        if diff.days == 0 and diff.seconds >= 60 and diff.seconds < 3600:
            minutes= math.floor(diff.seconds/60)

            if minutes == 1:
                return "Hace " + str(minutes) +  " segundo"

            else:
                return "Hace " + str(minutes) +  " minutos"

        if diff.days == 0 and diff.seconds >= 3600 and diff.seconds < 86400:
            hours= math.floor(diff.seconds/3600)

            if hours == 1:
                return "Hace " + str(hours) +  " hora"

            else:
                return "Hace " + str(hours) +  " horas"

```

There are some problems here.

1. `'+data.fields.whenpublished+'`: This value returns `undefined` and I don't know how to access it
2. This condition: `{% if '+data.fields.cantidad+' == 1 %}` it is intepreted as False, while `'+data.fields.cantidad+'` is actually one `1`
3. This condition: `{% if donacion.message != '' %}` it is intepreted as True even if `'+data.fields.message+'` == `''` And in that case it should be interpreted as False

In order for you to compare this ajax html I'll provide you with the one I usually use to render my posts via a `GET` method:

```
     <div class="post-box col-md-1">
          <div>
              <div>
                    {% if donacion.cantidad == 1 %}
                      <h3>{{donacion.donador}} </h3><text>te donó {{donacion.cantidad}} {{donacion.objeto}}.</text>
                    {% else %}
                    <h3>{{donacion.donador}} </h3><text>te donó {{donacion.cantidad}} {{donacion.objeto}}s.</text>
                    {% endif %}
                      <br>
                      <text>{{ donacion.whenpublished }}</text>
                      {% if donacion.message != '' %}
                      <hr>
                    <text>{{donacion.message}}</text>
                    {% endif %}
              </div>
          </div>
      </div>

```

views.py

```
def load_more(request):
    offset=int(request.POST['offset'])
    limit=2
    posts=Post.objects.all()[offset:limit+offset]
    totalData=Post.objects.count()
    data={}
    posts_json=serializers.serialize('json',posts)
    return JsonResponse(data={
        'posts':posts_json,
        'totalResult':totalData
    })

```