Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

404 error when trying to add a related (FK) object #12

Closed
edvm opened this issue May 5, 2015 · 8 comments
Closed

404 error when trying to add a related (FK) object #12

edvm opened this issue May 5, 2015 · 8 comments

Comments

@edvm
Copy link

edvm commented May 5, 2015

In my model form i have some FK to another models, and when trying to add them in the admin, i got a 404 error. The problem seems to be at:

(firefighters-hq) [edvm@laptop material]$ grep -R '%s%s' ./*

. /admin/templates/material/fields/django_relatedfieldwidgetwrapper.html:

I have attached a screenshot, when i click '+' i got the 404 error. Unfortunatly i dont know how to fix this issue to send a pr :-\

screenshot from 2015-05-05 08 34 09

@edvm
Copy link
Author

edvm commented May 5, 2015

Same bug seems to happen on demo page (when clicking the '+'), screenshot attached:
screenshot from 2015-05-05 08 48 39

@kmmbvnr
Copy link
Collaborator

kmmbvnr commented May 5, 2015

Yep, it's require a custom template tag to create a valid link. But seems it's not the last issue with new items creation.

@edvm
Copy link
Author

edvm commented May 5, 2015

@kmmbvnr can i help you with this problem? Maybe if you can point me to some file, code or doc?

@kmmbvnr
Copy link
Collaborator

kmmbvnr commented May 6, 2015

Here is how the url created in admin widget - https://github.com/django/django/blob/master/django/contrib/admin/widgets.py#L286

Basically, this should be recreated somehow in . /admin/templates/material/fields/django_relatedfieldwidgetwrapper.htm

Unfortunatelly django does not provide convinient methods on widget to get proper url in template, so i suppose it could be implemented as new tempate tag for material_admin template tags library

@kmmbvnr
Copy link
Collaborator

kmmbvnr commented May 6, 2015

Another option is to make material/fields/django_relatedfieldwidgetwrapper.htm very simple, leave only {{ bound_field }} as content and do everything in admin/related_widget_wrapper.html

It have propery context with all required urls.

@kmmbvnr
Copy link
Collaborator

kmmbvnr commented May 6, 2015

Actually i like the second option. If all django widgets was implemented as RelatedFieldWidgetWrapper most of django-material forms handing code will go away.

Unfortunately only RelatedFieldWidgetWrapper have rendered using django template

@kmmbvnr kmmbvnr added the admin label May 8, 2015
r3gis3r added a commit to r3gis3r/django-material that referenced this issue Aug 25, 2015
Use django rendering for bound field and customize only template as advised by @kmmbvnr
kmmbvnr added a commit that referenced this issue Nov 2, 2015
kmmbvnr added a commit that referenced this issue Nov 2, 2015
@diegocmsantos
Copy link

I have tested now and it's working.
The foreign model is saving but the select is not updated with the new model just saved.

@kmmbvnr
Copy link
Collaborator

kmmbvnr commented May 21, 2016

Should be fixed now

@kmmbvnr kmmbvnr closed this as completed May 21, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants