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

DjangoCount user objects e.g posts

python, Django

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…
Evgenij LegotskojNov. 22, 2019, 2:03 a.m.

DjangoDjango - Tutorial 050. Creating Dynamic Site Settings Using SingletonModel

SingletonModel, Model, Django, singleton

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
Maciej UrmańskiNov. 3, 2019, 5:20 a.m.

DjangoDjango letter avatar like this on evileg

python, Django, django

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? :)

Evgenij LegotskojNov. 3, 2019, 4:03 a.m.

DjangoEVILEG-CORE. Caching properties of model objects using model_cached_property

EVILEG, ESNF-C, model_cached_property, Django

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
Maciej UrmańskiNov. 2, 2019, 3:22 p.m.

DjangoDjango follow unfollow

Django, django, python

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 %}
<…
Evgenij LegotskojOct. 27, 2019, 4:55 a.m.

EVILEGRelease EVILEG-CORE 0.0.5

Django, Releases, Python, EVILEG, ECNF-C

Introducing the new release of EVILEG-CORE 0.0.5.

Evgenij LegotskojOct. 22, 2019, 1:39 a.m.

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

Django, django-silk, performance

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.

Ruslan VolshebnikOct. 16, 2019, 11:07 a.m.

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

Django, Telegram, Bot, celery

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

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

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

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

QT, QNetworkAccessManager, Django

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

Evgenij LegotskojSept. 2, 2019, 7:31 a.m.

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

Backend, Auth, Python, Django

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.

Card image cap
Pulsum Via

Project for travelers from EVILEG.

Go
Fornex

Let me recommend you a great European Fornex hosting.

Fornex has proven itself to be a stable host over the years.

For Django projects I recommend VPS hosting

Following the link you will receive a 5% discount on shared hosting services, dedicated servers, VPS and VPN

View Hosting
Share on social networks
Donate

The EVILEG project has switched to a non-commercial basis and will develop solely on the enthusiasm of the site creator, the enthusiasm of users, donations and the hosting referral system

Thank you for your support

Available ways to support the project

PayPal

PatreonYandex.MoneyMore

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

  • Result:80points,
  • Rating points4

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

  • Result:66points,
  • Rating points-1
GR

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

  • Result:90points,
  • Rating points8
Last comments

Qt/C++ - Lesson 061. Adding images to the application using the Drag And Drop method from the file manager

Доброго времени суток. А если нужно и изображение и текст? Что-то потерялся немного.... // Вместо отрисовки иконки и текста будем отрисовывать только одно изображение // с н…
AS

Qt/C++ - Lesson 004. QSqlTableModel – How to present the table from database?

error insert into TableExample " Количество параметров не совпадает" Я путь свой прописывала и даже бд удаляла, чтобы заново сделать, не работает. (всё остальное как у вас... Вроде ка…
i

Qt/C++ - Lesson 042. PopUp notification in the Gnome style using Qt

cialis powder comprare cialis online
LD

GameDev on Qt - Tutorial 1. Track mouse movement in QGraphicsScene

Вполне возможно, что ты не закинул graphicsView в дизайнере в виджет
LD

GameDev on Qt - Tutorial 1. Track mouse movement in QGraphicsScene

Кому интересно, поворот в slotTarget можно в одну строку организовать this->setRotation(90 + rotation() + qRadiansToDegrees(qAtan2(mapFromScene(point).y(), mapFromScene(point).x())));
Now discuss on the forum
M

Sorting the added QML elements in the ListModel

legal online pharmacy
  • Nomad
  • July 30, 2022, 5:42 a.m.

Как работать с HTMX?

Приветствую колеги. На днях наткнулся на вот это : https://htmx.org/ На офф сайте написанно вот такая фраза: htmx gives you access to AJAX, CSS Transitions, We…
h
  • harisr
  • July 25, 2022, 2:56 a.m.

QT - Native App Integration

Привет, у нас уже есть собственное приложение для Android. Можем ли мы интегрировать пользовательское представление QT в приложение со всем приложением QT внутри представления. Если да, ука…

Правильный запуск сервера на vps - Django

О я как то себе дома локальный сервер создавал. Вам же нужно просто сделать ручками конфигурацию системы. Настроить Nginx ну либо Apache (тут кому что нравится). Соответственно БД и всё остально…
o

Распознание объектов

Я к тому, что, возможно, софт уже есть.
About
Services
© EVILEG 2015-2022
Recommend hosting TIMEWEB