How to use get_fieldsets method in Kiwi

Best Python code snippet using Kiwi_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...80 ContactsInlineAdmin,81 ImageInlineAdmin,82 LinkInlineAdmin83 )84 def get_fieldsets(self, request, obj=None):85 full_fieldsets = [86 ('Сведения о застройщике', {'fields': (87 'name',88 'created_at',89 'description',90 'objects_delivered',91 'objects_under_construction'92 )}),93 ('Административная информация', {'fields': (94 'updated_at',95 'updated_by'96 )})97 ]98 self.fieldsets = full_fieldsets99 return super().get_fieldsets(request, obj)100 def save_model(self, request, obj, form, change):101 obj.updated_by = request.user102 return super().save_model(request, obj, form, change)103@register(base.Region)104class RegionAdmin(ModelAdmin):105 fields = ['name']106 list_display = ['name']107 search_fields = [108 'name'109 ]110@register(base.ConstructionTech)111class ConstructionTechAdmin(ModelAdmin):112 fields = ['name']113 search_fields = [114 'name'115 ]116@register(base.PremisesType)117class PremisesTypeAdmin(ModelAdmin):118 fields = ['name']119 search_fields = [120 'name'121 ]122@register(base.ObjectClass)123class ObjectClassAdmin(ModelAdmin):124 fields = ['name']125 search_fields = [126 'name'127 ]128@register(complexes.Complex)129class ComplexAdmin(ModelAdmin):130 list_display = (131 'id',132 '__str__',133 'updated_by',134 'updated_at',135 )136 readonly_fields = ['updated_by', 'updated_at']137 search_fields = [138 '__all__'139 ]140 inlines = (141 LayoutInlineAdmin,142 LinkInlineAdmin,143 ImageInlineAdmin,144 DocumentInlineAdmin,145 ContactsInlineAdmin,146 TagInlineAdmin147 )148 def get_fieldsets(self, request, obj=None):149 full_fieldsets = [150 ('Сведения о ЖК', {'fields': (151 'name',152 'region',153 'address',154 'developer',155 'near_metro',156 'description',157 'start_of_construction',158 'end_of_construction',159 'construction_tech',160 'premises_type',161 'object_class',162 'count_lots',163 'count_floors',164 'infrastructure',165 'transport_accessibility',166 'reward'167 )}),168 ('Детали', {'fields': (169 'trim',170 'facade',171 'elevators',172 'windows',173 'ventilation',174 'conditioning'175 )}),176 ('Юридические детали', {'fields': (177 'cadastre',178 'tax',179 'content',180 'contract',181 'ceilings',182 'parking',183 'parking_price',184 'trade_registration',185 'mortgage',186 'installment',187 'promotions',188 'complex_infrastructure',189 'commercial_space'190 )}),191 ('Закрытые для клиента данные', {'fields': (192 'weekdays_from',193 'weekdays_to',194 'weekend_form',195 'weekend_to',196 'sales_office_address',197 'note',198 'parking_close'199 )}),200 ('Административная информация', {'fields': (201 'updated_at',202 'updated_by'203 )})204 ]205 self.fieldsets = full_fieldsets206 return super().get_fieldsets(request, obj)207 def save_model(self, request, obj, form, change):208 obj.updated_by = request.user209 return super().save_model(request, obj, form, change)210@register(complexes.Floor)211class FloorAdmin(ModelAdmin):212 list_display = (213 'id',214 '__str__',215 'updated_by',216 'updated_at',217 'image_tag'218 )219 readonly_fields = ['updated_by', 'updated_at', 'image_tag']220 search_fields = [221 '__all__'222 ]223 def get_fieldsets(self, request, obj=None):224 full_fieldsets = [225 ('Информация по этажу', {'fields': (226 'name',227 'plan',228 'image_tag'229 )}),230 ('Административная информация', {'fields': (231 'updated_at',232 'updated_by'233 )})234 ]235 self.fieldsets = full_fieldsets236 return super().get_fieldsets(request, obj)237 def save_model(self, request, obj, form, change):238 obj.updated_by = request.user239 return super().save_model(request, obj, form, change)240@register(complexes.Corp)241class CorpAdmin(ModelAdmin):242 list_display = (243 'id',244 '__str__',245 'updated_by',246 'updated_at',247 )248 search_fields = [249 '__all__'250 ]251 readonly_fields = ['updated_by', 'updated_at']252 inlines = (253 LayoutInlineAdmin,254 )255 def get_fieldsets(self, request, obj=None):256 full_fieldsets = [257 ('Информация по этажу', {'fields': (258 'name',259 'complex',260 'start_of_construction',261 'end_of_construction',262 'premises_type',263 'count_lots',264 'count_floors'265 )}),266 ('Административная информация', {'fields': (267 'updated_at',268 'updated_by'269 )})270 ]271 self.fieldsets = full_fieldsets272 return super().get_fieldsets(request, obj)273 def save_model(self, request, obj, form, change):274 obj.updated_by = request.user275 return super().save_model(request, obj, form, change)276class LotAdmin(ModelAdmin):277 list_display = (278 'id',279 '__str__',280 'updated_by',281 'updated_at',282 )283 search_fields = [284 '__all__'285 ]286 readonly_fields = ['updated_by', 'updated_at']287 inlines = (288 ImageInlineAdmin,289 LinkInlineAdmin,290 DocumentInlineAdmin,291 ContactsInlineAdmin,292 TagInlineAdmin293 )294 def save_model(self, request, obj, form, change):295 obj.updated_by = request.user296 return super().save_model(request, obj, form, change)297@register(lots.Plan)298class PlanAdmin(ModelAdmin):299 list_display = (300 'id',301 '__str__',302 'updated_by',303 'updated_at',304 'image_tag'305 )306 readonly_fields = ['updated_by', 'updated_at', 'image_tag']307 search_fields = [308 '__all__'309 ]310 def get_fieldsets(self, request, obj=None):311 full_fieldsets = [312 ('Информация по этажу', {'fields': (313 'name',314 'plan_floor',315 'plan',316 'image_tag'317 )}),318 ('Административная информация', {'fields': (319 'updated_at',320 'updated_by'321 )})322 ]323 self.fieldsets = full_fieldsets324 return super().get_fieldsets(request, obj)325 def save_model(self, request, obj, form, change):326 obj.updated_by = request.user327 return super().save_model(request, obj, form, change)328@register(lots.NewBuildingLot)329class NewBuildingLotAdmin(LotAdmin):330 def get_fieldsets(self, request, obj=None):331 full_fieldsets = [332 ('Общая информация', {'fields': (333 'status',334 'complex',335 'lease',336 )}),337 ('Информация по лоту', {'fields': (338 'name',339 'n_on_price',340 'type_object',341 'corp',342 'floor',343 's',344 'trim',345 'view_from_windows',346 'options',347 'reward',348 'currency',349 'price',350 'comment',351 'plan'352 )}),353 ('Административная информация', {'fields': (354 'updated_at',355 'updated_by'356 )})357 ]358 self.fieldsets = full_fieldsets359 return super().get_fieldsets(request, obj)360@register(lots.OldBuildingLot)361class OldBuildingLotAdmin(LotAdmin):362 def get_fieldsets(self, request, obj=None):363 full_fieldsets = [364 ('Общая информация', {'fields': (365 'status',366 'complex',367 'lease',368 )}),369 ('Информация по лоту', {'fields': (370 'name',371 'n_on_price',372 'type_object',373 'corp',374 'floor',375 's',376 'trim',377 'view_from_windows',378 'options',379 'reward',380 'currency',381 'price',382 'comment',383 'plan'384 )}),385 ('Административная информация', {'fields': (386 'updated_at',387 'updated_by'388 )})389 ]390 self.fieldsets = full_fieldsets...

Full Screen

Full Screen

admin.py

Source:admin.py Github

copy

Full Screen

1from django.contrib import admin2from database.models import *3from django.contrib.auth.admin import UserAdmin4from django.contrib.auth.models import Group5from database.forms import *678class PersonAdmin(UserAdmin):9 form = UserChangeForm10 add_form = UserCreationForm1112 list_display = (13 'id', 'first_name', 'last_name', 'phone_number', 'email_id', 'password', 'profile_picture', 'training_dataset',14 'user_since',15 'is_active', 'is_superuser',)16 list_filter = ('is_superuser', 'is_active', 'user_since',)17 fieldsets = (18 (None, {'fields': ('email_id', 'password')}),19 ('Personal info', {'fields': (20 'id', 'first_name', 'last_name', 'phone_number', 'profile_picture', 'training_dataset',)}),21 ('Permissions', {'fields': ('is_active', 'is_superuser')}),22 )23 add_fieldsets = (24 (None, {'fields': ('email_id', 'password1', 'password2',)}),25 ('Personal info', {'fields': (26 'id', 'first_name', 'last_name', 'phone_number', 'profile_picture', 'training_dataset',)}),27 ('Permissions', {'fields': ('is_active', 'is_superuser')}),28 )29 # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin30 # overrides get_fieldsets to use this attribute when creating a user.31 search_fields = ('email_id', 'id', 'first_name', 'last_name')32 ordering = ('id',)33 filter_horizontal = ()343536class YearAdmin(admin.ModelAdmin):37 list_display = ('id', 'acronym', 'year',)38 ordering = ('id',)39 # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin40 # overrides get_fieldsets to use this attribute when creating a user.41 filter_horizontal = ()424344class DepartmentAdmin(admin.ModelAdmin):45 list_display = ('id', 'acronym', 'name')46 search_fields = ('name',)47 ordering = ('id',)48 # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin49 # overrides get_fieldsets to use this attribute when creating a user.50 filter_horizontal = ()515253class SubjectAdmin(admin.ModelAdmin):54 list_display = ('code', 'name', 'initials', 'year', 'department',)55 list_filter = ('year', 'department')56 search_fields = ('code', 'name', 'initials',)57 ordering = ('code',)58 # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin59 # overrides get_fieldsets to use this attribute when creating a user.60 filter_horizontal = ()616263class StudentAdmin(admin.ModelAdmin):64 list_display = ('person', 'year', 'division', 'batch', 'department',)65 list_filter = ('department', 'year', 'division', 'batch',)66 search_fields = (67 'person__id', 'person__first_name', 'person__last_name', 'person__phone_number', 'person__email_id',)68 ordering = ('person',)69 # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin70 # overrides get_fieldsets to use this attribute when creating a user.71 filter_horizontal = ()727374class FacultyAdmin(admin.ModelAdmin):75 list_display = ('person', 'room_number', 'department',)76 search_fields = (77 'person__id', 'person__first_name', 'person__last_name', 'person__phone_number', 'person__email_id',)78 ordering = ('person',)79 # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin80 # overrides get_fieldsets to use this attribute when creating a user.81 filter_horizontal = ()828384class AdminAdmin(admin.ModelAdmin):85 list_display = ('person',)86 search_fields = (87 'person__id', 'person__first_name', 'person__last_name', 'person__phone_number', 'person__email_id',)88 ordering = ('person',)89 # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin90 # overrides get_fieldsets to use this attribute when creating a user.91 filter_horizontal = ()929394class ScheduleAdmin(admin.ModelAdmin):95 list_display = (96 'day', 'beginning_time', 'ending_time', 'department', 'year', 'division', 'batch', 'facultyName', 'subjectName',)97 ordering = ('day', 'beginning_time', 'ending_time', 'department', 'year', 'division', 'batch',)98 search_fields = (99 'faculty__initials', 'subject__initials', 'faculty__person__first_name', 'faculty__person__last_name',100 'subject__name', 'subject__code',)101 # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin102 # overrides get_fieldsets to use this attribute when creating a user.103 filter_horizontal = ()104105106class AttendanceAdmin(admin.ModelAdmin):107 list_display = ('timestamp', 'schedule', 'student', 'present', 'concession', 'modified',)108 list_filter = ('timestamp', 'present', 'concession', 'modified',)109110 ordering = ('timestamp',)111 search_fields = ()112 # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin113 # overrides get_fieldsets to use this attribute when creating a user.114 filter_horizontal = ()115116class CameraAdmin(admin.ModelAdmin):117 list_display = ('lecture_class', 'url',)118 list_filter = ()119120 ordering = ('lecture_class',)121 search_fields = ('lecture_class',)122 # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin123 # overrides get_fieldsets to use this attribute when creating a user.124 filter_horizontal = ()125126admin.site.register(Person, PersonAdmin)127admin.site.register(Student, StudentAdmin)128admin.site.register(Faculty, FacultyAdmin)129admin.site.register(Year, YearAdmin)130admin.site.register(Department, DepartmentAdmin)131admin.site.register(Subject, SubjectAdmin)132admin.site.register(Attendance, AttendanceAdmin)133admin.site.register(Schedule, ScheduleAdmin)134admin.site.register(Admin, AdminAdmin)135admin.site.register(Camera, CameraAdmin)136137admin.site.unregister(Group)138 ...

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 Kiwi 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