Django how to pass custom variables to context to use in custom admin template?

class MyModelAdmin(admin.ModelAdmin): … def changelist_view(self, request, extra_context=None): extra_context = extra_context or {} extra_context[‘some_var’] = ‘This is what I want to show’ return super(MyModelAdmin, self).changelist_view(request, extra_context=extra_context) See: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.changelist_view

Recommended jQuery templates for 2012? [duplicate]

This is how I do it in my projects: Define a template in your HTML: <script type=”text/template” id=”cardTemplate”> <div> <a href=”https://stackoverflow.com/questions/14062368/{0}”>{1}</a> </div> </script> Use string.format to substitute variables: var cardTemplate = $(“#cardTemplate”).html(); var template = cardTemplate.format(“http://example.com”, “Link Title”); $(“#container”).append(template); string.format: String.prototype.format = function() { var args = arguments; return this.replace(/{(\d+)}/g, function(match, number) { return typeof … Read more

Are pure virtual methods allowed within a template class?

A class template can indeed contain virtual or pure virtual functions. This was employed by Andrei Alexandresu in “Modern C++ Design” to implement the visitor pattern using templates and type lists. You can see the code here in his Loki library if you’re interested. With most standard C++ implementations, this is fine, because when the … Read more

C++ Virtual template method

The problem is that you cannot mix static time polymorphism (templates) with runtime polymorphism easily. The reason for the language disallowing the particular construct in your example is that there are potentially infinite different types that could be instantiating your template member function, and that in turn means that the compiler would have to generate … Read more

How does the template parameter of std::function work? (implementation)

After getting help from other answers and comments, and reading GCC source code and C++11 standard, I found that it is possible to parse a function type (its return type and its argument types) by using partial template specialization and function overloading. The following is a simple (and incomplete) example to implement something like std::function: … Read more

How to populate a WPF grid based on a 2-dimensional array

The purpose of the Grid is not for real databinding, it is just a panel. I am listing down the easiest way to accomplish the visualization of a two dimensional list <Window.Resources> <DataTemplate x:Key=”DataTemplate_Level2″> <Button Content=”{Binding}” Height=”40″ Width=”50″ Margin=”4,4,4,4″/> </DataTemplate> <DataTemplate x:Key=”DataTemplate_Level1″> <ItemsControl ItemsSource=”{Binding}” ItemTemplate=”{DynamicResource DataTemplate_Level2}”> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation=”Horizontal”/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </DataTemplate> </Window.Resources> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)