I have two models, Event and Series, where each Event belongs to a Series. Most of the time, an Event's start_time is the same as its Series' default_time.
Here's a stripped down version of the models.
#models.py
class Series(models.Model):
name = models.CharField(max_length=50)
default_time = models.TimeField()
class Event(...
I have errors raised in the form's clean method (not tied to a field).
How do I display them in the template?
I tried {{ forms.errors }} and {{ form.non_field_errors }} but neither worked.
...
I have a model User which appears as a ReferenceProperty in another model, Group.
When I create a form for Group, using Meta, the form's values contain lots of generated strings. I'd like to stop this, and use the username field of User instead.
I already define a key_name. However, str(user.key()) still gives a generated string. I cou...
i need make a special widget for ForeignKeys in Admin, but i need get the class of model in the widget, somebody know how i can do it?
I think the Widget have a Field, and Field have a ModelForm, and obviously ModelForm have a Model, but i need this model in a widget in the admin.
...
Hi all,
I've got a form that renders a choicefield widget with a total of 3 choice values: 0, 6, 19 (these are of type "Decimal').
When editing an object via a modelform that has the value 6 or 19 the widget has selected the proper one when rendered, but when the object is stored with the value "Decimal('0') it has selected the empty_...
Is it possible to prepopulate a formset with different data for each row? I'd like to put some information in hidden fields from a previous view.
According to the docs you can only set initial across the board.
...
I'd like to be able to display additional information like a text label with each row in a Django formset.
Example/usecase:
User picks 5 rows in a model that would he would like some action performed. A popup appears that displays a 5 form formset some additional information (that are model instance methods) based on the 5 rows chosen...
I try to add a recaptcha field to my registration form and followed Marcos guide:
http://www.marcofucci.com/tumblelog/26/jul/2009/integrating-recaptcha-with-django/
In my registration app, I have a file "forms.py" which looks like this:
from recaptcha import fields as captcha_field
from registration.forms import RegistrationFormUniqu...
I'm using django-uni-form to style my form using the filter my_form|as_uni_form:
<form class="uniForm" id="my_form" method="post" action="./">
<fieldset class="inlineLabels">
{{ my_form|as_uni_form }}
<div class="form_block">
<input type="submit" value="Submit"/>
</div>
</fi...
I have been developing some Django app and there's some duplicated code for different Models. I'd like to create a generic table template and pass the Model class, a list of model instances, and Form classes to it so it can render the page and generate the forms to add/delete elements. Then create some generic add/delete views to work wi...
I'm wrestling with how to best create HTML pages in Django that can either be used for displaying or editing data. That is, I'd like the field's values to appear as text in display mode, but in their widgets when in edit/add mode. It appears that Django wasn't designed to do this: the fields always appear in their widgets (eg, text input...
Hi, I've just started Django and Python 50 hours ago ;-) so this might be an easy one but I am stuck.
I am using similar 'create' view with similar Form implementation in my project with no problem. In this case, I get the above mentionned error.
I am using Pinax...
2 from django.shortcuts import render_to_response, get_object_or_40...
I have several forms each having a hidden field that identifies this form...I want to check for this field in my view then based on the result determine which form will be processed. How should i go about this?
...
Is it possible to set a form's ForeignKey field's queryset so that it will take separate queryset's and output them in <optgroup>'s?
Here is what I have:
views.py
form = TemplateFormBasic(initial={'template': digest.template.id})
form.fields['template'].queryset = Template.objects.filter(Q(default=1) | Q(user=request.user)).order_by('...
i'm using Django 0.96 and want to implement the following form:
the user must either choose value from dropdown list or enter its own string to textbox field. the required field should be indicated by checkbox (if it's on - the required field is a charfield, otherwise - dropdownlist)
DB : __DBvalues___V # dropdownlist
own choic...
I have the following models:
class Territory(models.Model):
name = models.CharField(max_length=30)
power = models.ForeignKey(Power, null=True, blank=True)
is_supply = models.BooleanField()
class Subregion(models.Model):
territory = models.ForeignKey(Territory)
subname = models.CharField(max_length=10, blank=True)
...
I get the following error when instantiating a Django form with a the constructor overriden:
__init__() got multiple values for keyword argument 'collection_type'
The __init__() function (shown below) is exactly as written this but with # code replaced with my logic. Asside from that I am essentially overriding the form's (which is a ...
Hey all, I'm fairly new to both django and jquery, but have a couple years of general oo programming experience (mainly flash/flex/cf), and I'm trying to figure out the best way to implement a form for a sports tournament that manages a few model relationships and uses some simple jquery to improve usability.
My models look like this:
...
Hi everyone,
I have read the documentation several times, but I am still confused. When you specify a model in Django, you can specify the file's destination. However, in the documentation, they go on a great deal about handling the write to disk manually. My question is: Is it better to just say form.save() or to write a file handler w...
Hi, I have got problem with django's UserCreationForm. It's very strange because ween I:
view:
from django.contrib.auth.forms import UserCreationForm
from django.shortcuts import render_to_response
form = UserCreationForm()
context = {'form' : form}
render_to_response('something.html', context)
template:
...
{% block content %}
{...