Home > database >  django template is not showing python variables anymore
django template is not showing python variables anymore

Time:10-02

so I'm trying to build a website with Django (TAPP.GE), I'm getting texts for the website from the database, but after 39 variables, the 40th one and every variable after that is not showing up on the website.

all the texts above (get endless possibilities, etc are exactly the same type of variables as others but others are not showing up below, with 4 different icons.) [1]: https://i.stack.imgur.com/uCTwK.png

this code works fine

                                        <div >
                                            <div >
                                                <h4 >{{ video_bg_stat_3.content_eng }}</h4>
                                                <span>{{ video_bg_stat_title_3.content_eng }}</span>
                                            </div>
                                        </div>

this code is not working even if I pass the same variables as above

<div >
                <div >
                    <div >
                        <h3 >{{ advantages_title.content.geo }}</h3>
                        <p>{{ advantages_subtitle.content.geo }}</p>
                    </div>
                </div>
            </div>

so it works for the first 39 variables, after that it does not work.

Views.py

def home(request):
context = {
    'in_month': Text.objects.get(name="in_month"),
    'mainslogan': Text.objects.get(name="mainslogan"),
    'application': Text.objects.get(name="application"),
    'main_menu_1': Text.objects.get(name="main_menu_1"),
    'main_menu_2': Text.objects.get(name="main_menu_2"),
    'main_menu_3': Text.objects.get(name="main_menu_3"),
    'main_menu_4': Text.objects.get(name="main_menu_4"),
    'subslogan': Text.objects.get(name="subslogan"),
    'feedback': Text.objects.get(name="feedback"),
    'first_block_feature_1': Text.objects.get(name="first_block_feature_1"),
    'first_block_feature_2': Text.objects.get(name="first_block_feature_2"),
    'first_block_feature_3': Text.objects.get(name="first_block_feature_3"),
    'first_block_feature_4': Text.objects.get(name="first_block_feature_4"),
    'first_block_subtitle_1': Text.objects.get(name="first_block_subtitle_1"),
    'first_block_subtitle_2': Text.objects.get(name="first_block_subtitle_2"),
    'first_block_subtitle_3': Text.objects.get(name="first_block_subtitle_3"),
    'first_block_subtitle_4': Text.objects.get(name="first_block_subtitle_4"),
    'first_block_title_before_br_1': Text.objects.get(name="first_block_title_before_br_1"),
    'first_block_title_after_br_1': Text.objects.get(name="first_block_title_after_br_1"),
    'first_block_title_before_br_2': Text.objects.get(name="first_block_title_before_br_2"),
    'first_block_title_after_br_2': Text.objects.get(name="first_block_title_after_br_2"),
    'first_block_title_before_br_3': Text.objects.get(name="first_block_title_before_br_3"),
    'first_block_title_after_br_3': Text.objects.get(name="first_block_title_after_br_3"),
    'first_block_title_before_br_4': Text.objects.get(name="first_block_title_before_br_4"),
    'first_block_title_after_br_4': Text.objects.get(name="first_block_title_after_br_4"),
    'first_block_text_1': Text.objects.get(name="first_block_text_1"),
    'first_block_text_2': Text.objects.get(name="first_block_text_2"),
    'first_block_text_3': Text.objects.get(name="first_block_text_3"),
    'first_block_text_4': Text.objects.get(name="first_block_text_4"),
    'first_block_button': Text.objects.get(name="first_block_button"),
    'video_bg_title': Text.objects.get(name="video_bg_title"),
    'video_bg_subtitle': Text.objects.get(name="video_bg_subtitle"),
    'video_bg_stat_title_1': Text.objects.get(name="video_bg_stat_title_1"),
    'video_bg_stat_title_2': Text.objects.get(name="video_bg_stat_title_2"),
    'video_bg_stat_title_3': Text.objects.get(name="video_bg_stat_title_3"),
    'video_bg_url': Text.objects.get(name="video_bg_url"),
    'video_bg_stat_1': Text.objects.get(name="video_bg_stat_1"),
    'video_bg_stat_2': Text.objects.get(name="video_bg_stat_2"),
    'video_bg_stat_3': Text.objects.get(name="video_bg_stat_3"),
    'advantages_title': Text.objects.get(name="advantages_title"),
    'advantages_subtitle': Text.objects.get(name="advantages_subtitle"),
    'advantages_box_title_1': Text.objects.get(name="advantages_box_title_1"),
    'advantages_box_title_2': Text.objects.get(name="advantages_box_title_2"),
    'advantages_box_title_3': Text.objects.get(name="advantages_box_title_3"),
    'advantages_box_title_4': Text.objects.get(name="advantages_box_title_4"),
    'advantages_box_subtitle_1': Text.objects.get(name="advantages_box_subtitle_1"),
    'advantages_box_subtitle_2': Text.objects.get(name="advantages_box_subtitle_2"),
    'advantages_box_subtitle_3': Text.objects.get(name="advantages_box_subtitle_3"),
    'advantages_box_subtitle_4': Text.objects.get(name="advantages_box_subtitle_4"),
}
return render(request, 'main/home.html', context)

here is text model

class Text(models.Model):
name = models.TextField(('Name'),default="defname")
content_geo = models.TextField(('Input Georgian Text Here'),default="defgeo")
content_eng = models.TextField(('Input English Text Here'),default="defeng")
content_esp = models.TextField(('Input Spanish Text Here'),default="defesp")

def __str__(self):
    return self.name

CodePudding user response:

You just have a typo just change .content.geo to .content_geo in your template .

change :

<div >
                <div >
                    <div >
                        <h3 >{{ advantages_title.content.geo }}</h3>
                        <p>{{ advantages_subtitle.content.geo }}</p>
                    </div>
                </div>
            </div>

to :

<div >
                <div >
                    <div >
                        <h3 >{{ advantages_title.content_geo }}</h3>
                        <p>{{ advantages_subtitle.content_geo }}</p>
                    </div>
                </div>
            </div>
  • Related