Privacy policyContactsAbout siteOpinionsGitHubDonate
© EVILEG 2015-2018
Recommend hosting
Feb. 26, 2019, 10:22 a.m.


SFINAE, C++17, template

There was a problem: "write the second implementation of the template function", in which the same arguments are passed. That is, the signature of both functions completely coincides. The difference is that, as an argument, the std::vector containers and the std::map containers can be passed to the function. And depending on whether std::vector is or std::map, this or that implementation should be selected.

In this case, the SFINAE rule will be used, which states: If the final types of arguments cannot be calculated (to perform substitution of template parameters) of an overloaded template function, the compiler does not throw an error, but searches for another suitable overload. The error will be in three cases:

  • No suitable overload was found.
  • Several such overloads were found, and C ++ cannot decide which one to take.
  • The overload was found, it turned out to be a template, and an error occurred when instantiating the template.

Our case will be the second. There are two overload template functions.

Jan. 28, 2019, 6:19 a.m.


Django, jinja, Python, template

На ресурсе Medium Corporation пользователь под ником Samu делится опытом использования Jinja2. По его словам ранее он использовал Jinja2 в своих проектах, созданных с помощью Flask. Но затем решил использовать Jinja2 с Django для потенциального повышения производительности (в 10-20 раз быстрее по сравнению с шаблонами Django) и взаимодействия с Nunjucks. Samu делится опытом с людьми, которые уже знакомы с данными технологиями, а его статья призвана немного раскрыть и упростить шаги.

Jan. 27, 2019, 4:49 p.m.

Добрый день!

На одной html странице нужно разместить два UpdateView. Для этого имя формы для одного хочу изменить на update_form, а второе на upd_form.

Стандартно в html файле UpdateView для формы использует имя form.

Код формы в html:

<form action="." method="POST">
    {% csrf_token %}
    {{ form.as_p }}
    <button class="btn btn-outline-info" type="submit" value="Save">Add</button>
    <a href="{% url 'home' %}" class="ml-2 mt-2">Cancel</a>

В документации указано что для изменения этого имени нужно указать context_object_name.

Пробовал так (

class DataUpdateView(LoginRequiredMixin, UpdateView):
    template_name = 'index.html'
    form_class = MyForm
    context_object_name = 'update_form' ###

    def get_object(self):
        return get_object_or_404(Project, id=self.kwargs.get('id'))

    def form_valid(self, form):
        return super().form_valid(form)

    def get_context_data(self, *args, **kwargs):
        context = super(ProjectUpdateView, self).get_context_data(*args, **kwargs)
        data = filter(self.request)
        return context


<form action="." method="POST">
    {% csrf_token %}
    {{ update_form.as_p }}
    <button class="btn btn-outline-info" type="submit" value="Save">Add</button>
    <a href="{% url 'home' %}" class="ml-2 mt-2">Cancel</a>

Не работает. Возможно я что-то не так понял?

Jan. 5, 2019, 2:49 p.m.


templatetags, template, Django

In Django - Lesson 035. Different templates for rendering different types of content in search results it was shown how to render different templates depending on what type of content drawn in the search results on the site. In this case, the key point was that it was not necessary to make the verification conditions for the selection of the template. The information about the balbalon was stored in the variable TEMPLATE_PREVIEW, through which the template was inserted into the include tag in the Django template.

{% include object.TEMPLATE_PREVIEW %}

In this method there is one big drawback. The fact is that the include tag with each of its calls is looking for a template. With a large load on the site - this can significantly increase the duration of the response from the server. To solve this problem, you need to somehow cache the pattern. Since different types of content use different templates, to do this using inclusion_tag is quite problematic.

This problem was solved by caching the template at the class level as a class variable.

Aug. 6, 2018, 6:52 a.m.


template, lambda, C++11

The world of programming in C ++ in the new standards allows us to get up a variety of things, thanks to which we can safely abandon some old statements or principles, or simply flexibly approach these principles.

I would like to outline my view on the work of the RAII idiom and the C ++ 11 standard with respect to one established principle whose authorship is attributed to Edsger Dijkstra :

"The module (in this case the function) must have only one entry point and only one exit point"

For this principle, multiple returns in a function / method are contrary to the principles of structured programming for the following reasons:

  • the complexity of debugging code with the use of multiple returns returns increases with the number of these same return, that is, you never know when the function or method of an object just exited.
    the complexity of code support, when all the points of the call are not visible at the initial look at the function. Also, it is not known whether the code added to the end of the function will execute or not, especially if the program logic should always execute this code. That is, in the case of multiple returns, you will have to implement this code before every call to the return operator.

But modern C ++ has already changed significantly since the times of Dijkstra and the means of the latest C ++ standards allow to bypass or significantly level out the influence of the reasons that caused the formulation of the principles of structured programming.

July 5, 2018, 7:05 a.m.


Django, template, content, Search

Constant visitors of the site who use the search on the site, probably noticed that the display of articles differs from displaying comments in the search engine issue of the site. This was achieved by the fact that each content type has its own template for rendering, which is substituted for the rendering of the page, depending on what content was found in the search.

Let's look at the example of issuance.

You see, here the presentation of the comment differs from the article, but they are output in the framework of one search issue, as was done in the previous article.

But this is done much more elegantly than selecting via if else . Honestly, I myself really like this decision.

Sept. 18, 2016, 7:41 a.m.


view, model, template

In Django uses a modular system of applications, where one application is composed of several applications, each responsible for its functionality. As you have noticed, at the time of this writing, the site has a section "Knowledge", in which there are several sections, which have divided the article.

When working with the previous site on Wordpress, mindlessly spend time on the addition of new articles to the list of lessons on Qt. On this same site the page is automatically generated and save a new article is published with the status, this article will automatically enters the relevant section of the list.

I suggest to understand how it is implemented in a minimal version of the example EVILEG COM.

March 18, 2019, 3:12 p.m.
Пётр Махнёв

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
March 18, 2019, 7:59 a.m.
Ян Греку

C++ - Тест 003. Условия и циклы

  • Result:21points,
  • Rating points-10
March 15, 2019, 4:32 p.m.
Михаил Дементьев

C++ - Test 001. The first program and data types

  • Result:60points,
  • Rating points-1
Last comments
March 16, 2019, 1:55 p.m.

Спасибо за статью. Давно итересует следующий вопрос: с помощью переменных QMAKE_TARGET_COMPANYQMAKE_TARGET_PRODUCTQMAKE_TARGET_DESCRIPTIONможно задать свойства компилируемой программы, о...
March 12, 2019, 10:19 a.m.
Jean Stefanovich

Большое спасибо за разъяснения!
March 12, 2019, 10:04 a.m.
Евгений Легоцкой

Hello, In fact, this functionality or is not implemented, or is not documented. I'm not sure. But I think, that it should be implemented in Text QML Type. Because of we can write text in...
March 12, 2019, 9:51 a.m.
Евгений Легоцкой

Да вы правы. На самом деле проще через QSqlQueryModel, сколько не пытался использовать эти дженерики типо QSqlTableModel и QSqlRelationalTableModel, то всегда упирался в какие-то их ограничени...
March 12, 2019, 9:47 a.m.
Jean Stefanovich

Единицы измерения лежат там же где и названия продуктов. Просто в таблице ингредиенты нет ещё одного столбца, на который можно было бы установить setRelation. Я в итоге в базе создал ещё один ...
Now discuss on the forum
March 17, 2019, 10:47 p.m.
Евгений Легоцкой

Добрый день. Вот, нашлось у меня немного времени. Делается это через шаблон проектирования наблюдатель.
March 15, 2019, 9:52 p.m.
Чарльз Грин

спасибо, попробую, отпишусь
March 15, 2019, 7:41 p.m.

Сори догадался)
March 12, 2019, 4:57 p.m.

Большооооое спасибо!!!!!Не передать как я вам благодарен, спасибо что всегда отзываетесь.Теперь я смогу продолжить работу в QT!!! (пробую писать бота (Я как вы могли догадаться немного не пр...
March 12, 2019, 1:20 p.m.

Ну так если у вас есть готовая программа так ей и воспользуйтесь. Вы же написали ее вот и пользуйтесь.
Join us in social networks

For registered users on the site there is a minimum amount of advertising