A minor but rather annoying flaw in the default layout of forms in Django manager apps is the positioning of checkboxes where the checkbox and its label are positioned in the first column and its help text (if set) is aligned in the second column:
Either the checkbox and label should be positioned in the second column or -better- the label should be aligned in the first column (with all other labels) and the checkbox positioned in the second column.
I presume the chances are slim, but is there a relatively easy fix for this?
If you can do it by adding css, then it is relatively easy:
class MyModel(admin.ModelAdmin):
class Media:
css = {
'all': ('/path/to/css.css',)
}
Related
How can I output a DecimalField right-aligned in Django admin listview? It makes much more sense to have a column of, say, prices, right-aligned.
I tried this: django align right cannot align, but it doesn't work, presumably, because it doesn't change the output behaviour.
I have a page item with name as P1_ITEM. It has list of countries and 'All' value(displays all countries records in IG) .
If the Item value is 'All' I need to refresh my Interactive grid with Pagination type as 'Page' else if any one of the country is selected then I need to refresh my Interactive grid with Pagination type to 'Scroll'. Can any one help me to set pagination dynamically for Interactive Grid.
Regards,
SwaZ.
Here's the documentation for the pagination settings relevant to the grid widget:
https://docs.oracle.com/en/database/oracle/application-express/19.2/aexjs/grid.html#pagination
Here's an example of setting the scroll property of the pagination settings for a given region (you can pass in more properties at the same time):
apex.region('emps').call('getViews').grid.view$.grid("option", "pagination", {scroll: false} );
Here's a tweet series where I break down some of the code you're seeing there: https://twitter.com/dmcghan/status/1199420591960469505
I am using dfrdmn's neat hack to add a summary row to a Django admin view. Briefly, it overrides the ChangeList for the ModelAdmin to append a new item to self.result_list._result_cache
However, this row is treated like other rows in that:
it has a selection box (for performing actions on it)
it has clickable link fields (for opening the edit view)
it has editable fields (for same-page edits)
it is considered part of the result_list when clicking Save (which results in an error)
How can I disable all of these so that the row is view-only, not selectable and ignored when saving?
As a bonus, displaying nothing for the "Like" field would be nice but is a low priority. (It's a NullBooleanField.)
In my template I have a field type of Droplist which maps to a Sitecore folder holding values for the Droplist which in this case is Colours. This is so that an editor cannot make a typo or invent a colour this is not in the pre-defined list.
So that colour is based off a template I call TAGS which has a single field type of 'colour' and here I create a series of items using that template to create the colours for the swatch list.
When I access the main template I duly see the colour values in that Droplist so its working as I would expect it because I can access that fields values:
tileValues.Attributes["class"] += " tile-" + Item.Fields["Tile Colour"].Value.ToLower();
However I have realized its not using the field value of the template but rather the name I have called the item. SO its just a happy mistake that its achieving the result I wanted.
However how would I obtain the actual field value for that item in the end code. I have scenarios where there will be multi lingual editors so we may name the tags as rouge, blanc etc which is what the editor will see on selection in the Droplist but we need the colour value of the field to still say red or white etc
I tried:
Item.Fields["Tile Colour"].Item.Fields["Colour"].Value
But this failed despite the API hint implying its valid.
I hope this makes sense and someone can help me obtain the actual field value and not the items name.
As Sitecore Climber wrote, don't use Droplist field type - it stores item name only and you cannot get the item itself in the code behind.
Use Droplink field type - it stores ID of the item.
Then you can get the item:
Item colourItem = Sitecore.Context.Database.GetItem(Item["Tile Colour"]);
if (colourItem != null)
{
string colour = colourItem["Colour"];
|
I would like to be able to store reusable html-formatted text in Sitecore and reference in codebehind for inclusion in a custom user control. What is the best practice for doing this? If a user selects option A, for example, I would reference standard text A in my control. Any examples for how to accomplish this are appreciated. Thanks.
You have a couple options:
Store the text in the Standard Values of the same template that defines your option list. That makes it available on the same item, but standard for all items. Use security to lock down the field if you are worried about it being edited. This could also be accomplished with the new "cloning" feature in 6.4, I believe.
Create a structure outside of your Home element for storing this data. Based on the option selected, find an item in your content tree which corresponds to the selected item, and read the text off of it. You would need to find this item either relative to /sitecore/Content, or relative to your website root if multi-site support is a requirement.
No.2 in pseudo-code:
//get the item where we have the text values
Item textBase = Sitecore.Context.Database.SelectSingleItem(textBasePath);
//find the child w/ the same name as the selected option
Item textItem = textBase.Axes.GetChild(selectedOptionValue);
string value = textItem["text"];
I think I would do something like techphoria414's 2. option:
ie you have your normal "page" templates as per usual, but then you have some fields (multilist, treelist fields), where you put the source pointing to your other items contain the different texts.
then you basically just have to get the items from the current item (with some very quick'n'dirty code/pseudocode):
var CurrentItem = Sitecore.Context.Item;
Sitecore.Data.Fields.MultilistField mlf1 = CurrentItem.Fields["myExternalTexts"];
if(mlf1 != null)
{
foreach (Item itm in mlf1.GetItems())
{
lit += Sitecore.Web.UI.WebControls.FieldRenderer.Render(itm, "richtext");
}
}
You ofc shouldn't just add them to a literal and you should you Sitecore built in Field renderes if using Sitecore 6 or above and it's a Rich text field.
I hope that helps.