Questions tagged [django-crispy-forms]

1

votes
1

answer
7

Views

Crispy_forms_tags not fill form with instance in my update view

My problem about Update View On my UpdateView when I use {{form.as_p}} , Its work. But when I use {% load crispy_forms_tags %} Form not fill with instance. My View.py; def ayarlar (request): userinstance=get_object_or_404(kullaniciBilgileri,id=1) form = KullaniciForm(request.POST or None, instance...
Dany
1

votes
0

answer
133

Views

How to limit the selectable date range on UI for Crispy Form - forms.DateField?

In my form declaration, I have this field: effective_date = forms.DateField(required=False, label='Effective Date', widget=forms.TextInput(attrs={'class': 'datepicker'})) I want to limit the selectable date range on the datepicker to be [today - 30, today]. Is there a way to do it in Django crispy...
Dio Phung
1

votes
1

answer
277

Views

django-crispy-forms: Change name of input

I am running into some minor problems with django-crispy-form. I currently have a form, which successfully displays all fields from my model. However, I would like to change the html-attribute name to something else. I realize this might be difficult, since django-crispy-forms probably expects the n...
Runar
1

votes
1

answer
146

Views

Make 'Enter' key default to a certain button in a Django crispy form?

I have a form that subclasses PhoneNumberForm from the django-two-factor-auth-library. It renders a text box in which to enter phone number, and a Back button and Next button beneath it. The issue is that when the form is filled out and the user hits the 'Enter' key on their keyboard, the Back butto...
P.V.
1

votes
1

answer
71

Views

What does “{{ form|crispy}}” mean?

I am doing exercises in a django tutorials book, and when using crispy forms the line {{ form|crispy}} is used. The author does not explain it as I assume it must be commonly understood. I have never seen this notation used (I am new to this) and I would like to understand it. Thanks!
Al T
1

votes
0

answer
78

Views

Django formset view in template in reverse order

I am using modelformset_factory and view formset data in template. If you look at below image the template is showing data in 1st image. But i want to view the formset in reverse order like in 2nd image. First i will have new data enter textbox. Then the old data will be listed in reverse order like...
ivbtar
1

votes
1

answer
61

Views

Set template and wrapper_class parameters and render single form field not form

Related Q&A. You can consider this question follow up of it My form class is: class RoomForm(ModelForm): room_in_type = forms.ChoiceField(choices = [(elem[0], elem[1]) for elem in filter(lambda x: x[2] == False, memcache.Client().get('room_in_type_choices'))], widget=forms.RadioSelect()) class...
asdf_enel_hak
1

votes
0

answer
32

Views

How to implement a DateField into a custom user model's registration form using UserCreationForm in Django?

I have a registration form set up which worked, then I tried adding a date of birth field to the user model and add that to the registration form. The DateField appears on the registration form however whenever I submit the data to register a new user, I get the error message 'Enter a valid date' (s...
Terminal Guy
1

votes
1

answer
33

Views

How to save bio using forms.ModelForm

I tried multiple links on stackov. but none worked, I can't get my bio form to save the data on the db for the user profile :/ I managed to save the first name and last name, but I can't make the bio save... This is my code: profile.html {% csrf_token %} First name {{ user_ProfileForm.first_name |as...
Arturo
1

votes
1

answer
2.8k

Views

django-crispy-forms : help_text_inline of FormHelper not working as expected

For the following model: class MyModel(models.Model): name = models.CharField(max_length=110, help_text='Some sample help text.') def __unicode__(self): return u'%s' % (self.name) And the following modelform: class MyModelForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(MyModelForm,...
chefsmart
1

votes
2

answer
607

Views

How to pass currently logged in user to the model using generic views?

I am new to django and I was asked to associate currently logged in user with Context (my model class) the user creates. How/where to retrieve the User (from request.user) object? How to set it in the model? Is it possible to pass request.user to view using generic views? Here is my Context class: f...
matali
1

votes
1

answer
1.1k

Views

How to use a CreateView and include fields in form for new ForeignKey model?

By default CreateView/UpdateView just includes a dropdown for selecting an already existing ForeignKey-related object. Using django-crispy-forms, how do I have a CreateView or UpdateView that not only includes fields for my model, but fields for creating a new model related via ForeignKey? Would I b...
Dustin Wyatt
1

votes
1

answer
754

Views

In Django Crispy Form how i can use `layout.append(HTML(“<p>whatever</p>”))`

I read the tutorial about crispy form in read the docs. I found some thing very useful, in Manipulating a layout in https://django-crispy-forms.readthedocs.org/en/d-0/dynamic_layouts.html layout.append(HTML('whatever')) layout.insert(1, HTML('whatever')) so i tried: class PostJobForm(forms.ModelForm...
simple_human
1

votes
1

answer
1.6k

Views

Remove Label from django crispy form layout

I am using djano Crispy form and twitter bootstrap, i have a form. def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_method = 'POST' self.helper.form_class = 'form-horizontal' self.helper.layout = Layout( Div( Div(HTML(''' Trust Admin Name'''), css_class='span3'), Div...
Tushar.PUCSD
1

votes
1

answer
154

Views

Django crispy forms only partially loading css

I am trying to create a crispy form that looks something like this, but my code renders a default html input box and a disjoint bootstrap button instead of the desired, 'connected' form. My form code looks something like: class SearchForm(forms.Form): query = forms.CharField() def __init__(self,...
2014mchidamb
1

votes
2

answer
592

Views

Django errors while using crispy_forms and a custom template

I have problems display the default errors within a form I'm creating via crispy_forms using a custom template. Namely, the text 'This field is required.' is not present for two fields. Please see, here Here's the form's init code: ... start_time = forms.TimeField(label='Start Time', required=True,...
Joe Lones
1

votes
1

answer
90

Views

how to apply Django crispy_forms to create an attractive layout?

i tried the following code to create a form using Django crispy_forms but when it rendered gives simple html for layout forms.py from django import forms from crispy_forms.helper import FormHelper from crispy_forms.layout import Submit class SimpleForm(forms.Form): username = forms.CharField(label='...
Vishnu Kant
1

votes
1

answer
238

Views

Mixing free-tagging, auto-complete and select options in Django

I'm working on creating forms to encourage users to input keywords and other data. I've found a great solution for user input of category style data where users select one or more predefined options. http://renooble.tumblr.com/post/50369942756/displaying-many-to-many-fields-in-django-with This uses...
Mick Mushroom
1

votes
1

answer
849

Views

Can't Just Append A Delete Button To A Crispy Form

I'm trying to create a fairly simple form that will allow me to update and delete instruments from a database. Everything is working except for HTML rendering, and for that I'm using django-crispy-forms. The following code works really well if all I want is a Submit button: forms.py class Instrument...
Tom Purl
1

votes
1

answer
1k

Views

Django render a form field with css using crispy forms

I have a form I want to render with crispy form, FORM class MyForm(forms.ModelForm): class Meta: model = MyModel excludes = ('user', 'created') def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_show_labels = False ## I only need the input field self.helper.layout = la...
Alexxio
1

votes
1

answer
980

Views

Formset within a Form Using django crispy-forms

I'm trying to follow the answer given by @qris in a previous question (django crispy forms: Nesting a formset within a form) but I get a KeyError at formset = context[self.formset_name_in_context] in the render function. I don't quite understand what's going on. Where is the context coming from? How...
steph
1

votes
1

answer
428

Views

Django composite forms - how do I build and save them?

I am trying to build a form that would provide report tracking. Report itself is ProjectReport class that links instances of all available ReportAtoms. Each ReportAtom is a combination of RAGItem (like 'Progress', 'Risks', 'Resources') and RAGMarker ('Green', 'Red'): class ProjectStatus(CoreBase): r...
abolotnov
1

votes
1

answer
1.5k

Views

How to show validation error messages while using TemplateView and crispy forms

How to return the form with error messages using Crispy Forms. I can't use FormView because I am trying to add multiple model forms to the same tag. class Test(TemplateView): template_name = 'login.html' def get(self, request, *args, **kwargs): form = RegistrationForm() return render(request, se...
utkbansal
1

votes
3

answer
983

Views

Django crispy forms: add text next to a checkbox?

It seems to be simple but I can't figure out how to add some text next to my checkbox. I don't want to override the template (I think I don't need to). For now, I have a checkbox that works, but how to put some text like 'I Agree TOS' at the right of the checkbox? Here is what I have: https://www.dr...
David D.
1

votes
1

answer
370

Views

How to use Django parsley with crispy form in Django?

I am a beginner in Django crispy form and Django parsley,I want to know how to add data-validate = 'parsley' in the form tag. {{ form.as_p }} my form.py consist of the following code.I am using Crispy form. def __init__(self, *args, **kwargs): ''' Describes how to render the form in the template. ''...
nidhin
1

votes
2

answer
384

Views

Django form how to create a simple mixin

I have a set of special forms that refer to a single model, I've defined a common: class myBaseFormMixin(forms.Form): data_prod = forms.DateField(initial=datetime.date.today, label='Data') class Meta: model = mymodel def clean(self): if self.data['a']=='off': raise forms.ValidationError('check...
user2239318
1

votes
1

answer
1.4k

Views

Django: Ajax validation of Crispy forms

I am trying to get Crispy forms Ajax validation to work for my Django site, but I'm not sure how the errors are supposed to be displayed. When I submit an invalid form, it appears that the JSON form that gets sent back is exactly the same as the original one, so I don't understand how the error res...
zoidberg
1

votes
1

answer
1.1k

Views

How can I manipulate the form-group and controls divs with django-crispy-forms?

I'm using Django 1.8 and Crispy-Forms with Twitter Bootstrap 3 Here's what I have at the moment: self.helper.layout = Layout( ... 'address', StrictButton('Find address', id='find_address', css_class='btn-primary'), ) This outputs: Address Find address What I'd like to output (class form-inline and...
StringsOnFire
1

votes
3

answer
1.1k

Views

Django-crispy-forms place Submit button in different location

I'm using Django-crispy-forms, and I want to be able to place the Submit button in a different place than right next to the bottom of the form. Here is my form: from django import forms from django.core.urlresolvers import reverse from crispy_forms.helper import FormHelper from crispy_forms.layout i...
zoidberg
1

votes
1

answer
1k

Views

Where are templates to django-filter package?

I am a little bit confused. https://github.com/carltongibson/django-filter/blob/develop/django_filters/rest_framework/backends.py From line 31 to 37 - here is a logic, if I have crispy instaled, package should use django_filters/rest_framework/crispy_form.html file. I have installed all newest pac...
pmoniq
1

votes
3

answer
664

Views

add an icon to django crispy form submit button

I am struggling with the Button on a crispy form. Instead of just the default button I would like to have an icon inside The form I am currently using is like class MyForm(forms.ModelForm): helper = FormHelper() helper.layout = Layout( Div( Div(PrependedText('source_text', ''), css_class='col-md-6')...
mbieren
1

votes
1

answer
94

Views

Calculated fields (property) in crispy forms

It is possible to render calculated fields from model (@property) as readonly field or using HTML layout in crispy-forms? Thanks in advance for your answers.
Dani Díaz
1

votes
1

answer
45

Views

Hide drop-down menus in using id number

I passed a list [object1, object2, ...] to a drop-down menu. When I pressed on F12 with the desire of knowing the id of object1 which is Total number of clients in the following HTML code. I want to use that id in a JS file. How could I generate one id for each item of the list. Otherwise, what can...
J.G
1

votes
1

answer
272

Views

Django crispy forms - creating a form in home.html and getting an error

I have built a crispy form from a tutorial (https://godjango.com/29-crispy-forms/) and am getting an error that I believe means I need to define a URL in the urls.py. I also get the sense that there may be more than one issue going on - I am still trying to make this work and will continue to resear...
Steve
1

votes
1

answer
1.1k

Views

inline form with django crispy form

I'm sorry but I just don't get it, the docs here are pretty awesome, and I'm using practically the same example, I just have two fields, that I want do display inline, but it's just does not work, My form: from django import forms from crispy_forms.helper import FormHelper from crispy_forms import l...
PetarP
1

votes
1

answer
74

Views

All-auth / Crispyform : Error messages not displayed

I'm working on the all-auth authentification process of my website and I encounter a problem: I can't see the error messages of the login / signup views, when I do something wrong (bad password, not typing same password in signup for ex.) the page just reload. Views.py class CustomLogin(LoginView)...
Stakha
1

votes
1

answer
210

Views

Django Crispy forms - positional argument follows keyword argument error

Im new to crispy forms and am trying to use bootstrap to style some form fields into a bootstrap panel, then I will add some other fields into another panel and so on. Building the first panel I am getting the below error. something is awry but am not sure what? Traceback: File '/usr/local/lib/pytho...
AlexW
1

votes
1

answer
416

Views

How to add email address in signup_form.html - Django-crispy-forms

My signup_form.html is as below, is there any way to add a email address in this form without changing views.py of back-end code?, I would like to let user fill in email adress when he is registering, {% extends 'base.html' %} {% load crispy_forms_tags %} {% block content %} {% csrf_token %} {{ for...
Begin2Pip
1

votes
1

answer
0

Views

Django crispy forms - Set hidden field value

I've got the following django crispy form: class ConsultForm(forms.ModelForm): class Meta: model = Consults # Your User model fields = [ 'TEMPLATE','EMAIL', 'DATE'] labels = { 'EMAIL' : 'Your Email', 'DATE' : 'Todays date', # 'captcha': 'Enter captcha' } helper = FormHelper() helper.form_method = 'P...
user61629
1

votes
1

answer
0

Views

Django Bootstrap Crispy InlineField with custom validation missing message

I'm using Django Crispy forms to render a fieldset containing multiple fields, most of which are not inline, but I have a date of birth field (a DateField with SelectDate Widget) which I'd like to be inline. It uses a custom validation in which is translates date to age and then checks that the user...
Henry George

View additional questions