How to use formfield_for_dbfield method in autotest

Best Python code snippet using autotest_python

admin.py

Source:admin.py Github

copy

Full Screen

...7from django.contrib.flatpages.admin import FlatPageAdmin8from django.contrib.flatpages.models import FlatPage9from tinymce.widgets import TinyMCE10class TinyMCEFlatPageAdmin(FlatPageAdmin):11 def formfield_for_dbfield(self, db_field, **kwargs):12 if db_field.name == 'content':13 return forms.CharField(widget=TinyMCE(14 attrs={'cols': 80, 'rows': 30},15 mce_attrs={'external_link_list_url': reverse('tinymce.views.flatpages_link_list')},16 ))17 return super(TinyMCEFlatPageAdmin, self).formfield_for_dbfield(db_field, **kwargs)18 19class MainStoryAdmin(admin.ModelAdmin):20 exclude=('slug',)21 list_display = ('id','title')22 def formfield_for_dbfield(self, db_field, **kwargs):23 field = super(MainStoryAdmin, self).formfield_for_dbfield(db_field, **kwargs)24 if db_field.name == 'snippet':25 return forms.CharField(widget=TinyMCE(26 attrs={'cols': 80, 'rows': 30}))27 return field28 29class CaseStudyAdmin(admin.ModelAdmin):30 exclude=('slug',)31 list_display = ('id','title','program','slug','tags')32 def formfield_for_dbfield(self, db_field, **kwargs):33 field = super(CaseStudyAdmin, self).formfield_for_dbfield(db_field, **kwargs)34 if db_field.name == 'long_description':35 return forms.CharField(widget=TinyMCE(36 attrs={'cols': 80, 'rows': 30}))37 return field38class NewsAdmin(admin.ModelAdmin):39 exclude=('slug',)40 list_display = ('id','title','program','slug','tags')41 def formfield_for_dbfield(self, db_field, **kwargs):42 field = super(NewsAdmin, self).formfield_for_dbfield(db_field, **kwargs)43 if db_field.name == 'long_description':44 return forms.CharField(widget=TinyMCE(45 attrs={'cols': 80, 'rows': 30}))46 return field47class EventsAdmin(admin.ModelAdmin):48 exclude=('slug',)49 list_display = ('id','title','program','slug','tags')50 def formfield_for_dbfield(self, db_field, **kwargs):51 field = super(EventsAdmin, self).formfield_for_dbfield(db_field, **kwargs)52 if db_field.name == 'long_description':53 return forms.CharField(widget=TinyMCE(54 attrs={'cols': 80, 'rows': 30}))55 return field56class PageAdmin(admin.ModelAdmin):57 list_display = ('id','title','slug','parent')58 exclude=('slug',)59 def formfield_for_dbfield(self, db_field, **kwargs):60 field = super(PageAdmin, self).formfield_for_dbfield(db_field, **kwargs)61 if db_field.name == 'content':62 return forms.CharField(widget=TinyMCE(63 attrs={'cols': 80, 'rows': 30}))64 return field65class ProgramAdmin(admin.ModelAdmin):66 list_display = ('id','title','slug')67 exclude=('slug',)68 def formfield_for_dbfield(self, db_field, **kwargs):69 field = super(ProgramAdmin, self).formfield_for_dbfield(db_field, **kwargs)70 if db_field.name == 'description':71 return forms.CharField(widget=TinyMCE(72 attrs={'cols': 80, 'rows': 30}))73 return field74 75class ResourceAdmin(admin.ModelAdmin):76 list_display = ('id','title','program','slug','tags')77 exclude=('slug',)78 def formfield_for_dbfield(self, db_field, **kwargs):79 field = super(ResourceAdmin, self).formfield_for_dbfield(db_field, **kwargs)80 if db_field.name == 'long_description':81 return forms.CharField(widget=TinyMCE(82 attrs={'cols': 80, 'rows': 30}))83 return field84class HeadlineAdmin(admin.ModelAdmin):85 list_display = ('id','title','slug')86 form = AdminImageForm87 exclude=('slug',)88class VideoAdmin(admin.ModelAdmin):89 list_display = ('id','title','slug')90 exclude=('slug',)91class AudioAdmin(admin.ModelAdmin):92 list_display = ('id','title','slug')93 exclude=('slug',)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful