Django print object in template




















Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search. But what I get is an option for each character in strings instead of the country name as a whole.

I don't show JavaScript code in my example above as the intent of the question is how to parse and retrieve strings from a JSON object. I need to process this data using javascript later. In specific once the user change country I would like to populate another dropdown that will handle the cities, and therefore I thought to use JSON and Javascript to achieve that, as I don't want to refresh the page on each change. Why not just pass a dict into the template via context, just as everything else?

Add an extra context that isn't JSON serialized. This is a little redundant but a bit simpler. To be honest, I'd go for the second option since I don't see why you need to send it to the template in JSON in the first place.

This is why you get character after character when you iterate over it. In specific once the user change country I would like to populate another dropdown that will handle the cities. I highly recommend you to checkout django-autocomplete-light , which in addition to providing auto-completion, provides a way to filter results based on other fields. This will save you much efforts.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?

Collectives on Stack Overflow. Learn more. Add Your Comment. Become a more social person. Related Articles. How to render a Twig View inside a command in Symfony 5 January 23, How to setup your first django project and say hello world in Windows August 16, Follow Us. Week number of the year Sunday as the first day of the week as a decimal number [00,53]. Week number of the year Monday as the first day of the week as a decimal number [00,53]. In template, we can define a filter to retrieve all the fields.

Perrin W. Perrin 2, 25 25 silver badges 26 26 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.

Linked 0. Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings.



0コメント

  • 1000 / 1000