Advanced search
MU
Dec. 11, 2019, 6:27 a.m.
Maciej Urmański

DjangoCount user objects e.g posts

Hi, I try to get numbers of user post.

I have model Embed and try to count how many user add this embeds.

My model:

class Embed(models.Model):
    url = models.URLField(max_length=255)
    title = models.CharField(max_length=255, verbose_name='Tytuł')
    description = HTMLField…

DjangoDjango - Tutorial 050. Creating Dynamic Site Settings Using SingletonModel

Nov. 22, 2019, 2:03 a.m.

Django, SingletonModel, singleton, Model

Let's say you create a site with CMS based on Django, which must have some kind of dynamic site settings that will be available to the user. For example, the name of the site, some specialized information, while you take into account the possibility of multilingualism. What then can be used for this? I got the idea to use a database.

To implement this, the following is required:

  1. Creating a data model that will always contain only one object, that is, only one record. That is, it will be a Singleton Model.
  2. Prohibit deleting this entry and creating new ones in the Django admin panel
  3. The ability to use information from this model directly in the template, without loading the site settings in the view function.

Let's figure out in order how to implement this.

MU
Nov. 3, 2019, 5:20 a.m.
Maciej Urmański

DjangoDjango letter avatar like this on evileg

I try many apps and none of this create that nice letter avatars and cover on profile page. It's app or custom work?

It's possible to get a code? :)

DjangoEVILEG-CORE. Caching properties of model objects using model_cached_property

Nov. 3, 2019, 4:03 a.m.

ESNF-C, Django, model_cached_property, EVILEG

To speed up the site, in addition to optimizing database queries, you can use caching.

Django allows you to cache:

  • individual view , both Class Based View , and ordinary functions view
  • whole templates or parts of these templates
  • QuerySet
  • as well as properties of model objects using cached_property

I was interested in the ability to cache individual properties of model objects for heavy computing or heavy database queries.
The cached_property decorator has such a functional, but the drawback for me was that caching occurred only for the lifetime of the object.
Whereas I need caching for a longer period of time than the existence of an object when requesting a page. And also I needed to cache properties depending on the input arguments. This decorator on the site caches the number of likes and dislikes, as well as information about whether the current user liked a particular content object.

Thus the decorator model_cached_property was written

MU
Nov. 2, 2019, 3:22 p.m.
Maciej Urmański

DjangoDjango follow unfollow

Hi,

I try to solve my problem. I have follow and unfollow button on profile page, and on this page button works but I need to create this button on other pages. My problem is to filter when user is in target or not.

On profile page I have code:

{% if profile_user.followed %}
<…

EVILEGRelease EVILEG-CORE 0.0.5

Oct. 27, 2019, 4:55 a.m.

ECNF-C, Django, EVILEG, Releases, Python

Introducing the new release of EVILEG-CORE 0.0.5.

DjangoDjango - Tutoral 049. Optimizing Django Performance with a Real Project

Oct. 22, 2019, 1:39 a.m.

django-silk, performance, Django

Recently I have devoted a lot of time to website optimization and now I would like to talk about it.
This article will explain the use of the select_related and prefetch_related methods in QuerySet, as well as their differences. I will also try to explain why Django is considered slow, and why this is still not the case. Of course, Django is slower in many ways than the same Flask, but at the same time in most projects the problem is not in Django itself, but rather in the absence of optimizing database queries.

Therefore, let's optimize the EVILEG website forum page . And the Django Silk battery will help us with this, which serves to measure the number of queries to the database, as well as measure their duration.

Oct. 16, 2019, 11:07 a.m.
Ruslan Volshebnik

DjangoКак реализовать таймер на Django для викторины в telegram боте?

Здравствуйте.

Я делаю викторину в telegram боте на Django.
Суть заключается в том, что нужно выдавать вопрос с ответами пользователю на определенное время, а после окончание времени ему выдается следующий вопрос, но если пользователь вовремя ответил на вопрос, то таймер обновляется …

ChG
Oct. 14, 2019, 10:57 a.m.
Charl'z Grin

DjangoОбмен данными между сайтов Django и приложением Qt

Добрый вечер, задача такая: есть некое приложение на Qt, которое должно обмениваться данными с сайтом на Django. Так в чем вопрос, как прислать данные с приложения Django на клиент Qt и обратно? Как вообще организовать их взаимодействие между собой, чтоб придожение могло когда угодно получить …

DjangoDjango - Tutorial 048. How to add online status to a site

Sept. 2, 2019, 7:31 a.m.

Auth, Django, Backend, Python

For a long time I did not add such functionality on the site for the simple reason that I did not know which side to approach this, because I would like to process this information in one single place, and not in every View.

Over time, I began to modify Backend classes for the site and the solution came by itself. It was only necessary to modify each authentication backend that is used on the site. And rewrite the get_user method, which will store information about the user's last request to the site. And the online status can be saved for the last 15 minutes, then the status will be offline.

And the date of the last request can be stored either in the user’s profile, which will be the OneToOne model for the user, or override the user model. I chose the option of overriding the user model.

How to become an author?

Contribute to the evolution of the EVILEG community.

Learn how to become a site author.

Learn it
Donate

Good day, Dear Users!!!

I am Evgenii Legotckoi, developer of EVILEG. And it is my hobby project, which helps to learn programming another programmers and developers

If the site helped you, and you want also support the development of the site, than you can donate by following ways

PayPalYandex.Money
Timeweb

Let me recommend you the excellent hosting on which EVILEG is located.

For many years, Timeweb has been proving his stability.

For projects on Django I recommend VDS hosting

View Hosting Timeweb
AS
May 26, 2020, 12:29 p.m.
Artem Sun-Dun-Chan

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

  • Result:50points,
  • Rating points-4
MN
May 25, 2020, 12:33 p.m.
Mitja Nagibin

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

  • Result:50points,
  • Rating points-4
f
May 25, 2020, 6:05 a.m.
falcon

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

  • Result:66points,
  • Rating points-1
Last comments
May 29, 2020, 7:30 a.m.
Evgenij Legotskoj

Qt/C++ - Lesson 039. How to paint stroke in QSqlTableModel by value in the column?

У меня работает. Исправлял в проекте, который приложен к статье. А что происходит в вашем коде, с учётом места вызова этого кода, я знать не могу ;) Дебажьте и добавляйте условия, кото…
MA
May 29, 2020, 7:27 a.m.
Mihail A

Qt/C++ - Lesson 039. How to paint stroke in QSqlTableModel by value in the column?

QModelIndexList rowIndexes = ui->tableView->selectionModel()->selectedRows(); model->removeRows(rowIndexes.first().row(), rowIndexes.size()); model-&…
May 29, 2020, 7:14 a.m.
Evgenij Legotskoj

Django - Tutorial 036. How to add authentication through social networks. VKontakte

Неправильно прописали URL, на который возвращается ответ от OAuth ВКонтакте. Настраивайте ваше приложение в консоли разработчика ВКонтакте
AL
May 29, 2020, 6:24 a.m.
Aleksandr Leonidov

Django - Tutorial 036. How to add authentication through social networks. VKontakte

Здравствуйте! После клика на ссылку авторизации выдает json словарь с ошибкой: {"error":"invalid_request","error_description":"redirect_uri is incorrect, check application redirect uri in …
May 28, 2020, 4:14 p.m.
Evgenij Legotskoj

Qt/C++ - Lesson 039. How to paint stroke in QSqlTableModel by value in the column?

Ну в моём примере, который в статье сработало так model->setData(model->index(1, 1), 7); Поскольку model->index(1, 0) - это индекс колонки id, которая скрыта, поэтому…
Now discuss on the forum
DK
May 29, 2020, 9:44 a.m.
Dzhon Kofi

QMap<> какой ключ лучше

Привет. Есть QModelIndex и QString (одно слово). Что лучше поставить ключом индекс или строку? Данных мало, почти всегда 1. Понимаю, что строка проще, но как мапа с индексом в ключе работат…
May 29, 2020, 8:52 a.m.
Vladimir Sergeevich

Масштабирование двумя пальцами на мобильных платформах

Я планировал описать этот момент на блоге, но никак руки не доходят (уже год). Летом дойдут. Тем не менее, у меня в репозитории лежит рабочий код игрушки "пазлы", где есть все это. …
May 29, 2020, 7:51 a.m.
Evgenij Legotskoj

Графическое ускорение

Зависит от платформы и поддерживаемых технологий. В QML в первую очередь используется OpenGL и отрисовка производится средствами GPU. Но может переключаться на использование CPU и прог…
IP
May 29, 2020, 2:55 a.m.
Igor' Poroshin

QTablwView + QSqlQueryModel скрыть пустой столбец

Да, понятно. В данном случае лучше использовать серверную процедуру (если такие поддерживаются), в которой будет проверяться наличие всех пустых строк у нужного столбца и вызываться соответ…
RG
May 28, 2020, 7:21 p.m.
Rovshan Gurbanov

Сборка под старые версии Android

У меня SDK почти все версии есть, NDK есть версии 10, 17, 21. Но собирается приложение только с NDK v21 под Android версии 7.0 и выше Версия Qt у меня 5.14.2
About
Services
© EVILEG 2015-2020
Recommend hosting TIMEWEB