You cannot directly register a form with admin, you should be registering models
from myapps.forms import MyModelForm from myapps.models import MyModel class MyModelAdmin(admin.ModelAdmin): form = MyModelForm admin.site.register(MyModel, EmailAdmin) Also the form should be a ModelForm for that model. from django.forms import ModelForm # Create the form class. class MyModelForm(ModelForm): class Meta: model = MyModel Read the docs thoroughly, especially: http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#modelform http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#ref-contrib-admin On Mar 10, 10:28 pm, Praveen <praveen.python.pl...@gmail.com> wrote: > Hi > I have one form in forms.py > > class EmailForm(forms.Form): > recipient = forms.CharField(max_length=14, min_length=12, > widget=forms.TextInput(attrs=require)) > message = forms.CharField(max_length=140, min_length=1, > widget=forms.Textarea(attrs={'cols': 30, 'rows': 5})) > > and my site url is > admin.autodiscover() > urlpatterns = patterns('', (r'^admin/(.*)', > include(admin.site.urls)),) > > now i want it to be shown on admin interface > > I tried so far > First attempt > > from myapps.forms import EmailForm > class EmailAdmin(admin.ModelAdmin): > form = EmailForm > did not work Exception Value: > 'DeclarativeFieldsMetaclass' object is not iterable > > Second attempt > and now i > followedhttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri... > but could not get help > > class EmailAdmin(admin.ModelAdmin): > def my_view(self,request): > return admin_my_view(request,self) > > def get_urls(self): > urls = super(SmsAdmin, self).get_urls() > my_urls = patterns('',(r'^my_view/ > $',self.admin_site.admin_view(self.my_view))) > return my_urls + urls > > def admin_my_view(request, model_admin): > opts = model_admin.model._meta > admin_site = model_admin.admin_site > has_perm = request.user.has_perm(opts.app_label \ > + '.' + opts.get_change_permission()) > context = {'admin_site': admin_site.name, > 'title': "My Custom View", > 'opts': opts, > 'root_path': '/%s' % admin_site.root_path, > 'app_label': opts.app_label, > 'has_change_permission': has_perm} > template = 'admin/demo_app/admin_my_view.html' > return render_to_response(template, > context,context_instance=RequestContext(request)) > admin.site.register(EmailForm,EmailAdmin) > > and when i run server and type on browserhttp://localhost:8000/admin > and hit enter button > > Exception Value: > 'DeclarativeFieldsMetaclass' object is not iterable > > and second time just after first time when i again enter then it show > me the admin page but i can't see my EmailAdmin in admin intercae.. > > Just help me or suggest me any link. > > Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.