Django template design in OneToOneField and ManyToManyField

I am writing a movie about Seat Booking Django App, I can not conceive of a simple model.

First of all, here are my current models:

from django.db import models
from django.contrib.auth import get_user_model

class Seats(models.Model):
    seat_choice = (
        ('AA', 'AA'),
        ('AB', 'AB'),
        ('BA', 'BA'),
        ('BB', 'BB'),
        ('CA', 'CA'),
        ('CB', 'CB')
    name = models.CharField(choices=seat_choice, max_length=2)

    def __str__(self):

class Booking(models.Model):
    hall = models.OneToOneField(Seats)
    user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)

I wish that a user could buy / reserve one or more seats, but the same user or another user can not buy a seat already reserved by someone or by himself.

But the problem is that my current models do not work as I want …
Currently, it works as if a user bought a ticket, the same user could not buy the ticket that he had already bought! but the problem is, now another user can buy the ticket already booked by someone a and I do not want that at all.

I want that if a place has already been booked by someone, no one can book it later, but it can be canceled by the user who has reserved!

Can someone help me to achieve this?

custom publication types – Moving pages with a specific template to a new administrator menu

So, I build a website for a car dealership.

Currently, all pages are under the Pages tab in the admin.

One of the pages is called New Cars. This is the main page that lists all the child pages corresponding to each template.

I want to move the new cars to its own menu item in the administrator, then be able to display a list of its child pages and create new pages using the template for the child pages.

Is it possible?

Magento 2.3.2 Share Share module can not get an image in an email template

When I share the products of my wish list in my wish list with the list of friends, everything is ok, but the image can not be rendered in the image

I've used the default email template code for the same.
out HTML
{{var items | raw}}

php – displays the custom view of the plugin on the front end in the body of the template

I've searched on google but nothing. I create a custom plugin. The administration area is displayed without any problem. The problem is on the front end, I do not know what action or what filter I have to call. When I use add_filter ('template_include', 'myPublicFunction'), the view is displayed without the inside of the template body.

add_filter("template_include", "publicViewCall");

enter the description of the image here

I need to include the view inside the model body.
thanks any help is appreciated

magento2 – Magento 2: Replace a function of a template with a plugin

I want to replace a function (public function getName) from a template (Customer.php), a Google search engine, I have created a plugin, but it has not been displayed. You are wrong? Thank you

I want to replace this as below:
(Original file: supplier / magento / client-module / Template / Client.php)

public function getName()
        $name = '';

        if ($this->_config->getAttribute('customer', 'prefix')->getIsVisible() && $this->getPrefix()) {
            $name .= $this->getPrefix() . ' ';
        $name .= $this->getFirstname();
        if ($this->_config->getAttribute('customer', 'middlename')->getIsVisible() && $this->getMiddlename()) {
            $name .= ' ' . $this->getMiddlename();
        $name .= ' ' . $this->getLastname();
        if ($this->_config->getAttribute('customer', 'suffix')->getIsVisible() && $this->getSuffix()) {
            $name .= ' ' . $this->getSuffix();
        return $name;


public function getName()
        $name = '';

        if ($this->_config->getAttribute('customer', 'prefix')->getIsVisible() && $this->getPrefix()) {
            $name .= $this->getPrefix() . ' ';
        $name .= $this->getLastname();
        if ($this->_config->getAttribute('customer', 'middlename')->getIsVisible() && $this->getMiddlename()) {
            $name .= ' ' . $this->getMiddlename();
        $name .= ' ' . $this->getFirstname();
        if ($this->_config->getAttribute('customer', 'suffix')->getIsVisible() && $this->getSuffix()) {
            $name .= ' ' . $this->getSuffix();
        return $name;

1: registration.php

2: etc / module.xml


3: etc / di.xml


4: Plugin / Client / Model / Client.php

_config->getAttribute('customer', 'prefix')->getIsVisible() && $this->getPrefix()) {
            $name .= $this->getPrefix() . ' ';
        $name .= $this->getLastname();
        if ($this->_config->getAttribute('customer', 'middlename')->getIsVisible() && $this->getMiddlename()) {
            $name .= ' ' . $this->getMiddlename();
        $name .= ' ' . $this->getFirstname();
        if ($this->_config->getAttribute('customer', 'suffix')->getIsVisible() && $this->getSuffix()) {
            $name .= ' ' . $this->getSuffix();
        return $name;

Best WordPress template for this site?

Hi all
For a customer, we build a website on business definitions / terminology using WordPress.
(similar to sites like these

These definitions must be in a database (with a variety of different fields that we can later export and sort or use for analysis). Users who sign up as members can log in and submit / contribute their own definitions and administrator …

Best WordPress template for this site?

Python – Appropriate Design Template for Rules and Results Development

In the exercise I develop below, I apply the chain of responsibility model. The model works fine but I do not think it's the best approach. I think the rule design pattern should be a better fit, but there are not many good examples about it using python.

My questions for you are:

  1. Do you think that could be done with another motive?
  2. Is the chain of responsibility acceptable reason for this?
  3. Should I study the design of the rule (in other languages ​​if necessary) to apply it in python?

The exercise is as follows:

You have patients with health problems such as:

  1. F: fever
  2. H: healthy
  3. D: diabetes
  4. T: Tuberculosis

In this exercise, medications are provided to all patients. It is not possible to target a specific patient. Here is the list of available medications:

  1. Like: aspirin
  2. An antibiotic
  3. Insulin
  4. Paracetamol

Medications can change the states of patients. They can heal, cause side effects or even kill a patient if they are not properly prescribed. The effects of drugs are described by the following rules:

  1. Aspirin cures fever;
  2. An antibiotic cures tuberculosis;
  3. A sick patient who does not receive the right medication remains ill unless explicitly stated otherwise;
  4. Insulin prevents the diabetic subject from dying, does not cure diabetes;
  5. If insulin is mixed with an antibiotic, healthy people catch fever;
  6. Paracetamol cures fever;
  7. Paracetamol kills the subject if it is mixed with aspirin;


Parameter 1

List of patient health status codes, separated by a comma. for example. "D, F, F" means we have 3 patients, one with diabetes and two with fever.

Parameter 2

List of drug codes, separated by a comma, e.g. "As, I" means that patients will be treated with aspirin and insulin.


The result should be sent to stdout. It must be a comma-separated string with the number of patients in a given state, respecting the following format: F: NP, H: NP, D: NP, T: NP, X: NP (NP: number of people ).

WordPress single page template, custom message type, pagination order by title

It's been a while since I searched in QUITE, I'm looking for a method to page on a single page template, orderby title (the client likes sorting by first name of the team members)

I suppose this would include a way to compensate for pagination by the title or ?.

The following will be perfectly suitable by postal order and not by title.

') ?>
') ?>

How do you manually paginate / query against a custom article type, orderby => title, offset by the title of the article that fills the single page template? Thank you for any help.

multithreading – Asynchronous or multithreaded control lock template name

I have seen this model multiple times, both in asynchronous and multithreaded code. A counter is used to track asynchronous behavior or thread behavior – whenever a new action is started, the counter is incremented. When it is finished, the counter is decremented.

Meanwhile, another process can only be used if the counter is zero.

This is particularly useful for handling user actions that need to be resolved before moving to another workflow.

Is there a name for this lock pattern?

8 – How to programmatically get the picture style of an image in a paragraph template?

I have a twig extension that applies an image style to an image and provides a URL for the processed image. The extension looks like this:

protected function setImageStyleUrl($url_field_value, $image_style) {
  $url = ImageStyle::load($image_style)->buildUrl($url_field_value);
  return $url;

And I use it in the model this way:

{{}} Paragraph.field_image.alt

However, because the image style is hard-coded, I can not set it in the display settings (Structure> Paragraph Types> Manage Display).

Is it possible to programmatically get the image style of an image from the configuration settings instead of writing "500×200" in my example?
Or maybe another approach exists?

Important conditions:

  • I can not use Twig Tweak, Bamboo Tweak and other similar modules.
  • I can not use {{ content.field_image }} approach (although it works)