class Settings(models.Model):
    date_format = models.CharField('Date format', max_length=100)
    time_format = models.CharField('Time format', max_length=100) for saving the date and time format in database as boolean.

def date_format(request):

settings = Settings.objects.get(user=request.user)
settingsForm = SettingsForm(instance=settings)  
if request.method =='POST':     
    settingsForm = SettingsForm(request.POST,instance=settings)
    if (settingsForm.is_valid()):       
        return redirect('/member/follow-up/') 

return render_to_response( 'incident/date_format.html',
               'about_menu': True,


Date_Format = (
    ('0', ' dd / mm / yyyy'),
    ('1', 'mm / dd / yyyy'),

Time_Format = (
    ('0', ' 12 hour AM / PM '),
    ('1', ' 24 hour '),
class SettingsForm(forms.ModelForm):
    date_format = forms.ChoiceField(widget=forms.RadioSelect(), choices=Date_Format)
    time_format = forms.ChoiceField(widget=forms.RadioSelect(), choices=Time_Format)
    class Meta:
        model = Settings
        fields = ['date_format','time_format']

The above view code is to save selected format in database in Boolean format.

In settings page i am having date format like this ![like this][1] and time format is of following type![like this][2] .

So if the user select any one of these format in settings page and save it,saved format will be displayed in report creation page for report add/updation.

The concept is user is selecting the time format,depend on the format they selected the format should change in report creation page like this ![report creation page format][3]

I am searching this in google but no sucess.

I want to know is it possible in django. How to implement this in views.

I learning django so please help me in doing this.


Edited 3 Years Ago by Sivaram R

NSArray *dateFormats = [NSArray arrayWithObjects: @"dd/ mm / yyyy", @"mm / dd/ yyyy", nil];

NSString *selectedDateFormat = [dateFormats objectAtIndex:formatSelected];
This article has been dead for over six months. Start a new discussion instead.