Django-Oscar - Address Book not working on shipping-address

I'm having this problem that I mentioned in the title and I've been trying to fix it all morning, I've done some tests to find out where the error is coming from, I found out where it came from, but when I get to the file, I don't see any errors...

enter image description here

As you can see, the user is logged in, but he cannot find an address for this user, since I have already registered one.

See the code:

{% extends "oscar/checkout/checkout.html" %}
{% load i18n %}

{% block title %}
    {% trans "Shipping address" %} | {{ block.super }}
{% endblock %}

{% block checkout_nav %}
    {% include 'oscar/checkout/nav.html' with step=1 %}
{% endblock %}

{% block checkout_title %}{% trans "Shipping address" %}{% endblock %}

{% block order_contents %}{% endblock %}

{% block shipping_address %}
<div class="col-sm-12">
    <div class="sub-header">
        <h2>{% trans "Where should we ship to?" %}</h2>
    {% if user.is_authenticated %}
        <p>User logged in</p>
        {% if addresses %}
            <p>Addresses: {{ addresses }}</p>
            <h3>{% trans "An address from your address book?" %}</h3>
            <div class="choose-block">
                <div class="row">
                    {% for address in addresses %}
                        {% block select_address_form %}
                            <div class="col-sm-6 d-flex">
                                <div class="card card-body bg-light">
                                        {% block select_address_fields %}
                                            {% for field in address.active_address_fields %}
                                                <span>{{ field }}</span>{% if not forloop.first %}<br/>{% endif %}
                                            {% endfor %}
                                        {% endblock %}
                                    <form action="{% url 'checkout:shipping-address' %}" method="post" id="select_shipping_address_{{ }}" class="mb-0">
                                        {% csrf_token %}
                                        <input type="hidden" name="action" value="ship_to" />
                                        <input type="hidden" name="address_id" value="{{ }}" />
                                        {% if address.is_default_for_shipping %}
                                            <button type="submit" class="btn btn-success btn-large ship-address" data-loading-text="{% trans 'Saving...' %}"><i class="fas fa-check-circle"></i> {% trans "Ship to your default shipping address" %}</button>
                                        {% else %}
                                            <button type="submit" class="btn btn-primary btn-large ship-address" data-loading-text="{% trans 'Saving...' %}">{% trans "Ship to this address" %}</button>
                                        {% endif %}

                                        <div class="btn-group address-controls">
                                            <a href="{% url 'checkout:user-address-update' %}" class="btn btn-secondary">{% trans "Edit address" %}</a>
                                            <button class="btn btn-secondary dropdown-toggle" data-toggle="dropdown"></button>
                                            <ul class="dropdown-menu">
                                                <a href="{% url 'checkout:user-address-delete' %}" class="btn-remove-address nav-link">{% trans "Delete" %}</a>
                            {% if forloop.counter|divisibleby:2 %}
                                </div><div class="row">
                            {% endif %}
                        {% endblock %}
                    {% endfor %}
            <h3>{% trans "Or a new address?" %}</h3>
        {% endif %}
        <p>No addresses found</p>
    {% endif %}

    {% block new_address_form %}
        <div class="card card-body bg-light">
            <form action="{% url 'checkout:shipping-address' %}" method="post" id="new_shipping_address">
                {% csrf_token %}
                {% include "oscar/partials/form_fields.html" with form=form style='horizontal' %}
                <div class="form-group row">
                    <div class="offset-sm-4 col-sm-8">
                        <button type="submit" class="btn btn-lg btn-primary" data-loading-text="{% trans 'Continuing...' %}">{% trans "Continue" %}</button>
                        {% trans "or" %} <a href="{% url 'basket:summary' %}">{% trans "return to basket" %}</a>
    {% endblock %}

<script src="" integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" crossorigin="anonymous"></script>


        $("#id_postcode").on("blur", function(){
          var cep = $(this).val();
            url: ""+ cep +"/json/",
            method: "GET",
            success: function(data){

{% endblock shipping_address %}

{% block shipping_method %}{% endblock %}
{% block payment_method %}{% endblock %}

Part of the code:

class ShippingAddressView(CheckoutSessionMixin, generic.FormView):
    template_name = 'oscar/checkout/shipping_address.html'
    form_class = ShippingAddressForm
    success_url = reverse_lazy('checkout:shipping-method')
    pre_conditions = ['check_basket_is_not_empty',
    skip_conditions = ['skip_unless_basket_requires_shipping']

    def get_initial(self):
        initial = self.checkout_session.new_shipping_address_fields()
        if initial:
            initial = initial.copy()
            # Convert the primary key stored in the session into a Country
            # instance
                initial['country'] = Country.objects.get(
            except Country.DoesNotExist:
                # Hmm, the previously selected Country no longer exists. We
                # ignore this.
        return initial

    def get_context_data(self, **kwargs):
        ctx = super().get_context_data(**kwargs)
        if self.request.user.is_authenticated:
            # Look up address book data
            ctx['addresses'] = self.get_available_addresses()
        return ctx

What should I do so that when the user already has an address registered, it appears on this tab and he only selects the address?

As I put it in the code, I tried to find out where the error was coming from... I put a <p> tag after the user's authentication conditional to see if at least it was entering the block. Yes, it is.

I did the same thing for the address conditional, and this is where the problem lies, it doesn't identify the address even though it's already registered.

I went to check the views and didn't find any errors... at least I don't see them.

Back to Top