I
I
IgnoreGTO2021-02-02 08:06:08
Django
IgnoreGTO, 2021-02-02 08:06:08

Is it possible to add a save action in the Django Admin Panel when SAVE is clicked?

6018db9a351e0238839237.png

models.py

class Ptickname(models.Model):
    date = models.DateTimeField(default=datetime.now)
    street = models.CharField(blank=True, max_length=100, null=True, verbose_name="Улица")
    status = models.ForeignKey(Status, null=True, on_delete=models.SET_NULL, verbose_name="Статус", default=1)
    view = models.ForeignKey(ViewTicket, null=True, on_delete=models.SET_NULL, verbose_name="Вид заявки", default=1)
    comment_author = models.TextField(blank=True, null=True, verbose_name="Комментарий автора")
    comment_ingeneer = models.TextField(verbose_name="Комментарий", null=True, blank=True, )

    def __str__(self):
        return self.street

    class Meta:
        verbose_name = 'Тикет'
        verbose_name_plural = 'Тикеты'


class Ticket(models.Model):
    street = models.ForeignKey(Ptickname, null=True, on_delete=models.SET_NULL, verbose_name="Выберите имя петиции",
                               related_name='posts', default=1)
    home = models.CharField(max_length=150, verbose_name="Дом")
    kv = models.CharField(max_length=150, blank=True, verbose_name="Квартира")
    phone = models.CharField(max_length=150, verbose_name="Контакт")
    is_organization = models.BooleanField(verbose_name="Организатор")

    def __str__(self):
        return '{}-{}-{}'.format(self.street, self.home, self.kv)

    class Meta:
        verbose_name = 'Адреса петиции'
        verbose_name_plural = 'Адреса петиций'


admin.py
admin.site.register(Ticket)


class TicketInline(admin.TabularInline):
    model = Ticket
    extra = 5


class PtickAdmin(admin.ModelAdmin):
    inlines = [
        TicketInline,
    ]


admin.site.register(Ptickname, PtickAdmin)


How can I save another when I click and perform an action
request.POST.get('send'):
                        HttpResponse(do_send_r(request.GET))

More precisely ( do_send_r )
Please explain a little more clearly, I'm just starting to dive into python and django.
If possible with an example.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-02-02
@bacon

https://docs.djangoproject.com/en/3.1/ref/contrib/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question