python - how to transfer the date in view? -



python - how to transfer the date in view? -

please help solve problem. model:

class diary(models.model): ......................... date = models.datefield( 'Дата записи', blank=true, null=true, ) last_edit_date = models.datetimefield( 'Дата последнего редактирования', auto_now=true, ) @classmethod def get_entry_public(self, id_record): homecoming self.objects.get(id=id_record, is_active=true, is_delete=false)

view:

def record(request, id_record): entry = diary.get_entry_public(id_record=id_record) print(entry.date) print(entry.last_edit_date) homecoming httpresponse(....)

i'm trying pass value of field

last_edit_date

in view. but

print(entry.last_edit_date)

outputs

none

db

entry = diary.objects.get(pk=id_record)

get_entry_public method of info record, not info table

update (thanks cesar)

entry = diary.objects.get(pk=id_record, is_active=true, is_delete=false)

you can utilize code in view, or can extend diary manager it, in diary class methods in 1 diary record

python django

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -