views:

372

answers:

1

Hi guys, i dont know how ill ask this, im new with Django, but ill try.

I have a form in the private user section, well this form save the username logged, a encrypted data from another function, and some more fields.

Now my problem is that in the Admin, i need to use "this form" too, but i dont know how render the form in different way, for example, in the private user section i dont display "x" field, but in the Admin the "x" field is showing.

i dont know if im clear of if my poor English let me explain

but i want to know how ill show in some part of my website (private o public) a form and in the Admin section show the same form in different way...

and in the same way guys, (im sorry with my question's), i want to know how use the function SAVE (overriding??)

if somebody have a link with example :)

Thanks :)

+3  A: 

You can make amendments to the way things display in the admin forms by doing something similar to :-

from myproject.myapp.models import Event
from django.contrib import admin

class EventAdmin(OccasionAdmin):
    fieldsets = [
        (None,                  {'fields':  ['title', 'description', 'venue']}),
        ('Date Information',    {'fields':  ['start', 'end']}),
        ('Options',             {'fields':  ['moderated', 'promoted']}),
        ('Users',               {'fields':  ['creator', 'owner']}),
    ]

admin.site.register(Event, EventAdmin)

As I don't mention the fields I don't want to display here (autogenerated slugs, mainly!), they don't show.

If you don't want this field to be editable anywhere, then define the field as non-editable

slug = Models.SlugField(editable=False)

But make sure you auto-generate it, or set it as:-

slug = Models.SlugField(editable=False, blank=True)
Mez