G
G
Grigory Dikiy2017-10-12 13:09:43
Django
Grigory Dikiy, 2017-10-12 13:09:43

Django Admin not passing POST request?

Good afternoon! I can't save data through the admin panel in any way.
There is a model:

class Product(CreationModificationDateMixin, MetaTagsMixin, ImageThumbnailMixin):
    category = TreeForeignKey(
        Category,
        verbose_name='Категория'
    )

    name = models.CharField(
        'Имя',
        max_length=150,
        db_index=True
    )

    slug = models.SlugField(
        'Название в URL',
        max_length=200
    )

    articul = models.CharField(
        'Артикул',
        max_length=6,
        unique=True
    )

    price = models.PositiveIntegerField(
        'Цена'
    )

    stock = models.PositiveIntegerField(
        'На складе',
        default=0
    )

    discount = models.PositiveIntegerField(
        'Скидка',
        default=0,
        help_text='Скидка указывается в процентах'
    )

    in_discount = models.BooleanField(
        'Учавствует в распродаже ?',
        default=False
    )

    brand = models.ForeignKey(
        Brand,
        null=True,
        blank=True,
        related_name='products',
        verbose_name='Производитель'
    )

    __original_name = None

    # Managers
    objects = models.Manager()
    with_image = WithImageManager()

    def __init__(self, *args, **kwargs):
        super(Product, self).__init__(*args, **kwargs)
        self.__original_name = self.name

    def get_absolute_url(self):
        return reverse('products:detail', kwargs={'slug': self.slug, 'id': self.id})

    def get_price(self):
        return self.price - int(self.price * (self.discount / 100))

    def save(self, *args, **kwargs):
        sync = None

        if kwargs.get('sync'):
            sync = kwargs.pop('sync')

        if not sync:
            for fc in FilterCategory.objects.filter(categories=self.category):
                pf = ProductFilter.objects.filter(filter_category=fc, product=self)

                if not pf:
                    pf = ProductFilter(filter_category=fc, product=self)
                    pf.save()

            # Overwrite Slug If Changed Name
            if self.__original_name != self.name:
                self.slug = slugify(unidecode(self.name))

        super(Product, self).save(*args, **kwargs)
        self.__original_name = self.name

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = 'Товар'
        verbose_name_plural = 'Товары'
        ordering = ['price', '-id']

Sometimes items are added, sometimes not. I don't understand the dependency.
Tried on Django 1.11.4 and 1.11.6
When I press the save button, the data just hangs on the client and no request is made. That is, there is no POST request as such, and the site itself endlessly executes js, that is, it cannot transmit the request. Why xs.
Data of this type:
59df3f3e98225258366521.png
I just press the save button and that's it.
It is also strange that this problem is observed only in this model.
Put a global listner on click and got that endpoint call
59df46c07c4d7508167529.png
before it was handled by Jquery

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Dikiy, 2017-10-12
@frilix

The site was using celery, but the module wasn't enabled during testing. The problem was that the request was not recorded anywhere

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question