Hi All,
I have a django model roughly as shown below:
class Event(db.Model):
creator = db.ReferenceProperty(User, required= True)
title = db.TextProperty(required = True)
description = db.TextProperty(required = True)
class Ticket(db.Model):
user = db.ReferenceProperty(User, required = True)
event = db.ReferencePropert...
Hi guys, i have a "rare" behavior here, i this model:
models.py
class Area(models.Model):
area = models.CharField(max_length=150,unique=True)
slug = models.SlugField(max_length=200)
fecha = models.DateTimeField(default=datetime.date.today,editable=False)
activa = models.BooleanField(default=True)
class Empresa(models.M...
Hello Guys,
I have a form with a ModelMultipleChoiceField to list of categories.
I would like to group categories using the Category.group field.
I thought that by changing the field.choices in the init function it will make the trick
class CategoriesField(forms.ModelMultipleChoiceField):
def __init__(self, queryset, **kwargs):
...
I am trying to display a bound ModelForm in my template.
Here the the code from the view:
assessment = Assessment.objects.get(slug=slug)
form = AssessmentForm(assessment)
But when I then pull up the template, it is empty except for the submit button.
When I try to debug with PDB, I get:
(Pdb) form.data
<Assessment: Alaska - Coastal...
First try at playing with model formsets with django and was wondering how to filter by the logged in user. The view below renders a form with all the profiles when I only want them to list one (the user's one).
def create_profile(request):
ProfileFormSet = modelformset_factory(Profile)
if request.method == 'POST':
formset...
Hi,
I'm trying to build a custom multivaluewidget in my django app.
Widget
class DayInputWidget(MultiWidget):
def __init__(self, attrs=None):
widgets = (DayInput(day_name='Mo'), DayInput(day_name='Di'), DayInput(day_name='Mi'), DayInput(day_name='Do'), DayInput(day_name='Fr'))
super(DayInputWidget, self).__init__(...
Prior to today, I've been using Django 1.1. To ensure I'm keeping up with the times, I decided to update my Django environment to use Django 1.2.3. Unfortunately, I've encountered an issue.
The following code did not raise a ValueError in 1.1:
instance = FormClass(
request.POST,
instance=existing_instan...
Does anybody know, how to support i18n in forms ? I would like to use {% trans "SOMETHING" %} in a template. Or should I just use _() in views.py only for the selectbox, in order to translate these strings?
I do not want to use model i18n addons.
...
I am developing an app for use on Google App Engine with Django and Google App Engine Django Helper.
A certain model is looking like this:
from appengine_django.models import BaseModel
from google.appengine.ext import db
from google.appengine.ext.db.djangoforms import ModelForm
class Server(BaseModel):
name = db.StringProperty(req...
Is there any way to get the id of a field in a template?
In the HTML i get: <input name="field_name" id="id_field_name"...
I know I can get the name with {{ field.html_name }}, but is there anything similar for getting the id?
Or can I only get it like this: id_{{ field.html_name }}?
...
Hi all,
I am trying to create a simple CRUD with ModelForm. It works fine except that every time I edit, saving creates a new instance of the data. So i edit and get an extra row in DB instead of an updated one. I am at a loss as to how it knows to save an existing charity as it does not store the PK (id) as a hidden field in the form. ...
Hi.
I am trying to use django-friends in my app, with no luck.
This app is not well documented and I cannot seem to find any real information about it out there.
Has anyone used this app in their project before? Something that is not a PINAX project.
Any links or ideas will be appreciated.
...
The use case I am try to address is a requirement for a user to have downloaded a file before being permitted to proceed to the next stage in a form process.
In order to achieve this, I have a Django Form to capture the user's general information which POSTS to Django view 'A'. The Form is displayed using a template which also includes ...
Hi!
I'm trying to do a form, with gender choices. The user could choice between male or female.
What I have now in forms.py:
class GenderForm(forms.Form):
demo = DemoData.objects.all()
GENDER_CHOICES = [
('Male', 'Masculino'),
('Female', 'Feminino')]
gender = forms.ModelChoiceField(demo, widget=Select(), r...
Exactly like this question, except that one got closed and accepted without a real answer. It looks like I can use a custom formset and override the clean method, but that still doesn't answer how I check that they're all filled in. What properties am I supposed to be looking at?
The formset is smart enough to ignore extra forms that...
Hi,
How can I create a Form with normal form elements and generic elements together as ModelForm
For using frontend CRUD.
For example;
Generic Model:
class Todo(models.Model):
user = models.ForeignKey(User, related_name="todo")
title = models.CharField(max_length=100, unique=False)
slug = models.SlugField(max_length=50)
...
I want to build a system using Django that will allow users to build forms, store them and have their customers use them. I know how I can go about creating the forms dynamically but I'm looking for a good way to still use the form classes and handle many different user's dynamic forms in an elegant way.
I'm thinking of storing the for...
I'm using the phone number MultiWidget provided by derek73. Question is: it puts three separate values in the POST - how should I recombine them into one value?
class USPhoneNumberMultiWidget(forms.MultiWidget):
"""
A Widget that splits US Phone number input into three <input type='text'> boxes.
"""
def __init__(self,attrs=None):
wi...
Is there a more efficient, or cleaner way to do the following?
class SpamForm(ModelForm):
some_choices = fields.MultipleChoiceField()
def __init__(self, *args, **kwargs):
super(SpamForm, self).__init__(*args, **kwargs)
self.fields['some_choices'].choices = [[choice.pk, choice.description] for choice in self.inst...
I have a form for a model wich has two fields: field_A and field_B. I want to:
when the form is rendered: only field_A is displayed
when i call form.save() field_B is saved in the model with the value from field_A
What i've tried:
field_A = forms.CharField(required=True)
field_B = forms.CharField(required=False)
def save(self, *arg...