So I have this model with multiple Many2Many relationship. 2 of those (EventCategorizing and EventLocation are through tables/intermediary models)
class Event(models.Model):
""" Event information for Way-finding and Navigator application"""
categories = models.ManyToManyField('EventCategorizing', null=True, blank=True, help_text="categ...
I have this class in my model:
class ServiceCharge(models.Model):
name = models.CharField(max_length=30)
amount = models.PositiveIntegerField()
extends_membership = models.BooleanField(default=False)
def __unicode__(self):
return str(self.name)
What I want to have is in the form for charging users a service charge, when a...
I have the following model:
class Image(db.Model):
auction = db.ReferenceProperty(Auction)
image = db.BlobProperty()
thumb = db.BlobProperty()
caption = db.StringProperty()
item_to_tag = db.StringProperty()
And the following form:
class ImageForm(djangoforms.ModelForm):
class Meta:
model = Image
When...
If I have two models like
class Author(models.Model):
name = models.CharField(max_length=100)
title = models.CharField(max_length=3, choices=TITLE_CHOICES)
birth_date = models.DateField(blank=True, null=True)
def __unicode__(self):
return self.name
class Book(models.Model):
name = models.CharField(max_lengt...
I want to update the Meta.fields dynamically. Is it possible to do it from the Form constructor? I tried the following but year doesn't show up during the form generation. Only name and title are displayed.
class Author(models.Model):
name = ...
title = ...
year = ...
class PartialAuthorForm(ModelForm):
class Meta:
...
hi.. i have the following form class with corresponding clean methods...
class SOFIATMUserLogin(forms.Form):
Username=forms.CharField(label='Username')
Password=forms.CharField(label='Password', widget=forms.PasswordInput)
def clean_Username(self):
user=self.cleaned_data['Username']
try:
SOFIALogin.objects.get(UserName=user)
except Exc...
Hi All,
I've recently been developing on the django platform and have stumbled upon Django Forms (forms.Form/forms.ModelForm) as ways of creating <form> html.
Now, this is brilliant for quick stuff but what I'm trying to do is a little bit more complicated. Consider a DateField - my current form has fields for day, month and year and c...
Hey,
I have got a choiceField in my form, where I display filtered data. To filter the data I need two arguments. The first one is not a problem, because I can take it directly from an object, but the second one is dynamically generated. Here is some code:
class GroupAdd(forms.Form):
def __init__(self, *args, **kwargs):
sel...
Can please anybody explain how to use datagrid in a django application????
...
I'd like to use the user updated values of a ManyToManyField in a model's overriden save() method when I save an instance in admin.
It turns out that by design, django does not update the M2M field before calling save(), but only after the save() is complete as part of the form save...
e.g. in both print commands bellow the values disp...
I have the following problem to solve. In my project users (defined by first name, last name and personal id number ) have the possibility to register accounts. Each registered user (let's call him 'user1') can also add data of up to 4 friends. Those friends then later can join the community themselves, and their profile should disappear...
I have a BooleanField in a Django 1.2 form.
I'm setting for it default=True but it is still unchecked in the browser by default.
Googling for it shows that some people are using initial=True, but this breaks the code for me completely (unrecognized keyword "initial").
Any ideas?
...
form = AddItemForm(request.POST, request.FILES)
if form.is_valid()
do_stuff
return render_to_response(blah.html, {'form':form})
Now form will have the error information along with the original values of the fields, but it does not retain a selected file
How do I keep the selected file if the form fails validation?
...
I'm working on a basic event form created from a model, but I keep getting the following error message:
TypeError at /addlaundry/
addlaundry() takes exactly 1 argument (0 given)
I think it's because I'm not passing the argument through on views, but I can't find documented anywhere how to do this right, at least not written in a way I...
I need a Django Form Field to support US or International phone numbers. Does one exist? How could you validate US phone #'s or int'l ones.
...
class Material(models.Model):
products = ManyToManyField('Product', related_name='materials')
class Products(models.Model):
...
class ProductForm(forms.ModelForm):
class Meta:
model = Product
fields = ('materials', )
I want to do this.
I saw this discussion:
http://groups.google...
Here is my model
class RecipeIngredient(models.Model):
recipe = models.ForeignKey(Recipe)
ingredient = models.ForeignKey(Ingredient)
serving_size = models.ForeignKey(ServingSize)
quantity = models.IntegerField()
order = models.IntegerField()
created = models.DateTimeField(auto_now_add = True)
updated = models...
I have an extended UserProfile for registering new users. My user_created function connects to signals sent upon registering basic User instance and creates new UserProfile with extended fields from my form. Here's the code :
from registration.signals import user_registered
from accounts.forms import ExtendedRegistrationForm
import ac...
Heya!
I have three models:
Variable, which has Group as a foreign key
Group, which has Set as a foreign key
Set
I want to create a form that lets user create a new Set based on existing Set. Only things that user is able to modify are the Set name and Variable values.
This has given me an idea of using inlineformset_factory to acce...
I recently upgraded to Django 1.2.1 because I was specifically interested in the ability to have basic many-to-many inline fields. When using the admin like so:
Initial models:
class Ingredient(models.Model):
name = models.TextField()
class Recipe(models.Model):
ingredients = models.ManyToManyField(Ingredient)
Initial admin...