How to show shamsi date in django? - django

I'm trying to make django's default 'DateTimeField' to show Shamsi (Persian) calendar, but I have no idea of how to do it. Is there any way to make this type of field use Shamsi completely or use it as it is and just converting to Shamsi when showing on the template?

Maybe it's too late but you can use jalai-date

I had this problem and solved it by just adding a textfield for shamsi date and converting the date manually each time. It't not the best way but it gets the job done!

Related

Flask WTF SelectField with custom entry?

I want to create a SelectField that offers suggestions but still allow the user to enter something else.
class MyForm(Form):
username = wtf.StringField()
title = wtf.SelectField('Job title', choices=['Owner', 'Manager'], validate_choices=False)
WTF documentation suggests that setting validate_choices to False allows this:
Note the validate_choice parameter - by setting this to False we are telling the SelectField to skip the choice validation step and instead to accept any inputted choice without checking to see if it was one of the given choices.
But, no data entry or modification is possible with above. Is this possible or do I need another 'manual entry' field?
Or, is there perhaps a way to show my suggestions in a StringField using JS similar to the way the browsers offer autocomplete suggestions for addresses etc?
I'm not aware of any way to do this. It seems you and I are in a similar position. However, I did have an idea I wanted to share that could work for you.
Many forms will have a dropdown with a value "Other" and if you select "Other" there is another empty box that appears for you to type in. You could implement this pretty easily in wtforms. Alternatively you could have the extra box always display and just do a check that they did indeed select "Other" if they have a custom input.
I have opened an issue, but they are not planning to add this feature.
Based on this, we could, but it is not a pure python implementation

How can I implement 'select all' button in Django?

I'd like to implement select all button (e.g select all and deleting) in Django 1.9.7 but I can't find any post about it in Google Since, I'm not a non-native-english person, I'm not good at googling in correct english. Could anybody give me advices or keywords so that I can googling based on it?
Well this depends on how you implemented your table with Django. Putting javascript/bootstrap/etc aside, there are some samples on how you can implement select all in javascript. Like this.
Deleting those items requires defining a form and processing it's data in the serverside and deleting your model items. This also depends on how you are passing data between your view and your model.

django - best way to get a datetime object from separate date and time picker jquery tools on a template?

Is the best way to make a datetime object from separate date and time inputs on a template to use datetime.combine(date object, time object) in the view? I've been spinning my wheels a bit on this one and help is appreciated.
Thanks!
Take a look at the forms.SplitDateTimeWidget()

Custom Field Type or Logic in the View?

Before I start on this project I want make sure what I am proposing is feasible. There is an unusual requirements I have to satisfy.
The model and formModel fields have to support a comment field on every field. I would like to be able to access them by object.field and object.field.comment. At first glance, this looks like I should have a separate type of comment and then somehow link it to correct field but is there a way to create a custom modelField that stores data in more then one database field from one or more form inputs? I would think there would have to be a custom widget to support this too?
If anyone has any ideas or examples of anything like this please respond.
I think this is the answer to my question. I have not tried it yet, but from the description it looks like what I need. https://docs.djangoproject.com/en/dev/ref/forms/widgets/#multiwidget

Django Event Calendar

Hi
I am using an Event Calendar wirtten in Django http://www.3captus.com/download/django_calendar and it is working great expect the time format is showing up wrong. Instead of showing "12:00:00" it is showing "noon" instead, can someone figure out what is wrong.
If you are talking about the formatting of a date in your templates then you can adjust the format easily with the builtin date filter.
Make sure to also check your TIME_FORMAT setting.