django-forms

Django - Minimum time between posts

My models: class Entry(models.Model): title = models.CharField(_('Title'), max_length=200) content = models.TextField(_('Content')) created_at = models.DateTimeField(auto_now_add=True) My models is used for multi-user. So, how to set a value to handle minimum time between posts? Please give me some codes. Thanks so much! ...

custom error messages with Model Form

I can see how to add an error message to a field when using forms, but what about model form? This is my test model class Author(models.Model): first_name = models.CharField(max_length=125) last_name = models.CharField(max_length=125) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_...

The "next" parameter, redirect, django.contrib.auth.login

I'm trying to redirect users to custom url "/gallery/(username)/" after successfully logging in. It currently redirects to the default "/account/profile/" While I know what I can override the redirect url in my settings.py, my url is dynamic thus it will not work. Documentation states that I need to use the "next" parameter and contex...

Calendar input like admin application Django

Hi, Using the django admin application for a date it displays Today | CalendarSymbol. I am using a datefield in my form and I thought it would do this for me how would i go about doing this? As i would normally use the jquery datepicker plugin is this the way to go? Thanks in Advance, Dean ...

Passing instance/default value to a ModelFormSet for the empty forms to use, in a view.

How do i pre-populate the exclude fields in a ModelFormSet. AuthorFormSet below doesn't take an instance argument here, only queryset. So how do i force the empty forms coming in not to have a NULL/None user attribute. I want to be able to set that user field to request.user models.py class Author(models.Model): user = models.Forei...

Django: Set field choices from view?

I've got some <selects> that I need to populate with some choices that depend on the currently logged in user. I don't think this is possible (or easy) to do from inside the form class, so can I just leave the choices blank and set them in the view instead? Or what approach should I take? ...

Conditionally required fields and disabled inputs

My form has a bunch of address fields (street, city, country, province, postal code) that need to be filled out over and over again. To make it easier for the user, I've added a "copy from" selector where they can choose an address they've previously used. When they do this, the form fields are filled in automatically and then disabled. ...

On edit data from inlineformset_factory is missing

This is my code to get recipe data objRecipe = models.Recipe.objects.get(id=recipe_id) recipe = models.RecipeForm(instance=objRecipe) objRecipeSteps = models.RecipeStep.objects.filter(recipe__id = objRecipe.id) recipeSteps = models.RecipeStepFormSet(queryset=objRecipeSteps) I am able to display data from "recipe" but not from "recipe...

Exclude a field in django admin for users not super admin

Hi guys, how i'll exclude a field in django admin if the users are not super admin? thanks ...

Django forms integerField set max_value on runtime

I've got a form like this: class SomeForm(forms.Form): first = forms.IntegerField(max_value= DontWantToSetYet) second = forms.IntegerField(max_value= DontWantToSetYet) third = forms.IntegerField(max_value= DontWantToSetYet) How can I set the max_values at runtime? I.E if request.method == 'POST': form = SomeForm(request.POST, ...

How force user to fill forms before do something else ?

Hi guys, i would like to know how force user to fill forms before do something else. I have a private area, i need the user's fill the forms, there's 4 forms, (is a job's board). a) i want fill the forms with wizardforms, but how force to do it? Sorry with my english Thanks ...

processing an image upload form in django: when to use save() vs chunks() vs cleaned_data?

I have successfully uploaded an image using the following code: views.py from django.conf.urls.defaults import * from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render_to_response from django import template from django.template import RequestContext from mysite.uploadr.forms import UploadFileFo...

"invalid literal for int() with base 10:" But can't see why it is accessing an integer

Hi, I can't see why in my application i am getting this error. As all primary keys are text fields are integers. Here is my code: forms.py class EventAttendForm(forms.Form): talk = forms.ModelChoiceField(queryset=Talk.objects.all()) membersAttended = forms.ModelMultipleChoiceField(queryset=Member.objects.all()) models.py ...

FormWizard and saving data

Hi guy's, im trying to use django formWizard, all is fine, but im getting an error in the last step after submit Traceback (most recent call last): File "/home/vacantes/webapps/django/lib/python2.6/django/core/handlers/base.py", line 100, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/h...

Appengine Fill a Form on the same page with different classes

Hello everyone. I have this code that works. My class is a db.Model one2many with a teacher, experience, and so on... What I want is to call the class teacher with forms, but also intend to include other classes, like a form from experience class and a form from category. These classes are as foreign Key teacher. I wonder how to derive...

Django form template

If there were field.errors in django, how to to add css class to {{ field }}, example at bottom {% for field in form %} {{ field }} {% if field.errors %}{{ field.errors }}{% endif %} {% endfor %} Aiming for {{ field }} input type that would have "class=error" when ever there was an error <input class="error"> ...

django - many to many field as dropdown on form

I have a many to many relationship model which actually shows as a multi select list on forms. In one particular place I want to show it as dropdown single selection - any idea how to do this? ...

How wrap a FormWizard in a View?

How do I wrap a Django Form Wizard in a view? I need to do this so I can access request. Does anyone have some example code for this? ...

Is there any analog of django's forms in Ruby on Rails?

Hi guys, Is there any analog of django's forms in Ruby on Rails? Thanks, Alexey Zakharov ...

Make all inline formset forms optional

I have an Article form that can have 0-5 images attached so I am using a normal form for article and a formset for the images. Is there way to make it optional to fill out any information for the forms in the image formset? When I leave them I get validation errors that I have not field out required fields. ...