Is there a quick way to submit (pre-defined) POST data from a hyperlink in a Django template? I've got an 'add this to my favourites' link on page. I'm currently doing this with a GET request, which obviously breaks all kinds of rules.
I could manually build a form and have the link submit it with Javascript. I'm looking for an automat...
My models:
HitCounter:
hits = models.PositiveIntegerField(default=0)
object_pk = models.TextField('object ID')
content_type = models.ForeignKey(ContentType,
verbose_name="content cype",
related_name="content_type_set_for_%(class)s",)
content_object = generic.GenericForeignKey('conte...
I have a Django form that allows a user to change their password. I find it confusing on form error for the fields to have the *'ed out data still in them.
I've tried several methods for removing form.data, but I keep getting a This QueryDict instance is immutable exception message.
Is there a proper way to clear individual form fields...
Is it possible to have Django automatically delete formsets that are not present in the request?
So for example if I had three inline formsets represented in HTML when I loaded my edit page and I use javascript to remove two of those when the request is processes Django sees that those two forms are no longer their and deletes them.
...
I have models like this:
class IdfPracownicy(models.Model):
nazwa = models.CharField(max_length=100)
class IdfPracaOpinie(models.Model):
nazwa = models.CharField(max_length=30)
class IdfPraca(models.Model):
numer_idf = models.ForeignKey(IdfPracownicy)
[...]
opinia = models.ForeignKey(IdfPracaOpinie)
uwagi = model...
I have some codes like this:
cats = Category.objects.filter(is_featured=True)
for cat in cats:
entries = Entry.objects.filter(score>=10, category=cat).order_by("-pub_date")[:10]
But, the results just show the last item of cats and also have problems with where ">=" in filter. Help me solve these problems. Thanks so much!
...
Hi
I have wrote a custom widget
class AutoCompleteWidget(widgets.TextInput):
"""
widget to show an autocomplete box which returns a list on nodes available to be tagged
"""
def render(self, name, value, attrs=None):
final_attrs = self.build_attrs(attrs, name=name)
if not self.attrs.has_key('id'):
final_attrs['id'] = 'id...
Why can't I do this?
from django import forms
from django.forms import widgets
class UserProfileConfig(forms.Form):
def __init__(self,*args,**kwargs):
super (UserProfileConfig,self).__init__(*args,**kwargs)
self.tester = 'asdf'
username = forms.CharField(label='Username',max_length=100,initial=self.tester)
Mo...
I am calling a form as follows, then passing it to a template:
f = UserProfileConfig(request)
I need to be able to access the request.session within the form... so first I tried this:
class UserProfileConfig(forms.Form):
def __init__(self,request,*args,**kwargs):
super (UserProfileConfig,self).__init__(*args,**kwargs)
...
Hi everybody!
What I'm trying to do is to manage several forms in one page, I know there are formsets, and I know how the form management works, but I got some problems with the idea I have in mind.
Just to help you to imagine what my problem is I'm going to use the django example models:
from django.db import models
class Poll(model...
Hello there,
I came across this blog entry which describes an elegant way of handling results returned from a ChoiceField to a view using a list comprehension technique - one that eliminates empty keys/values without all the intermediate data structures. This particular approach doesn't seem to work for MultipeChoiceFields, though. Is t...
Hi all,
I found out that the FormWizard only __init__'s once, when the url is request by multiple users at the same time (me in 2 browsers :).
This results in the fact that my temporarily stored data on the wizard's instance is wrongfully shared between users.
I'm doing some DB hits in the second step, and based on that outcome I do a...
How can I show a busy server icon to a user for Django form post and remove it with failure or success message when a response from the background process is receive ? I cannot do the POST using javascript.
Thanks
...
How can I make a Django field that renders itself as a pair of input
fields?
Reasoning: I am trying to write a new custom field. I will use it for a
captcha-like service. The service works by requesting a question -
then receiving one and a token. The validation happens by sending the
answer along with the token. I want to write a form ...
Hey, I've searched around to do this (particularly this Q: http://stackoverflow.com/questions/1854237/django-edit-form-based-on-add-form) but I just can't get it to work.
The problem I'm having is that the form always creates a new object, instead of modifying the existing one.
This is my code:
def new_task(request, task_id=None):
if...
I've found a similar question here, but I'm looking for more general solutions.
As it is now, when Django generates anykind of HTML for you (this mainly happens when generating forms), it uses self-closing tags by default i.e. <br /> instead of <br>. <br /> is valid XHTML and I think HTML5 also, but it's not valid HTML4.
Is there any c...
I need to detect when some of the fields of certain model have changed in the admin, to later send notifications depending on which fields changed and previous/current values of those fields.
I tried using a ModelForm and overriding the save() method, but the form's self.cleaned_data and seld.instance already have the new values of the ...
I need to create a Django FormWizard asking for the user personal data in the first step and for an image in the next step(there are more steps asking for personal data later). I can store all the data in the database except the ImageFields
I read this http://code.djangoproject.com/ticket/7439 , I apply the suggested patch to my django...
Hello
I have 3 forms at the same page and each has a different form submit. Such as:
<h1>Address</h1>
<form method="post" id="adress_form" action=/profile/update/>
{{ form_address.as_p }}
<p><button type="submit">Save</button></p>
</form>
<h1>Email Change</h1>
<form method="post" id="email_form" action=/profile/update/>
{{ form_email...
Hi I have an array of checkboxes e.g.
<input type="checkbox" name="checks[]" value="1" />
<input type="checkbox" name="checks[]" value="2" />
<input type="checkbox" name="checks[]" value="3" />
<input type="checkbox" name="checks[]" value="4" />
How do I access these in the view.py if more than one is selected?
I have tried
request...