Hi,
I have a form MyForm which I update using ajax as the user fills it out. I have a view method which updates the form by constructing a MyForm from request.POST and feeding it back.
def update_form(request):
if request.method == 'POST':
dict = {}
dict['form'] = MyForm(request.POST).as_p()
return HttpResp...
Django 1.1
models.py:
class Property(models.Model):
name = models.CharField()
addr = models.CharField()
phone = models.CharField()
etc....
class PropertyComment(models.Model):
user = models.ForeignKey(User)
prop = models.ForeignKey(Property)
text = models.TextField()
etc...
I have a form which needs t...
Hi
I'm trying to set custom 'name' attribute in django form.
I've been trying this kind of approach:
class BaseQuestionForm(forms.Form):
question_id = forms.CharField(widget=forms.HiddenInput)
answer = forms.ChoiceField(choices = [ ... ], widget=forms.RadioSelect)
and then setting the 'name'-attr on answer with:
form.fields['an...
I have a form (not a model one) for a rsync front-end type. So I would like that when the user selects the source, it will get deleted from the destination choice. I'm new to python and django so forgive my ignorance. This is my forms.py:
from django import forms
class ChoiceForm(forms.Form):
source = forms.ChoiceField(choices=[(1,...
I have a template that has a button that posts just the button's name to a view which has the following code:
if request.POST:
a = request.POST
name = mymodel.objects.get(id = a )[0]
return HttpResponse(name)
request.POST has the name of the button that submitted the post. THE error is: int() argument must be a string ...
Is it possible for an inlineformset_factory to take in a ModelForm as well as a model. When I try to run this I get an error message 'NoneType' object is not iterable.
Please help, I've spent an entire day trying to figure this out. Thanks.
Code:
Model.py
class FilterForm(ModelForm):
firstFilter = forms.BooleanField(label='First Filt...
How can I temporarily turn off verify_exists on a models.URLField at runtime? I would like to skip the check on certain URLs (they block EC2 IPs from their firewall).
I'm interfacing with the model through the ModelForm right now.
...
I have two submit buttons part of two different forms. They are being displayed on two different lines. Is it possible to have them, side by side on a single line.
<form action="" method="POST">
<input type="submit" name = "" value="OK" >
</form>
<form action="" method="POST">
<input type="submit" na...
Hi guys, my problem is simple. Where the right place for a custom error_css_class value is when using ModelForm?
I tried this:
class ToolForm(ModelForm):
error_css_class = 'wrong_list'
class Meta:
model = Tool
widgets = {
'name' : TextInput(attrs={'class': 'small_input corners'}),
'description' : T...
Dears
I have a django model as following
class Project(models.Model)
name=models.CharField(max_length=200)
class Application(models.Model)
proj=models.ForeignKey(Project, null=True, blank=True)
I need to modify the admin form of the project to be able to assign multiple applications to the project, so in the admin.py I ...
What is the best way to pass request information to a model class method?
I'm wondering whether I have my logic in the wrong place. Maybe I need to move it out of my model.
I want to be able to pass in POST variables or a form to filter the model by country or institution.
I can't do that from the template, but the question is whethe...
I use fileSystem caching in my django application
what I need is to clear the cache after any action(adding or editing or deleting) taken by the admin
is there any way to get an action (clearing the cache) to be executed after all the submission of any form in the admin site?
...
I've got a boolean field,
is_operable = BooleanField(widget=RadioSelect(choices=YES_OR_NO, renderer=InlineRadioFieldRenderer), required=False, initial=True)
Which is rendered as two radio buttons (yes or no), but I want it to be required. The problem is that if I change it to required=True, it throws a validation error when it gets Fa...
I'm having some trouble trying to understand how to create a dynamic choice field in django. I have a model set up something like:
class rider(models.Model):
user = models.ForeignKey(User)
waypoint = models.ManyToManyField(Waypoint)
class Waypoint(models.Model):
lat = models.FloatField()
lng = models.FloatField()
...
I need to offer a from in which a user can manage the permission associated to some Group.
I'd like to use the forms.ModelForm feature which comes from django, but I cannot understand how to modify the queryset over which the field cycles. I've also taken a deep look in contrib.admin and contrib.auth to discover where those forms are ge...
I'm trying to do something pretty simple; I'd like to apply a "hidden" style to a form field inside a django template when I've passed in some initial value like this:
form = form_class(initial={'field':data})
Normally, it would be like this:
<li class="{{form.somefield.name}} {% if form.somefield.initial %} hidden{% endif %}>
.....
I want to write my own method for the password reset form to make some tests about the new password (length, characters,...). So I added this class to my forms.py:
class PasswordResetForm(SetPasswordForm):
def clean(self):
if 'newpassword1' in self.cleaned_data and 'newpassword2' in self.cleaned_data:
if self.cleaned_data['n...
Hi,
I am a current web2py user, but find I still go back to Django once in a while (where I started). Specifically when working on projects where I want to make use of some specific django apps/plugins/extensions that don't yet exist in web2py.
One thing that I can't live without in web2py, which I am looking for a solution for in Dja...
Hi,
I'm trying to understand why I can't specify choices to a form field's widget if I'm overriding a ModelForm's field in Django. It works if I give the choices to the field but not the widget. My understanding is/was that if you give choices to a field it'll be passed onto the widget for rendering. I know I can get this to work with a...
I have a simple Book Author relationship
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_now=True)
class Book(models.Model):
title = models.CharField(max_length...