Questions tagged [templates]

23475 questions
1

votes
1

answer
1.8k

Views

using morris chart in django

I am trying to use a morris chart in django. morris chart requires a data in format $(Morris.Bar({ element: 'mchart', data: [ { y: '2006', a: 120 }, { y: '2007', a: 75 }, { y: '2008', a: 50 }, { y: '2009', a: 75 }, { y: '2010', a: 50 }, { y: '2011', a: 95 }, { y: '2012', a: 100 } ], xkey: 'y', ykeys...
Laxmi Kadariya
0

votes
3

answer
28

Views

How can I identify a user without login feature in Django?

I'm making Django app where visitors can answer to questions without login feature. The number of each answer will be counted as 'votes', but I need to restrict a user to answer a question only once. I need someone's help who has experienced in this.
web coder
1

votes
1

answer
136

Views

C++ placement of 'const' trouble.

First of all I would like to thank in advance anyone who answers this question. Your help is greatly appreciated. This is my first time posting here, so please forgive me if I post with bad etiquette. My question is about the method prototype: void copySubtree(Node * & target, Node * const & origi...
Tom
1

votes
2

answer
1.2k

Views

Using Django registration with a Flat UI template

I have created a template design for signup page using Flat UI. Now i want to use Django registration to register a user. I have goggled various resources but they are very complex and using Django inbuilt form to create a form. I need simple steps that i can follow signup.html(home/django/mysite/te...
Rohit.nib
1

votes
1

answer
2.2k

Views

Jinja - Indentation in a recursive loop with dictionary

I'm trying to write a template using ninja. But I can't display the right indentation! I tried a lot of stuffs but I couldn't get the expected result. I have a dictionary like this: videoNode = {'type': "VideoLoader", 'config': {'type': "url", 'source': "blabla", 'frameBufferSize': 50, } } I would l...
Romanzo Criminale
1

votes
2

answer
524

Views

Django - manually build HttpResponse, but want to use a template too

When returning an HttpResponse object with render_to_response you can provide a template and it will use that template and fill in all the {{ variables }} you've set within your template. If I want to build my HttpResponse object manually, is it possible to still use one of my templates in my templa...
Garfonzo
9

votes
3

answer
501

Views

How can a variadic template be used to generate a left-associative expression (aka left fold) in c++11?

I would like to use a c++ template to aggregate (fold) multiple arguments using a binary operation. Such a template could be used as follows: fold(100,10,5) expands to add(add(100, 10), 5) The particular expansion shown above is the "left fold". The expansion add(100, add(10, 5)) is the "right fold...
ricovox
1

votes
2

answer
10k

Views

border-radius alternative in email Templates

Well I am designing email templates and I know that CSS3 is not working on most of the email providers. I am trying bend the borders (that can be DONE by border-radius - but it is NOT supported by most of email providers). So is there any alternative of border-radius that works on all the email prov...
Junaid
1

votes
1

answer
140

Views

Why do you need external linkage for references to non-type template arguments

Suppose I have the struct: template struct Thing{ }; Later to declare it I have to do this: extern constexpr float value = 12.0f; Thing MyThing; Why does this need the extern keyword. I mean it should not matter whether or not the float is extern or not (should it?)
DarthRubik
1

votes
3

answer
1.7k

Views

Django: Get the form name or id from template

If you have multiple forms from django import forms class NameForm(forms.Form): your_name = forms.CharField(label='Your name', max_length=100) class SecondNameForm(forms.Form): your_name = forms.CharField(label='Your name', max_length=100) is there a way that, in your template, you can figure out i...
Algorithmatic
1

votes
2

answer
599

Views

Google App Script Convert Google Docs Template to PDF Template

I have a Google Docs template which is automatically copied into a folder and replace specific values with values coming from spreadsheet cells. The template contains values such as which are used to be "find-and-replaced" with values coming from a spreadsheet. The find-and-replace process is fine,...
JeffMan
9

votes
2

answer
458

Views

How to use implicit template type deduction

I am trying to write a template to calculate the power of a number during compile time(i am not a template meta-programming expert so any comment is appreciated). Below the code: template struct Pow { static constexpr T result = X * Pow::result; }; template struct Pow { static constexpr T result = 1...
eucristian
0

votes
0

answer
25

Views

Showing display values in form built with a loop

I have a simple model form for adding new objects. The template builds the form with a loop, i.e not every field is placed explicitely. The model has a few choice fields. Normally, if you want to see the the display value of the choice field you'd do something like {{ get_myfieldname_display }}. bu...
uwain12345
5

votes
1

answer
81

Views

Statically get offset of member variable

I'm searching a way to get the offset of a member variable to statically pass this offset to the member variable. Basically I want achieve this: template struct A { std::intptr_t self() { return reinterpret_cast(this) - OFFSET; } }; struct B { int some_variables[256]; A a; }; int main() { B b; asse...
JulianH
1

votes
1

answer
286

Views

Django. Pass an array to a child template via include tag

I'm trying to create an array on the fly and pass it to a child template: {% include "template.html" with foo = ['one', 'two'] %} but this doesn't work. Does anybody know how to generate an array in parent template and then pass it to another template?
MrBinWin
1

votes
1

answer
956

Views

Different css margins for mobile & desktop without multiple {% block content %} in Django template

I need to change the margin-left that is applied to my main {% block content %} in my base.html template (that contains my navbar and other common elements) based on if the viewer is using mobile or desktop. My current base.html is like: {% block content %} {% endblock %} with a css file containing:...
TimJ
1

votes
2

answer
69

Views

How to use c++ template to conditionally compile asm code?

There is a bool variable named "Enable", when "Enable" is false, I want to create following function: void test_false() { float dst[4] = {1.0, 1.0, 1.0, 1.0}; float src[4] = {1.0, 2.0, 3.0, 4.0}; float * dst_addr = dst; float * src_addr = src; asm volatile ( "vld1.32 {q0}, [%[src]] \n" "vld1.32...
maofu
4

votes
3

answer
144

Views

Specialize member functions based on size of member container

I have a class that holds some statically-sized containers: template struct Point { Container container; ... void bar(); } where a Container class might look like: struct Container1 { static constexpr size_t size = 5; } Now I want to specialize the bar method based on the size of the container. I...
bremen_matt
1

votes
4

answer
1.6k

Views

How to use templates instead of macros to create a class with a dynamic number of functions

Currently i am creating a base class with set and get functions with a macro. But I would like to add more complex macros but macros are really bad for debugging so I would like to do it with templates but I have no idea does someone know a book or link for me. My real problem is far more complex I...
Max
0

votes
0

answer
8

Views

I can't access a Django template variable in JS script

I'm having trouble accessing the list param = ['foo','bar'] on myView.js. the JS code is treating param as if it were a string, but when I try JSON.parse(param) I get the error shown below. What am I missing here? myView.html: window.obj = {}; obj.param = "{{ param | safe }}"; views.py: def myView(r...
Jane
1

votes
1

answer
818

Views

std::unique_ptr and templates: Why won't this code compile?

I am working on a templated component system for a game. It holds items in a vector and has two partial specializations: One for POD types and another that uses std::unique_ptr. The templated specialization for the vector of std::unique_ptr doesn't compile but using a vector of std::unique_ptr's in...
Colin
0

votes
0

answer
24

Views

static files in django is not working (404) although the path is right

the html page appear without any style or images because of not finding the static files in Django the load : {% load staticfiles %} this is the static call : the url setup : STATIC_URL = os.path.join(BASE_DIR, "static/")
Abanoub Magdy
5

votes
1

answer
105

Views

Way to Only Pass Second Template Parameter

So I have a template function which has a defaulted 2nd argument. It's 1st argument can be deduced, so something like: template void foo(const F param) This works fine in the general case, I'll just call foo(bar). But in the case where I want to specify the second argument, I cannot do this: foo(ba...
Jonathan Mee
1

votes
2

answer
1.4k

Views

load static file in a template that extends other template - Django javascript

I want to load a javascript file in the template that extends my base_generic template. I am using generic listView to render the template. Since I can not use "{% url %}" tamplate tag inside of "{% block %}" tag I hardcoded the link as follows: Unfortunately the file does not work and I get a a...
McCzajnik
1

votes
2

answer
7.5k

Views

Django - getting Error “Reverse for 'detail' with no arguments not found. 1 pattern(s) tried:” when using {% url “music:fav” %}

I am learning django framework from last 4 days. Today I was trying to retrieve a URL in HTML template by using {% url "music:fav" %} where I set the namespace in music/urls.py as app_name= "music" and also I have a function named fav(). Here is the codes: music/urls.py from django.urls import pat...
Vishal Ghosh
-1

votes
2

answer
43

Views

C++ ambiguous template overloads

I'm trying to use template specialization to return different types based on the value of the template variable. I've moved from trying to branch at runtime rather than compile time using typeof(), unspecialized templates and using std::enable_if_t. I think this may stem from a lack of understanding...
Mokou
0

votes
0

answer
3

Views

How To Download HTML Data As Doc File From Django DetailView

I am trying to figure out if there is a way to natively download data from my Django DetailView. I have been reading SO and getting ideas for the last day or so and I almost have it working.... Here is my code... class AuthorDetailView(LoginRequiredMixin,DetailView): model = Author context_object_n...
Steve Smith
1

votes
1

answer
197

Views

django - showing OrderedDict in templatetag

I have a OrderedDict and I need to show its key, value but I am unable to get its value, I have this dict = ([('sainbath', 'thesailor'), ('HELLO', 'WORLD')]), I have tried this {{object.specifications}} {% for key in object.specifications %} {{key}} {%endfor%} I am getting this output OrderedDict([(...
Pankaj Sharma
1

votes
1

answer
109

Views

Adaptive function of sorting in C++

I would like to make function for adaptive bubble sorting different collections with different types. Example of code: #include #include #include template void bubbleSort(CollectionType& ar, size_t size, std::function comparator) { bool isSorting = false; for (size_t i = 0; i < size - 1; i++) {...
VladimirBalun
0

votes
1

answer
30

Views

Why no ambiguity when choosing between templated and non-templated functions with same signatures?

The following code passes asserts: int foo() { return 1; } template int foo() { return 2; } int main() { assert( 1 == foo() ); assert( 2 == foo() ); return 0; } But to my understanding, according to Paragraph 13.3.3/1 of the C++ 11 Standard: [...] Given these definitions, a viable function F1 is def...
z3dd
0

votes
0

answer
6

Views

How to control indent after including file content in Helm configMap?

I'm setting up a ConfigMap for my Helm chart. As per good practice, I want to include non-yaml resources through separate files rather than inline. Currently I am trying to include both an xml file and a tpl helper in my ConfigMap under "data". Both are read without issue in the below code. But I ca...
Bluebluebleu
1

votes
2

answer
24

Views

Assign list to a key within a chart

Deployment.yaml ... env: {{ .Values.env}} ... Values.yaml: env: - name: "DELFI_DB_USER" value: "yyy" - name: "DELFI_DB_PASSWORD" value: "xxx" - name: "DELFI_DB_CLASS" value: "com.mysql.jdbc.Driver" - name: "DELFI_DB_URL" value: "jdbc:sqlserver://dockersqlserver:1433;databaseName=ddbeta;sendStringPar...
4c74356b41
1

votes
1

answer
52

Views

Can I use a Fold Expression in this example

I want to know if it is possible to use fold expression (and how to write it) in the example below. #include #include #include #include #include template std::string padFormat() { return ""; } template std::string padFormat(const T& t) { std::ostringstream oss; oss
Blood-HaZaRd
-1

votes
1

answer
45

Views

Tempalated function overloading

I am learning about game development and in the book i need to overload a function with a template. original function is template void ResourceHolder::load(Identifier id, const std::string& filename) {} and the overloaded version is template template void ResourceHolder::load(Identifier id, cons...
OgiciBumKacar
-2

votes
0

answer
41

Views

How do I pass all vector elements separated by comma into function in C++?

I have been reading this website for quite a while now but have just registered. I have also used search which did not seem to be very helpful. Here it is: As I am having fun with C++ I come along "lazy evaluation" conception on the Internet. I am interested in creating something like a "lazy vector...
Nick M
1

votes
2

answer
427

Views

Django: How to nicely format an address in a template without knowing how much information is available?

I have a table with address information. It has these fields. address_1 address_2 city state zip No field is required. I want to display this in a template and format it nicely. I want line breaks between address_1, address_2, and the city/state/zip line for any of those that exists. I also want a c...
raddevon
1

votes
1

answer
3.9k

Views

display django model data in custom template

I have django models such as this class District(models.Model): name = models.CharField(max_length=30,unique=True) number = models.PositiveIntegerField(null=True,blank=True) def __unicode__(self): return "District (%s,%s)" % (self.name,self.number) class Meta: db_table = 'districts' And i can be ab...
roykasa
-1

votes
0

answer
21

Views

std::string out of range eventhough I am not using any index

I get the following error message: string subscript out of range. I believe it has more to do with my templates definition because I am not using any string subscripts anywhere. I have not been able to figure this out, I have tried defining and implementing my templates in various ways but the resul...
Daniel Duque
10

votes
2

answer
578

Views

Using std::apply with variadic packs

I am trying to create a generic class that takes a pack of types, stores them in a tuple, and can apply a function over them. What I tried so far is the following: #include struct Base{ virtual void base_function() = 0; }; template struct A : public Base{ std::tuple as; A(T... pack):as(pack...){};...
sqrtroot

View additional questions