Django Forms initials not working for some fields? - Could be ID conflict

I just realized that I have in others pages id_address for google autocomplet and id_latitude and id_longitude. So I will rename my fields to fix it. But if someone knows another work around I will br very thankfull!!!

Something weird is happening. I am trying to get initial fields into my form but only some of then are filled. The address, latitude and longitude wont.

this is my form:

class OrderForm(forms.ModelForm):
class Meta:
model = Order
fields = ['first_name', 'last_name', 'cpf', 'phone', 'email', 'address', 'street_name', 'street_number', 'address_complement', 'country', 'state', 'city', 'pin_code', 'latitude', 'longitude',]

This is my view:

default_values = {
    'first_name': request.user.first_name,
    'last_name': request.user.last_name,
    'cpf': request.user.cpf,
    'phone': request.user.phone_number,
    'email': request.user.email,
    'address': checkout_address.address,
    'street_name': checkout_address.street_name,
    'street_number': checkout_address.street_number,
    'address_complement': checkout_address.address_complement,
    'country': checkout_address.country,
    'state': checkout_address.state,
    'city': checkout_address.city,
    'pin_code': checkout_address.pin_code,
    'latitude': checkout_address.latitude,
    'longitude': checkout_address.longitude
}
form = OrderForm(initial=default_values)

When I print the default_values I got all right:

{'first_name': 'Admin', 'last_name': 'Sistemas', 'cpf': '9999999', 'phone': '98989898', 'email': 'rm@rm.com', 'address': 'Rua dos Lamentos, 10, Armação dos Búzios - RJ', 'street_name': 'R. dos Lamentos', 'street_number': '10', 'address_complement': 'ap32', 'country': 'Brasil', 'state': 'Rio de Janeiro', 'city': 'Armação dos Búzios', 'pin_code': '28950-000', 'latitude': '-22.7980796', 'longitude': '-41.9321335'}

But by some how those three fields are not filed:

enter image description here

Does someone could give me a tip on what the wack is going on?

I tried to take some fields out and in but those three fields wont appear!

Thank you very much for any help!

Вернуться на верх