views:

35

answers:

2

I made a simple project named "employee" with an "info" app.

When I add a new employee the fields comes one below the other, like this:

name:____

eno:____

phone1:____

phone2:____

How can I get the output to be like this:

name:____

eno:____

phone1:________________ phone2:____________
A: 

In your template set up the boxes for the fields however you like (tables, CSS, etc.), then use {{ form.fieldname }} to display only the HTML for the form input.

Ignacio Vazquez-Abrams
+1  A: 

Since you say "when I add a new employee," I assume you're talking about in the Django admin?

In that case, you need to set the "fieldsets" attribute of your ModelAdmin subclass, and wrap those two fields inside a tuple. Something like this in your admin.py:

class EmployeeAdmin(admin.ModelAdmin):
    fieldsets = ((None, {'fields': ('name', 'eno', ('phone1', 'phone2'))}),)
Carl Meyer
You can do an amazing amount of customizing within the Django admin environment, but you've got to read the docs. Does SO need some sort of big, red RTFM button that can be linked to answers that are plainly given in the original docs?
Peter Rowell