-
-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting dictionary values from built in form #133
Comments
@jeffykle , it does perform the parsing but only in conjunction with the jquery script that queries googles places api. The autocomplete suggestions will be automatically broken into the components you seek. See the example for a demo. If you cannot use the places api, I recommend creating a form that collects the components. After validating them, you can Please let me know if this isn't clear or if you have a suggestion for changes to how it behaves or the documentation. |
@banagale Thanks for your input. It wasn't clear to me how it worked as I was using the form provided with the template tag in the readme which only had one visible input field. Now after more inspection I see I can directly access the address components within the form after selecting a result. On a separate note, it might be nice to leave some hints on how to customize the form. I found it easiest to use django-widget-tweaks so I could quickly add a Bootstrap class to the input field and change or remove the input label. https://github.com/jazzband/django-widget-tweaks
|
@jeffykle You'e welcome. Would you please describe a bit more what your goal was from the start and perhaps a screenshot of the UI you ended up with? If I can, I want to make sure we at least address the use case with ideally a few directions on how to implement it in the docs. (Including, perhaps the widget tweaks method you described) Re-opening with the hope of capturing this and converting into a documentation issue. |
Sure, my use case is to capture shipping addresses and save them to a user's profile (specifically U.S. only in my case). I'll get the address components with jquery and pass them to a django view with an ajax call. It will add a new address if the user doesn't already have that one saved, and select it in the billing form.
I believe the dataset.geo attributes of the form come from this package, and if so, it would be nice to update them so they match the dictionary values used for saving the address object in Django. As you can see I had to remap some of the field names, but it would be much simpler without doing so. views.py
Finally, I have to figure out how to add a "Street Address #2" field, possibly appending it to one of the existing fields, or just adding an extra field to my |
@jeffykle Thank you for this additional set of information on your use case. I will carefully at your implementation and suggestions. I'm leaving this ticket open for now, so I can be sure it gets looked at. |
Does the built in form allow me to save the addressed parsed into the different dictionary values?
When I use the form, I can only see one input "address" and when saving model instance, it just populates the "raw" field.
models.py
views.py
As seen in Django-Admin
![image](https://user-images.githubusercontent.com/37871091/93718433-d13b6c80-fb41-11ea-8585-c5788887d1d9.png)
The text was updated successfully, but these errors were encountered: