Advanced search
NomadDec. 26, 2020, 3:22 p.m.

DjangoДжанго модели

django, Model, user, Foreignkey

Всем привет.

Увожаемые коллеги, прошу поделится идейками для следуешей ситуации:

представим себе джанго приложение в которй есть модель project, подвязанная к пользователям НО в данной модели есть 2 поля связанных в пользователем:

****
project_lead      = models.ForeignKey(User,…
NomadNov. 7, 2020, 10:04 a.m.

DjangoОтображение моделй в админке Django

django, Model, adminmodel

всем привет

помогите пожалуйста разобраться в следующем:

во первых речь идет о задаче на стороне стандартной джанговкой админки.

предположим есть три модели:

class M1(models.Model):
    title = ...

class M2(models.Model):
    m1 = ForeignKey(m1)
    name = ...

class M3(m…
M
MarkGlenJuly 27, 2020, 7:35 a.m.

QMLFlow QML Type: связь с моделью, динамическое добавление и удаление элементов

views, QML, View, flow, view, model, qml, вёрстка qml, Model

Надо: подтягивать из с++ список слов, делать из них кнопки. Ширина кнопок соответствует ширине текста. При заполнении одной строки (ряда) - переход на следующую.

С передачей данных из с++, сигналами и слотами, вроде пока понятно. На данный момент затруднения с вёрсткой. ListView и GridVi…

Evgenij LegotskojApril 26, 2020, 3:08 p.m.

DjangoDjango - Tutorial 052. Redefining a User Model

Python, QuerySet, django, Model

There are various options for working with a user model for creating a user profile and adding some specific information, for example, a profile photo. One way is to add a profile model with the OneToOneField field for the user. This option is simpler than a proxy model or overriding a user model. But for me personally, redefinition of the user model turned out to be more effective in terms of organizing code and writing various methods that allow you to extract the necessary information from the user object in templates without resorting to writing template tags.

Therefore, let's consider exactly the option of redefining the user model in a project in Django

Evgenij LegotskojJan. 31, 2020, 3:50 a.m.

DjangoDjango - Tutorial 051. How to change queryset and editing ability in ModelAdmin depending on the user

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.

Evgenij LegotskojNov. 22, 2019, 2:03 a.m.

DjangoDjango - Tutorial 050. Creating Dynamic Site Settings Using SingletonModel

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.

Evgenij LegotskojAug. 26, 2019, 3:51 a.m.

DjangoDjango - Tutorial 047. How to do select_related and prefetch_related for an authenticated user

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 %}
Evgenij LegotskojApril 28, 2019, 9:36 a.m.

DjangoDjango - Tutorial 046. Reset migrations in the project

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.

Evgenij LegotskojApril 24, 2019, 3:42 a.m.

DjangoDjango - Tutorial 045. How to move model from one application to another

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.

Evgenij LegotskojJuly 4, 2018, 2:38 a.m.

DjangoDjango - Tutorial 034. How to do a search on several data models

Search, Model, QuerySet, Django

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.

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
NI

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

  • Result:90points,
  • Rating points8
NI

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

  • Result:92points,
  • Rating points8
NI

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

  • Result:80points,
  • Rating points4
Last comments
D

Django - Tutorial 001. Deploying a site on Django + PostgreSQL + Gunicorn + Nginx

А почему нельзя? Где можно об этом почитать? Киньте, пожалуйста, в меня ссылкой.
D

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

Огромное спасибо вам за статью! Для меня стали открытием select_related и prefetch_related
t
  • t1m4
  • Feb. 24, 2021, 2:56 a.m.

Django - Tutorial 052. Redefining a User Model

В данном случае я заходил под superuser но все равно не появлялись эти поля

Django - Tutorial 001. Deploying a site on Django + PostgreSQL + Gunicorn + Nginx

Поднял сервис с помощью systemd, вот по этому мануалу: https://habr.com/ru/post/501414/
t
  • t1m4
  • Feb. 23, 2021, 7:11 a.m.

Django - Tutorial 052. Redefining a User Model

А как дать ему эти права?
Now discuss on the forum
S

Помощь в проекте qt, qml

Доброго времени суток! Хотелось бы получить консультативную помощь по проекту, т.к. имеются определенные затыки, которые своими силами преодолеть не получается. За труды по наущению меня ум…

Добавление данных в модель из textEdit

ознакомьтесь с этим и этим для понимания принципов работы с моделями, и поймете что у вас не так
  • BlinCT
  • March 6, 2021, 10:57 a.m.

Работа с QJsonObject и получение данных из него

Вопрос решен. Оказалось что я не очень внимательно прочитал описание метода root.take("devices") Оказывается он удаляте ключ, а занчит и все данные по нему. И по этому после этого…

Как совместить таблицу и дерево в Qt

Добрый день. Имеется таблица QTableView, нужно у некоторых строк сделать возможность раскрытий, как в QTreeVidget и отоборажать в них аналогичные строки. Скажите пожалуйста, как это мо…
KM

не получаеться добавить списки в списокб ошибка в петле

решение: с line 99: listy = [] lista = [] for single_lp in max_list_from_all_plates: suma = 0 lists = [] for sign in single_lp: Highest_score=0 bigl…
About
Services
© EVILEG 2015-2020
Recommend hosting TIMEWEB