@@ -181,6 +181,9 @@ <h4 class="title">FastAdmin</h4>
181181 < li class ="nav-item ">
182182 < a class ="nav-link " href ="#changelog "> Changelog</ a >
183183 < ul class ="nav flex-column ">
184+ < li class ="nav-item ">
185+ < a class ="nav-link " href ="#v0_1_25 "> v0.1.25</ a >
186+ </ li >
184187 < li class ="nav-item ">
185188 < a class ="nav-link " href ="#v0_1_24 "> v0.1.24</ a >
186189 </ li >
@@ -212,7 +215,7 @@ <h1>Documentation</h1>
212215 < div class ="row ">
213216 < div class ="col-sm-6 col-lg-4 ">
214217 < ul class ="list-unstyled ">
215- < li > < strong > Version:</ strong > 1.1.24 </ li >
218+ < li > < strong > Version:</ strong > 1.1.25 </ li >
216219 < li >
217220 < strong > Author:</ strong >
218221 < a href ="mailto:vsdudakov@gmail.com " target ="_blank "
@@ -393,18 +396,20 @@ <h4>Tortoise ORM</h4>
393396 hash_password = fields.CharField(max_length=255)
394397 is_superuser = fields.BooleanField(default=False)
395398 is_active = fields.BooleanField(default=False)
396-
397399 ...
400+ async def __str__(self):
401+ return self.username
398402
399403
400404class Group(Model):
401405 name = fields.CharField(max_length=255)
402406 ...
407+ async def __str__(self):
408+ return self.name
403409
404410
405411@register(User)
406412class UserAdmin(TortoiseModelAdmin):
407- label_fields = ("username",)
408413 exclude = ("hash_password",)
409414 list_display = ("id", "username", "is_superuser", "is_active")
410415 list_display_links = ("id", "username")
@@ -422,7 +427,6 @@ <h4>Tortoise ORM</h4>
422427
423428@register(Group)
424429class GroupAdmin(TortoiseModelAdmin):
425- label_fields = ("name",)
426430 list_display = ("id", "name")
427431 list_display_links = ("id",)
428432 list_filter = ("id", "name")
@@ -434,7 +438,7 @@ <h4>Django ORM</h4>
434438 < code class ="language-python ">
435439from django.db import models
436440
437- from fastadmin import DjangoModelAdmin, register, sync_to_async
441+ from fastadmin import DjangoModelAdmin, register
438442
439443
440444class User(models.Model):
@@ -443,23 +447,25 @@ <h4>Django ORM</h4>
443447 is_superuser = fields.BooleanField(default=False)
444448 is_active = fields.BooleanField(default=False)
445449 ...
450+ def __str__(self):
451+ return self.username
446452
447453
448454class Group(models.Model):
449455 name = fields.CharField(max_length=255)
450456 ...
457+ def __str__(self):
458+ return self.name
451459
452460
453461@register(User)
454462class UserAdmin(DjangoModelAdmin):
455- label_fields = ("username",)
456463 exclude = ("hash_password",)
457464 list_display = ("id", "username", "is_superuser", "is_active")
458465 list_display_links = ("id", "username")
459466 list_filter = ("id", "username", "is_superuser", "is_active")
460467 search_fields = ("username",)
461468
462- @sync_to_async
463469 def authenticate(self, username, password):
464470 obj = User.objects.filter(username=username, is_superuser=True).first()
465471 if not obj:
@@ -471,7 +477,6 @@ <h4>Django ORM</h4>
471477
472478@register(Group)
473479class GroupAdmin(DjangoModelAdmin):
474- label_fields = ("name",)
475480 list_display = ("id", "name")
476481 list_display_links = ("id",)
477482 list_filter = ("id", "name")
@@ -509,16 +514,19 @@ <h4>SQLAlchemy ORM</h4>
509514 is_superuser: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
510515 is_active: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
511516 ...
517+ async def __str__(self):
518+ return self.username
512519
513520
514521class Group(Base):
515522 name: Mapped[str] = mapped_column(String(length=255), nullable=False)
516523 ...
524+ async def __str__(self):
525+ return self.name
517526
518527
519528@register(User, sqlalchemy_sessionmaker=sqlalchemy_sessionmaker)
520529class UserAdmin(SqlAlchemyModelAdmin):
521- label_fields = ("username",)
522530 exclude = ("hash_password",)
523531 list_display = ("id", "username", "is_superuser", "is_active")
524532 list_display_links = ("id", "username")
@@ -540,7 +548,6 @@ <h4>SQLAlchemy ORM</h4>
540548
541549@register(Group, sqlalchemy_sessionmaker=sqlalchemy_sessionmaker)
542550class GroupAdmin(SqlAlchemyModelAdmin):
543- label_fields = ("name",)
544551 list_display = ("id", "name")
545552 list_display_links = ("id",)
546553 list_filter = ("id", "name")
@@ -553,7 +560,7 @@ <h4>Pony ORM</h4>
553560import bcrypt
554561from pony.orm import Database, PrimaryKey
555562
556- from fastadmin import PonyORMModelAdmin, register, sync_to_async
563+ from fastadmin import PonyORMModelAdmin, register
557564
558565db = Database()
559566db.bind(provider="sqlite", filename="db.sqlite", create_db=True)
@@ -566,27 +573,29 @@ <h4>Pony ORM</h4>
566573 is_superuser = Required(bool, default=False)
567574 is_active = Required(bool, default=False)
568575 ...
576+ def __str__(self):
577+ return self.username
569578
570579
571580class Group(db.Entity):
572581 id = PrimaryKey(int, auto=True)
573582 name = Required(str)
574583 ...
584+ def __str__(self):
585+ return self.name
575586
576587
577588db.generate_mapping()
578589
579590
580591@register(User)
581592class UserAdmin(PonyORMModelAdmin):
582- label_fields = ("username",)
583593 exclude = ("hash_password",)
584594 list_display = ("id", "username", "is_superuser", "is_active")
585595 list_display_links = ("id", "username")
586596 list_filter = ("id", "username", "is_superuser", "is_active")
587597 search_fields = ("username",)
588598
589- @sync_to_async
590599 @db_session
591600 def authenticate(self, username, password):
592601 user = next((f for f in self.model_cls.select(username=username, password=password, is_superuser=True)), None)
@@ -599,7 +608,6 @@ <h4>Pony ORM</h4>
599608
600609@register(Tournament)
601610class GroupAdmin(PonyORMModelAdmin):
602- label_fields = ("name",)
603611 list_display = ("id", "name")
604612 list_display_links = ("id",)
605613 list_filter = ("id", "name")
@@ -914,12 +922,6 @@ <h3>ModelAdmin options</h3>
914922 < p class ="lead "> Specific options:</ p >
915923 < pre >
916924 < code class ="language-python ">
917- # Labels for model. We use them in select, autocomplete and other wigets where we represent model items.
918- # We user first from label_fields, if it is empty, we use the second and so on.
919- # If you don't set this attribute, we will use id attr as label.
920- # Example of usage: label_fields = ("name", "email", "id")
921- label_fields: Sequence[str] = ()
922-
923925 # Use list_display_links to control if and which fields in list_display should be linked to the “change” page for an object.
924926 # Example of usage: list_display_links = ("id", "mobile_number", "email")
925927 list_display_links: Sequence[str] = ()
@@ -1235,7 +1237,6 @@ <h2>InlineModelAdmin objects</h2>
12351237
12361238@register(Author)
12371239class AuthorAdmin(TortoiseModelAdmin):
1238- label_fields = ("name",)
12391240 inlines = (
12401241 BookInline,
12411242 )
@@ -1355,15 +1356,24 @@ <h2>Changelog</h2>
13551356 < hr class ="small-divider " />
13561357 <!-- <p class="alert alert-info mb-5"> For Future Updates Follow Us <a target="_blank" href="http://themeforest.net/user/harnishdesign?ref=HarnishDesign">@themeforest</a> / <a target="_blank" href="http://facebook.com/harnishdesign">@facebook</a> / <a target="_blank" href="http://twitter.com/harnishdesign">@twitter</a> / <a target="_blank" href="https://dribbble.com/harnishdesign">@Dribbble</a></p> -->
13571358
1359+ < h3 id ="v0_1_25 ">
1360+ Version 0.1.25
1361+ < small class ="text-muted "> (25 March, 2024)</ small >
1362+ </ h3 >
1363+ < ul class ="changelog ">
1364+ < li > Fixed inlines api.</ li >
1365+ < li > Fixed label fields.</ li >
1366+ < li > Fixed inlines frontend side.</ li >
1367+ </ ul >
1368+ < hr class ="small-divider " />
1369+
13581370 < h3 id ="v0_1_24 ">
13591371 Version 0.1.24
13601372 < small class ="text-muted "> (25 March, 2024)</ small >
13611373 </ h3 >
13621374 < ul class ="changelog ">
1363- < li >
1364- Fixed a bug with inline fk_name field. Added pydantic as
1365- dependency.
1366- </ li >
1375+ < li > Fixed a bug with inline fk_name field.</ li >
1376+ < li > Added pydantic as dependency.</ li >
13671377 </ ul >
13681378 < hr class ="small-divider " />
13691379
0 commit comments