You need to set a Subcategory as default when this field is loaded by the field Category? Sorry Martyn, i didn't get your doubt, could you elaborate more?
On May 13, 2:23 am, martyn <[EMAIL PROTECTED]> wrote: > It's true, I don't know for what reason I changed this before posting, > but I've seen the error to, correct it and, no way. > But I made a error on my urls, > this /admin/boutique/produit/getsubcategory/ was not the same as > urls.py, so I had no response. > > Now I've got another question. I've never used jQuery and I'm also new > to django. > I can't find the way to don't repeat my self on loading my object and > show the subcategory with jQuery. > > On load > 1- Load the results for the current category > 2- Select the current subcategory > > <script type="text/javascript" charset="utf-8"> > $(function(){ > $("select#id_categorie").change(function(){ > $.getJSON("/admin/boutique/produit/getsubcategory/",{id: $ > (this).val()}, function(j){ > var options = '<option value="">---------</option>'; > for (var i = 0; i < j.length; i++) { > options += '<option value="' + j[i].id + '">' + j[i].nom + '</ > option>'; > } > $("select#id_sous_categorie").html(options); > }) > }) > > }) > > $(document).ready(function(){ > $.getJSON("/admin/boutique/produit/getsubcategory/",{id: > document.getElementById("id_categorie").value}, function(j){ > var options = '<option value="">---------</option>'; > for (var i = 0; i < j.length; i++) { > options += '<option value="' + j[i].id + '">' + j[i].nom + '</ > option>'; > } > $("select#id_sous_categorie").html(options); > })}); > > // HOW TO GET {{ object.subcategory }} ? > </script> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---