I was wondering how they made it possible to display more fields in the User page of the djagno admin site.
If you create a new User you only have some basic fields to fill in but if you reopen that user (edit mode) then you see a lot more fields to fill in.
Im trying to achieve the same, I had a look at the add_form.html template but I...
I'm trying to render a form's fields manually so that my designer colleagues could manipulate the input elements within the HTML instead of struggling in Python source.
ie. Instead of declaring form fields like this...
{{ form.first_name }}
.. I actually do ...
<label for="id_first_name">Your name:</label>...
Given a form class (somewhere deep in your giant Django app)..
class ContactForm(forms.Form):
name = ...
surname = ...
And considering you want to add another field to this form without extending or modifying the form class itself, why does not the following approach work?
ContactForm.another_field = forms.CharField(...)
(...
I have a GenericForeignKey in an inline on an admin page. Being a GenericFK there are 2 fields involved in it: The ContentType FK and the object_id integer field. The GenericFK can, of course, point to a variety of models and objects, some that have image fields and some that don't. My goal is to customize one of the widgets (it can be e...
This is actually a follow-up to a previous question.
A user's profile data is spread over several different models, like so:
# Simplified versions, actual classes contain many more fields.
class Profile(models.Model): # returned by Django's User.get_profile()
user = models.OneToOneField(User)
home_address = models.OneToOne...
I have a model like below.
class Content(SimpleModel):
title = models.CharField(max_length=255)
body = models.TextField()
slug = models.SlugField(max_length=50)
def __unicode__(self):
return self.title
class MediumStuff(models.Model):
meta_value = models.TextField()
meta_key = models.SlugField('Fie...
I use a custom auth backend in my django application that allows users to login with ther emails.
But when I try to login in the admin I get the message: "usernames cant contain the '@' char"
I suppose this error is raised before it reaches the auth backend, so its a form issue, right ?
...
so...i've been banging my head on this for a bit. I'm getting the most bizarre error when attempting to validate a form. I pass input to the form wanting to test behavior when the form fails validation, i.e. i expect it to fail validation.
i've got this code for a form:
class CTAForm(forms.Form):
first_name = forms.CharField(...
I am generating multple forms on one page using signals like:
def send_articleform(sender, form, request, type=None, nid=None, **kwargs):
if sender == 'article':
if nid == None:
if request != None:
formset = modelformset_factory(Article, form=ArticleModelForm)
form['article...
Hello, this is a Django related question. I have an invoice that I have created from a database which displays the information. Now I want to know is if I can send these details to an email address. I have tried looking at this page at http://docs.djangoproject.com/en/dev/topics/email/, but I don't know if I am looking for that. I am ass...
Hey guys.
I have a model that references a ForeignKey(User) field.
When a user selects an item on his form I would like them to be able to see the get_full_name() instead of just the username.
class Books(models.Model):
author = models.ForeignKey(User)
...
Let say I have a django ModelForm which I want to edit before saving.
For example,
Instead of this
model_instance = form.save()
I would like to do something like this
model_instance = form.get_model()
model_instance.edit() #say add a new field which is not available on form
model_instance.save()
...
Consider I have defined the following models:
class Tag(models.Model):
name = models.CharField(max_length=20)
class Entry(models.Model):
title = models.CharField(max_length=100)
date = models.DateField()
tags = models.ManyToManyField(Tag)
and the following model form:
class EntryForm(forms.ModelForm):
tags = CharField(max...
Hello everyone.
I have a small question to ask the community. I am wondering why my foreign key will not show up when I go to my edit form. When I go to edit the information, all my data is populated except for status (which is a foreignkey that points from the status table to project table), which is left with nothing selected. I ...
I have a Django (1.1) form. One of the fields is CharField with a set number of choices, this is correctly rendered as a <select> box. However the html style attribute for the <select> is set as …style="width: 100px"…. I want to conserve screen space, so I want to change this to style="width: auto", or even just remove the style attribut...
How can I send a file in django to a different server without user being redirected to the server ? So all goes to rewriting this simple php function in django :
$filename = 'C:/tmp/myphoto.jpg';
$handler = 'http://www.example.com/upload.php';
$field = 'image';
$res = send_file($filename, $handler, $field);
if ($res) {
echo 'do...
Hello everyone, I have a small problem. I am trying to check to see if status's value already exists and make sure I do not create another instance of it, but I am having some trouble. Ex. If the project status was once "Quote" I do not want to be able make the status "Quote" again. Right now, I check to make sure if the user select...
Hey everyone,
Here is my problem. I have a model Project, that has a quote field in it. When a new instance of project is created I need to append the last 2 digits of the year plus a hyphen onto the start of the "quote" field. Ex. 2010 = "10-". Im just not quite sure how to start it?
As of right now I have hard coded in "10-" in a...
Hello-
I'm new to Django and I'm creating an app to create and display employee data for my company.
Currently the model, new employee form, employee table display, login/logout, all works. I am working on editing the current listings.
I have hover on row links to pass the pk (employeeid) over the url and the form is populating correctl...
I am building a small app that looks at availability of vehicles and helps a customer book it.
in this I am making use of a form wizard that guides the user through the steps.
in the backend I am updating all the queries successfully, however I am not quite sure on how to execute one part of it.
I have two models, Quote and Vehicle
V...