Sunday, November 27, 2016

Re: DateTimeField Outside Admin

Its simple. In your view in your context dictionary create a variable for date. Import timezone and date = timezone.now(). You can declared "date" like {{ date }} in any of your template and you will get date coming up.

On Sun, Nov 27, 2016 at 8:50 AM, Elias Coutinho <coutinho.elias@gmail.com> wrote:



Good afternoon people,

I would like to display my date field outside the admin in the same way it displays, ie an option for date and another for time, as in the figure below.







I looked in the documentation but I did not understand much, I searched the webmas not found anything without using other libraries.

A friend sent a tip and also did not work because it presents the error:

'Str' object has no attribute 'input_formats'

Finally I found an ancient good:

Open on page 198 onwards.

But even so he does not even carry the field.

Can someone show me an example of how I would do this?

If possible post as would be the model, the form and the hrml.

Thank you.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/47f0afd0-c988-4924-9c37-a9c4254f969b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANoUts5rctEkp%3D7qrCLNwPhK5ftbYH8bXv4JP-8PP8HMSv8z0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment