Jan. 5, 2018, 7:11 a.m.

Django

Ubuntu, Django, VDS

With the growth of site functionality, as well as attendance, it was possible to successfully test the capabilities of the current VDS server, which I currently use. I would like to describe my experience with VDS, as well as show how much this VDS keeps under certain conditions and sizes of the project.

I decided to tell about it right now, because a week ago I expanded the server's capacity by purchasing additional memory.

All the further narrative will be subjective, but I hope that it will make it possible to make a general picture, so that newcomers will be able to navigate in what server they need for their needs, and this will facilitate the choice of the server.

Server Configuration

Initially, the site worked on the minimum configuration that I managed to take. The fare is $5 per month. By the way, my ISP also has a cheaper tariff (190 rubles / month), but it is fixed, whereas my current tariff allows me to configure the configuration necessary for me and increase the server's capacity to one that is not available at fixed tariffs.

Configuration:

  1. Processor cores: 2 x 2,7 GHz
  2. RAM: 512 Mb
  3. SSD: 5Gb
  4. OS: Ubuntu 16.04
  5. Access to the Internet: 100 Mbit/s

All configuration of the server was done exclusively through the console, without any auxiliary tools like ISP Manager, which also absorbs some of the RAM, so this modest RAM was enough for me for a long time

Dec. 30, 2017, 3:50 p.m.

Django

чат, message, Django, chat, сообщение

According to the tradition, I will tell you about my experiences on the introduction of new functionality on the site. At the moment, this functionality is a personal message between users. Of course, this now does not work as well as in well-known social networks ... but in the end everything will work. The main feedback on the forum, please.

So. I really wanted to add personal messages on the site, especially since I already mentioned this six months ago. The question remained, how to do it. When searching on the Internet it was possible to stumble upon an option when the following data model is being formed.

  • Id of the message
  • from_user - sender
  • to_user - recipient
  • pub_date - the date of the message
  • message - message content

Tried to implement this option, but I was stopped by the fact that suddenly after personal messages I want to make chats? So why not immediately lay the foundation for chats?

Dec. 4, 2017, 8:41 p.m.

Django

Releases, Django

Команда Django анонсировала выпуск Django 2.0

Этот выпуск начинается с использования в Django свободной формы семантического управления версиями, но нет существенных изменений в обратной совместимости (за исключением того, что был удалён Python 2.7), что было ожидаемым в выпуске 2.0. Обновление должно быть таким же, как и для предыдущих выпусков.

Примечания к выпуску

Совместимость с Python

Django 2.0 поддерживает следующие версии Python: 3.4, 3.5 и 3.6. Разработчики Django настоятельно рекомендуют именно эти версии и официально поддерживают только последнии версии данных версионных серий Python.

Django 1.11.x является последней версией, которая поддерживает Python 2.7

Django 2.0 станет последней версией с поддержкой Python 3.4. Если вы планируете развертывание Python 3.4 до конца срока службы для Django 2.0 (апрель 2019 года), то используйте Django 1.11 LTS (поддерживаемый до апреля 2020 года). Обратите внимание, однако, что конец поддержки Python 3.4 - конец марта 2019 года.

Поддержка третьесторонних библиотек для старых версий Django

После выпуска Django 2.0 Разработчики предлагают сторонним разработчикам приложений отказаться от поддержки всех версий Django до 1.11. В тоже время разработчики должны иметь возможность запускать тесты своего пакета с помощью python -Wd , чтобы отображались предупреждения об ошибках. После внесения исправлений для предупреждения об ошибке приложение должно быть совместимо с Django 2.0.

Nov. 27, 2017, 8:03 p.m.
Ambient

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

Изучаю, как написать сайт на Django. Пытаюсь настроить CKEditor, чтобы стиль оформления контента редактора был такой же, как и стиль оформления сайта. Заметил, что у вас пользователи могут писать свои статьи и там используется CKEditor.  А в нём такое же оформление контента, как и на сайте.
Можете подсказать, как сделать также?
Nov. 10, 2017, 7:43 a.m.

Django

Django, ckeditor

In most of the site I use a self-written WYSIWYG editor, so it's not as advanced as I'd like. But for writing articles on the site, CKEditor is used, a very powerful and good editor. Nuance is that writing articles is available for all registered users of the site. But by default CKEditor allows you to upload images only to users with the status of staff.

For all other users, either an error page or the main page of the site will open instead of a file manager to search for images or the downloaded image.

A little polished the documentation, I managed to fix this problem. And to be honest, the solution looks rather strange, although it is proposed in the official documentation for the editor.

June 23, 2017, 8:12 a.m.

Django

Battery, tagging, Framework, Django, ckeditor, REST, django-bootstrap3

The convenience of developing on Django is not only that it is already a developed Framework with rich functionality, but also the availability of a large number of high-quality batteries (packages) that implement the necessary functionality that it would be quite difficult to write independently, especially if you are developing Site alone.

In the process of more than half a year's development of the site on the COM domain, it was just such a package that greatly facilitates life and accelerates the development:

  1. django-ckeditor
  2. django-autocomplete-light
  3. django-tagging
  4. django-bootstrap3
  5. django-modeltranslation
  6. django-daterange-filter
  7. django-phonenumber-field
  8. django-rest-framework
June 4, 2017, 8:52 a.m.

PostgreSQL

PostgreSQL, Django, LATIN1, UTF8

On the site there was one bug that manifested itself when trying to attach to files messages whose names were in Cyrillic. In this case, the site issued error 503. This occurred despite the fact that the database was encoded in UTF8, after correcting the encoding of the database itself in the previous article . While Django issued the following message:

'latin-1' codec can't encode characters in position 55-64: ordinal not in range(256)

The problem was that the server's coding was initially set to LATIN1. That is, the following commands gave the following conclusion:

postgres=# show server_encoding;
 server_encoding 
-----------------
 LATIN1
(1 row)

postgres=# show client_encoding;
 client_encoding 
-----------------
 LATIN1
(1 row)

postgres=# \encoding 
 LATIN1

Executing the command SET CLIENT_ENCODING TO 'utf 8'; did not work, after exiting psql, the encoding was returned to LATIN1 .

May 10, 2017, 4:38 p.m.

Django

AJAX, Django, Polling

Frequent surveys with AJAX allow you to establish a permanent connection between the browser and the server in order to update any data, for example, whether there are new notifications on the site for the user. For example, I organized a small system of notifications for registered users, which allows them to find out at the entrance to the site if there were answers in the articles and forum questions to which they are subscribed, and whether there were new articles and questions on the forum, to sections of which users were also signed.

The notifications are as follows:

April 30, 2017, 4:17 p.m.

Django

Like, Django, GenericRelation, Dislike, GenericForeignKey

In the article on creating a system of bookmarks on Django, an example was considered with the use of an abstract model for several types of bookmarks, namely for articles and comments on articles. Attention was also drawn to the fact that the model fields that had foreign keys to different models should have the same names to support the possibility of creating a single interface for adding bookmarks. This is made possible by the so-called "duck typing", which implies that objects that do not have a single inheritance hierarchy can be used in the same scenario if there are interfaces (methods) that have the same signature.

Literally the principle of duck typing sounds like this:

If it looks like a duck, swims like a duck and quacks like a duck, then it probably is a duck.

That is, having methods with the same signature, we can use objects that are not associated with an inheritance hierarchy, in the same context.

In the same article, let's consider the variant when using the Like Dislike system, not two different tables for articles and comments are used, and not even one that will contain a foreign key for an article or comment (that is, two columns, One of the columns, depending on what type of content the user activity is related to), and one table that will contain:

  • content_type - The content type to which the record belongs
  • object_id - Record ID
    • content_object - The generated foreign key to write, in fact the content object
  • Other additional fields
April 8, 2017, 11:52 a.m.

Django

bookmark, AJAX, favorite, Django, jQuery

The site has the ability to mark articles, comments, topics and answers on the forum as favorites. However, marking as favorites does not provide a reload of the page, because for these actions the mechanism of AJAX-requests is used.

In order to implement the bookmark system, you need:

  • Add a table that implements the Many-to-Many relationship between the user and the article or comment.
  • Add a view that will handle this request.
  • Add url to handle the request to add or exclude an object from the favorites.
  • Write the html-code, which will be responsible for displaying the counter added to the bookmark.
  • Add a javascript handler that will call the AJAX request.

On this site, the icon of the star from Bootstrap is used as a counter icon.

m
May 19, 2019, 1:49 a.m.
mahhaki

Qt - Test 001. Signals and slots

  • Result:78points,
  • Rating points2
S
May 17, 2019, 1:14 p.m.
SunBro

Qt - Test 001. Signals and slots

  • Result:42points,
  • Rating points-8
b
May 17, 2019, 4:18 a.m.
banana

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

  • Result:57points,
  • Rating points-2
Last comments
May 21, 2019, 8:10 p.m.
Дмитрий

Приветствую! Я думаю дойдёт и до этого, но пока изучать его у меня нет желания.
May 20, 2019, 7:20 p.m.
Евгений Легоцкой

Добрый день! Вы не думали разместить репозиторий проекта на GitHub?
P.
May 18, 2019, 2:03 p.m.
PELMYACH .

Спасибо большое! Вскоре буду разбираться!
May 18, 2019, 9:13 a.m.
Евгений Легоцкой

Добрый день! Отнимать значение общего счётчика можно в деструкторе класса кнопки QDynamicButton::~QDynamicButton(){ ResID--;} При этом я бы ещё переустанавливал значения вс...
P.
May 14, 2019, 10:33 p.m.
PELMYACH .

Здравствуйте!А не подскажите, как можно при удалении какой либо кнопки, у щётчика отнять значение?Дабы например четвёртой кнопке соответствовал ID 4, а не 5 скажем
Now discuss on the forum
May 24, 2019, 6:48 a.m.
Евгений Легоцкой

Если там будут только перечисления внутри namespace, то жа, достаточно будет заголовочного файла
May 24, 2019, 6:28 a.m.
Андрей Янкович

работает любой http сервер, и можно использовать обсалютно любой портпример <RemoteRepositories> <Repository> <Url>http://178.124.160.6:3030/A/B&l...;
May 23, 2019, 2:40 p.m.
Михаиллл

Попробовал сделать этот запрос по http и получил json файл. request.setUrl(QUrl("https://jsonplaceholder.typicode.com/todos/1")); Как Вы думаете, почему https не работает и как это и...
May 23, 2019, 10:42 a.m.
Михаиллл

Спасибо, помогло.
May 23, 2019, 6:31 a.m.
Евгений Легоцкой

Для задач и граф-то не нужен. Достаточно будет таблицы в локальной базе данных SQLite, в которой указывается задача, время и т.д. В этом разделе есть примеры по работа с базой д...

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

EVILEG
About
Services
Join us
© EVILEG 2015-2019
Recommend hosting TIMEWEB