Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic (JS/Ajax) field updates w/ Django admin interface
    primarykey
    data
    text
    <p>This might be a complicated explanation. Here it goes.</p> <p>There are two models in the scope of this problem, <code>Asset</code> and <code>AssetGroup</code>. <code>AssetGroup</code> contains information about a 'group' of assets (e.g. brand, model, specifications) and <code>Asset</code> contains individual asset information (e.g. cost, date of purchase, reason for purchase, asset group).</p> <p>Obviously, a relationship exists between the two models, (e.g. assets belong to a certain 'group').</p> <p>So a person at this company goes to add a product to the database using Django's admin interface, and they have to select a group for their asset to belong to. The select-box for the asset group shows the <code>__unicode__</code> method for each asset group (of course), and the <code>__unicode__</code> method I'm using is a concatenation of the asset group brand, model, and sub-model:</p> <pre><code>def __unicode__(self): return self.asset_brand + " " + self.asset_product + " - " + self.asset_subproduct </code></pre> <p>Easy enough.</p> <p>Now, there are multiple entries in the <code>AssetGroup</code> table that end up with the same <code>__unicode__</code> method output, e.g. there are two items with:</p> <ul> <li><code>asset_brand = 'Apple'</code></li> <li><code>asset_product = 'Macbook Pro'</code></li> <li><code>asset_subproduct = 'Mid-2009'</code></li> </ul> <p>so they look exactly the same. The reason that they are separate entries in the first place is because there's a field in <code>AssetGroup</code> called <code>asset_description</code>, which holds additional information about the <code>AssetGroup</code> (e.g. the first Macbook Pro <code>AssetGroup</code> object might have 4GB of RAM, and the second <code>AssetGroup</code> object might have 8GB of RAM).</p> <p>So obviously there are two different products which look the same in the select-box when the client is entering an asset into the database. I'd like to (dynamically, using JS) show the selected <code>AssetGroup</code>'s <code>asset_description</code> to the client when they're entering an <code>Asset</code> into the database.</p> <p>Is there anything in Django that does this? If not, I guess I could redesign my database, but I really don't want to.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload