You could make the date field "disabled":
https://docs.djangoproject.com/en/2.0/ref/forms/fields/#disabled
On Mon, Feb 19, 2018 at 08:37:40AM -0800, prince gosavi wrote:
> That did the job.But I would like to get rid of the 'Field' type view that
> surrounds the date. As I only want to display
Hi.
If you want to display only date why aren't you doing it in template rather
than trying to make form to just display value.
19.2.2018 18.38 "prince gosavi" kirjoitti:
> That did the job.But I would like to get rid of the 'Field' type view that
> surrounds the
That did the job.But I would like to get rid of the 'Field' type view that
surrounds the date. As I only want to display the date.
Is there a way to do it in the form itself or any way to change it in the
templates?
On Monday, February 19, 2018 at 7:52:05 PM UTC+5:30, prince gosavi wrote:
>
>
i think you need to replace:
form = UserQueryForm()
with
form = UserQueryForm(initial={'date': date})
See: https://docs.djangoproject.com/en/2.0/ref/forms/api/
Etienne
Le 2018-02-19 à 10:31, prince gosavi a écrit :
|
# my_app/views.py
fromdjango.shortcuts importrender,get_object_or_404
#
# my_app/views.py
from django.shortcuts import render, get_object_or_404
# Create your views here.
from .models import User
from .forms import UserQueryForm
def home(request): # home page
a_list = User.objects.filter()
for item in a_list:
context = {'username':
How does your view looks like?
Etienne
Le 2018-02-19 à 09:18, prince gosavi a écrit :
Hi,
I am building a simple django application for user feedback. And I
have created a form for that purpose.
Here is the snippet:
|
# my_app/forms.py
fromdjango importforms
importdatetime
Hi,
I am building a simple django application for user feedback. And I have
created a form for that purpose.
Here is the snippet:
# my_app/forms.py
from django import forms
import datetime
class UserQueryForm(forms.Form):
date = forms.DateField(initial=datetime.date.today) # need help
7 matches
Mail list logo