Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
211 views
in Technique[技术] by (71.8m points)

Django - deployment on Heroku returns different HTML than local host

I have a Django app that works great on localhost. When deployed the Heroku, for some reason the app returns different HTMLs. A few examples:

  1. I have a form with button type submit. This is the template
        <button type="button" page="{{request.resolver_match.view_name}}" type="submit" id="bullets_submit"
            class="btn btn-primary px-5 py-2">
            Next Step
        </button>

In localhost everything works well. But, on Heroku, the HTML I receive is without the type="submit". Same button just without this attribute.

  1. I have a for loop that iterates on a model and create a li
        <div class="h5 mx-4 px-3 bg-white" style="position: absolute; top: -20px;">
            About the role <a href="{% url 'app:responsibilities' description.pk %}" type="button" class="btn btn-outline-light px-2 text-muted border border-0"><i class="far fa-edit"></a></button>
        </div>
        <div class="border border-primary rounded shadow p-2 pt-3 m-2">
            <ul>
                {% for responsibility in description_responsibilities%}
                <li>{{responsibility}}</li>
                {% endfor %}
            </ul>
        </div>

On Heroku, even though the <i class="far fa-edit"> is clearly outside of the for loop, it still get generated several times in the HTML I receive from the server, as if it was inside the for loop.

Any idea what might cause this weird behavior? Or how I can debug it?

question from:https://stackoverflow.com/questions/65875280/django-deployment-on-heroku-returns-different-html-than-local-host

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Found the reason. It was stupid (missing HTML tag).

What's interesting is that the page rendered nicely on my local Windows machine, but on Heroku, the issue appeared. It made it really hard to find what's wrong.

So I cloned my app to a linux shell and then the issue reproduced locally. From there it took 2 minutes to fix. I'm not sure why Windows django rendered a different page then linux.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

[2] html - How to create even cell spacing within a

1.4m articles

1.4m replys

5 comments

57.0k users

...