Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Outlet(models.Model):
- a = models.CharField(max_length=253, primary_key=True, db_index=True)
- def _split(self, idx):
- if not self.a:
- return None
- return self.a.split(".")[idx]
- @property
- def b(self):
- return self._split(0)
- @property
- def c(self):
- return self._split(1)
- @admin.register(Outlet)
- class OutletAdmin(admin.ModelAdmin):
- fields = ("a", "b", "c")
- readonly_fields = ("b", "c")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement