django form
is anybody know how to log the username who is currently loged in in form.py ...
is anybody know how to log the username who is currently loged in in form.py ...
I need to perform a range of simple calculations on an Invoice model object, which has a number of Order children associated with it that hold the order quantity and order value etc. This is all managed through the admin form for Invoice (with order as inlines) The code I'm working with now performs these calcs like this: Invoice (mod...
I am writing an app for a simple survey. For possible answers I need "Yes/Now", "1 out of 1 to 5", and a short text In the admin it should be selectable, what kind of answer should be given. My models: from django.db import models from django.contrib.contenttypes.models import ContentType CHOICES=((1,'excactly true'),(2,'mostly true...
I would like to override (create custom) widgets/foreign.html template for a ForeignKey field but can't find this in the source. Browsing the Django SVN respository I can find these files at revision: 7966, but they are removed after this revision; http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/templates/widget?...
Hi I have a Django form which I'm validating in a normal Django view. I'm trying to figure out how to extract the pure errors (without the HTML formatting). Below is the code I'm using at the moment. return json_response({ 'success' : False, 'errors' : form.errors }) With this, I get the infamous proxy object e...
I need a model field composed of a numeric string for a Django app I'm working on and since one doesn't exist I need to roll my own. Now I understand how "get_db_prep_value" and such work, and how to extend the Model itself (the django documentation on custom model fields is an invaluable resource.), but for the life of me I can't seem ...
2 questions: How can I stop duplicates from being created when parent=None and name is the same? Can i call a model method from within the form? Please see full details below: models.py class MyTest(models.Model): parent = models.ForeignKey('self', null=True, blank=True, related_name='children') name = models.CharField(max...
@render_to('edit_operation.html') def edit_operation(request, pk): from forms import OpBaseForm, OperationForm from django.forms.models import inlineformset_factory op = Operation.objects.get(pk=pk) OpBaseFormSet = inlineformset_factory(Operation, OpBase, form=OpBaseForm, extra=5, ) if request.method == "POST": form = Oper...
I have two models that looks like this: class RouteBase(models.Model): base = models.ForeignKey("Base") route = models.ForeignKey("Route") sequence = models.IntegerField() class Route(models.Model): bases = models.ManyToManyField("Base", through="RouteBase", blank=True) description = models.TextField(blank=True) #and a few oth...
How do you fix the following Django bug when working with forms? TypeError at /url/ argument of type 'WSGIRequest' is not iterable ...
This is how I went about, to display a Boolean model field in the form as Radio buttons Yes and No. choices = ( (1,'Yes'), (0,'No'), ) class EmailEditForm(forms.ModelForm): #Display radio buttons instead of checkboxes to_send_form = forms.ChoiceField(choices=choices,widget=forms.RadioSelect) class Me...
I have a simple Django Form: class testForm(forms.Form): list = forms.CharField() def getItems(self): #How do I do this? Access the data stored in list. return self.list.split(",") #This doesn't work The list form field stores a csv data value. From an external instance of testForm in a view, I want to be able to look a...
Django lets you create a model foreign-keyed to User and define it in settings as the official "profile" model holding additional data for user accounts. django-profiles lets you easily display/create/edit that profile data. But the user's primary email address is part of their main account, not part of their extended profile. Therefore ...
After being dissatisfied with the existing solutions I wrote an OpenId provider for Django. If now somebody wants to authenticate himself somewhere as http://tejp.de/users/abc/ and needs to login for that, I want to display the login form with the username preset to "abc". The standard functions like redirect_to_login don't seem to prov...
I am making a model in which i have a filefield.I wan to store file content in the DB column instead of file path.ANy suggestions ...
I have a Django app that has activities and objects that have foreign keys to the User object that is defined in django.contrib.auth.models. In doing this, I get the username property of the user, which is the login id. Since the User object stores the full name, how do I make a ChoiceField on an form display the full names of the user...
I have a model: from django.db import models CHOICES = ( ('s', 'Glorious spam'), ('e', 'Fabulous eggs'), ) class MealOrder(models.Model): meal = models.CharField(max_length=8, choices=CHOICES) I have a form: from django.forms import ModelForm class MealOrderForm(ModelForm): class Meta: model = MealOrder A...
I have this model: class Aircraft(models.Model): model = models.CharField(max_length=64, blank=True) type = models.CharField(max_length=32) extra = models.CharField(max_length=32, blank=True) manufacturer = models.CharField(max_length=32) engine_type = models.IntegerField("Engine Type", choices=ENGINE_TYPE, default=0) cat_class...
Hello, I would like a form to be invalid without raising a ValidationError in any of the form's or form's field's clean methods. The reason for this is that the form is the "super form" for a set of "sub forms", and I want the super form to be invalid when any of its subforms are invalid. But this invalidity does not entail raising a ...
I have a Django form that uses a different number of fields based on the year/month. So I create the fields in the form like this: for entry in entry_list: self.fields[entry] = forms.DecimalField([stuffhere]) but now I don't know how to get the submitted data from the form. Normally I would do something like: form.cleaned_data["...