On Mar 12, 10:16 am, Vincent <jellygr...@gmail.com> wrote:

> Thanks Alex.
>
> I spent the better part of my day yesterday pouring over both of those
> pages prior to posting a request for help here. I think part of the
> problem is that I only loosely understand the whole model, form, view
> paradigm and am therefore having a hard time augmenting things as I
> need to.
>
> It would be great if someone could provide me with a brief example of
> how to proceed with what I would like to do. Most importantly, I am
> not sure what file my customized form is to be entered into. Should it
> be in the admin.py file or a new form.py file? Also, I only want to
> add validation and such for one field, not change the functionality of
> the rest of the fields in the admin interface.
>
> I realize that these are really basic questions, but after looking at
> the documentation several times already, I just don't understand what
> is to go where based on what is in docs.djangoproject.com.
>
> Again, thanks.
>
> ~Vincent

After more continued poking, I seem to have got things in the correct
place.

Using the example given at docs.djangoproject.com as a starting point,
I have the following in my admin.py:

#admin.py
from snufkin.media_mngr.models import Media
from snufkin.media_mngr.forms import MyMediaAdminForm
from django.contrib import admin

class MediaAdmin(admin.ModelAdmin):
    form = MyMediaAdminForm
    fieldsets = [
        (None, {
            'fields': [('media_loc', 'is_active'), 'media_name',
'media_size',
            'media_hash']
        }),
        (None, {
            'fields': ['b_type']
        }),
    ]

admin.site.register(Media, MediaAdmin)

I then created a file called forms.py that contains the following:

#forms.py
from django import forms
from snufkin.media_mngr.models import Media

class MyMediaAdminForm(forms.ModelForm):
    class Meta:
        model = Media

    def clean_media_loc(self):
        return self.cleaned_data["media_loc"]

This all seems to work correctly or at least the admin interface still
works when I run the test server. However, obviously I'm not
validating anything at this point. I am going to continue along this
path, but if anyone would care to post some additional guidance it
would be greatly appreciated.

~Vincent
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to