Answer the question
In order to leave comments, you need to log in
Is it possible to add a save action in the Django Admin Panel when SAVE is clicked?
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.site.register(Ticket)
class TicketInline(admin.TabularInline):
model = Ticket
extra = 5
class PtickAdmin(admin.ModelAdmin):
inlines = [
TicketInline,
]
admin.site.register(Ptickname, PtickAdmin)
request.POST.get('send'):
HttpResponse(do_send_r(request.GET))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question