Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Tommy Binkley
18,584 PointsItems in the grid are not in order
When I view the project in the port The items in the list show up in order from top to bottom as "Glasses, Hat, Footwear, Shirts, Pants", and in the video it shows its supposed to be "Shirts, Pants, Glasses, Hat, Footwear". Is there any easy fix to re-order the items?
Tommy Binkley
18,584 Points{% extends "layout.html" %}
{% block content %}
<!--Build Area -->
<form action="{{ url_for('save') }}" method="POST" class="wrap no-top">
<div class="grid-100 row">
<div class="grid-30">
<div class="title">
<input type="text" name="name" value="{{ saves.get('name', '') }}">
</div>
</div>
<div class="grid-70">
<div class="colors">
{% for color in options['colors'] %}
<input type="radio" id="{{ color }}" name="colors" value="{{ color }}"
{% if saves.get('colors') == color %}checked{% endif %}>
<label for="{{ color }}"></label>
{% endfor %}
<button class="btn">Update</button>
</div>
</div>
<div id="bear" class="grid-100 bg-{{ saves.get('colors') }}">
<div class="bear-body"><img src="/static/img/bear_body.svg" /></div>
{% if saves.get('footwear') %}
<div class="footwear"><img src="/static/img/bear_items_footwear-{{ saves['footwear'] }}.svg"></div>
{% endif %}
{% if saves.get('footwear') %}
<div class="pants"><img src="/static/img/bear_items_pants-{{ saves['pants'] }}.svg"></div>
{% endif %}
{% if saves.get('shirts') %}
<div class="shirt"><img src="/static/img/bear_items_shirts-{{ saves['shirts'] }}.svg"></div>
{% endif %}
<div class="head"><img src="/static/img/bear_face.svg" /></div>
{% if saves.get('glasses') %}
<div class="glasses"><img src="/static/img/bear_items_glasses-{{ saves['glasses'] }}.svg"></div>
{% endif %}
<div class="nose"><img src="/static/img/bear_nose.svg" /></div>
{% if saves.get('hat') %}
<div class="hat"><img src="/static/img/bear_items_hat-{{ saves['hat'] }}.svg"></div>
{% endif %}
</div>
<div class="items">
{% for category, choices in options.items() %}
{% if category != 'colors' %}
<div class="grid-100 row">
<div class="grid-20">
<p class="category-title">{{ category.title() }}</p>
</div>
<div class="grid-80">
<input type="radio" id="no_{{ category }}_icon" name="{{ category }}" value='' {% if not saves.get(category) %}checked{% endif %}>
<label for="no_{{ category }}_icon"><img src="/static/img/no-selection.svg"></label>
{% for choice in choices %}
<input type="radio" id="{{ category }}-{{ choice }}_icon" name="{{ category }}" value="{{ choice }}" {% if saves.get(category) == choice %}checked{% endif %}>
<label for="{{ category }}-{{ choice }}_icon"><img src="/static/img/{{ category }}-{{ choice }}.svg"></label>
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
</div>
</div>
</form>
{% endblock %}
1 Answer
jacinator
11,936 PointsThe code appears to be pulling category and choices from a dictionary. Dictionaries are unordered types and so having them out of order isn't a bug. It is just something that is going to happen unless you rework your code structure.
Tommy Binkley
18,584 PointsYeah I know dicts are unordered, but I was just curious if I did something wrong compared to what was in the video.
jacinator
11,936 PointsIt doesn't look like it.
Perry Marquer
11,243 PointsPerry Marquer
11,243 PointsWithout seeing the code or the task in question it's hard to see what is wrong or what the task is asking you to do.