Advanced search

Django

Jan. 31, 2020, 3:50 a.m.

Model, Django, UserAdmin

A short note on how to fix the queryset administration form admin.ModelAdmin or UserAdmin . Actually, there is no difference, since the form UserAdmin is inherited from admin.ModelAdmin . Nevertheless, I will show UserAdmin as an example.

The task is as follows. The site has superusers and users from the administration. Superusers can see all users and edit as they like. And administration users can see all user records except superusers, and also can not appoint other users as superusers.

Django

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.

Django

Aug. 26, 2019, 3:51 a.m.

user, Django, Backend, Model

Imagine that for an authenticated user, when opening pages, some requests are constantly being executed, for example, an additional list of notifications is loaded, as well as his profile. And we use this information in templates, for example this way.

{% if user.is_authenticated %}
    {{ user.profile.avatar }}
    {{ user.notices.count }}
{% endif %}

Django

April 28, 2019, 9:36 a.m.

Django, Model, Reset

In the process of developing a project on Django, we may encounter an unpleasant situation when some packages and modules were removed and, accordingly, models from these packages were no longer used. But at the same time, squash of application migrations does not allow removing these packages, since migrations have many circular dependencies. As a result, removing unnecessary packages becomes a rather difficult task. Since resolving such dependencies becomes a non-trivial task. For me, such an unpleasant package was Django CKEditor, which was present almost everywhere. As a result, this package due to migrations remained for quite a long time in the list of requirements.txt, although in fact it was not used on the site at all.

Django

April 24, 2019, 3:42 a.m.

Django, Application, Model

I would like to share one of the possible way for moving the data model from one application to another.

Immediately, I note that this version of the data model transfer is not 100% working and you may need additional manual editing of the tables to correctly set the Content Type. Since any such modifications are fraught with data loss for GenericForeignKey relationships.

In my case, GenericForeignKey was not used, so there was no such problem.

Django

July 4, 2018, 2:38 a.m.

Search, QuerySet, Django, Model

In previous articles, we considered how to do a search on the site on the site. Namely:

But what if you have more than one type of content. You can have articles, comments, forum and messages on the forum. How then to be?

If you want to do everything yourself, without using third-party libraries, then you will need to do a search on all the necessary models and combine the result. I have done exactly the same on the site.

QML

Nov. 24, 2015, 9:11 a.m.

База данных, SQLite, Qt, QML, Android, DataBase, Model, View, MVC

A small example to work with the database in QML Qt. This lesson brings together information on the use of signals and slots in the Qt QML , access to C++ classes from QML layer implementation of the application interface on QML, as well as the implementation of the model/view for the database tables.

The database contains a table with a list of people, which has four columns:

  • id (INTEGER) - a unique record number;
  • FirstName (VARCHAR (255)) - First Name;
  • SurName (VARCHAR (255)) - Last Name;
  • Nik (VARCHAR (255)) - Nik name.

The application must implement removing and adding records to the database through the application interface. To add records to the database three fields for data entry will be used and a button that initiates the addition of data to an SQL database. Adding entries to the table through a wrapper class designed for this application is present in metodom.Takzhe ListModel class that implements the model of data representation for the information display in the TableView in QML layer.

QML

Nov. 9, 2015, 4:03 a.m.

ListView, ListModel, TextInput, Model, Delegate, QML, Qt, Android, View

Working with the ListView in QML is a fairly common aspect in the development of Android applications, since many applications have in their functional building lists of data, records, settings, etc. It is also true in developing a Desktop applications with QML principle would be the same for both platforms.

For its consideration of the transfer of information in the list offer carefully consider the following scenario of interaction with the ListView .

The principle of view data in the ListView

ListView object has two important properties:

  1. delegate - which determines the appearance of a single element ListView
  2. model - which placed the data of each element

The transmission model can be used ListModel object that contains the data for each item in the list. The data assigned to variables that have been assigned to certain properties of the objects in the delegate. In the figure below has two delegate objects Text, text properties which the variables text_first and text_second assigned. These variables determine which will be substituted data from each ListElement in ListModel . As can be seen from the figure, each ListElement has two properties, the name of which is identical to the variables that are assigned to the delegate. In fact, these variables are roles, which put a value of ListModel . So we get ListView with text fields, which are filled with the data that have been made in each ListElement in ListModel .

Donate

Hello, Dear Users of EVILEG!!!

If the site helped you, then support the development of the site financially, please.

You can do it by following ways:

Thank you, Evgenii Legotckoi

v
April 9, 2020, 5:41 a.m.
vitalisimys

Qt - Test 001. Signals and slots

  • Result:21points,
  • Rating points-10
v
April 9, 2020, 5:36 a.m.
vitalisimys

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

  • Result:40points,
  • Rating points-8
v
April 9, 2020, 5:32 a.m.
vitalisimys

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

  • Result:53points,
  • Rating points-4
Last comments
April 8, 2020, 9:12 a.m.
ogustbiller

Круто! Немного начинает проясняться что к чему. Спасибо.
K
April 7, 2020, 8:55 a.m.
KULINAR847

А вот уже и на python... #!/usr/bin/env python# -'''- coding: utf-8 -'''-import sysfrom PySide2.QtWidgets import *from PySide2.QtQuick import *from PySide2.QtCore import *from PySide2.…
April 3, 2020, 8:06 a.m.
Konstantin Grudnitskiy

Я надеюсь вы уже разобрались в чем дело, но если вдруг нет, то проблема состоит в том, что вы пытаетесь запустить программу из интерпретатора питона. Файл main.py это уже готова…
April 3, 2020, 6:18 a.m.
Konstantin Grudnitskiy

>>> text = 'hello world'>>> ' '.join(word for word in text.split()[:-1])'hello'>>> def remove_last_word(text):... return text and ' '.join(word for word in text.s…
March 27, 2020, 2:40 p.m.
Evgenij Legotskoj

Добрый день. В конце пятой статьи скачать можете.
Now discuss on the forum
DK
April 9, 2020, 3:31 a.m.
Dzhon Kofi

Привет. Делаю реализацию перемещения строк на QTableView с моделью QSqlTableModel. Буду в этой теме спрашивать нужное. Пока такой вопрос при создании модели: как мне узнать rowCount? int…
April 8, 2020, 5:42 p.m.
elyana

Подскажите как правильно реализовать... Нужно создать массив в C++ с переменными типа сhar или же int. В Qml будет переменная, например text, которая будет изменять своё значение в зависим…
DK
April 8, 2020, 6:29 a.m.
Dzhon Kofi

:-D блин, без слов, пойду пройдусь))
s
April 8, 2020, 4:59 a.m.
slava_d2000

Всем привет. Прошу помощи.есть статическая сборка 5.14.2 (без SSL) компилируется чистый шаблон на QML и Widgets если войти на компьютер в терминальной сессии и запустить программ…
s
April 6, 2020, 8:06 a.m.
shuric

Добрый день. Объясните пожалуйста ... ... допиливать стилевое оформление в прокси классе ... где именно копать ? В каком виртуальном методе лучше допиливать (если можно н…
EVILEG
About
Services
© EVILEG 2015-2019
Recommend hosting TIMEWEB