0

I have a model, which has some fields stored in db. On top of it, I need to implement non-db fields, which would be loaded and saved using a custom API. Users should interact with the model using the admin interface, Grappelli is used to enhance the standard Django admin.

I am interested in one of the following:

  • Model virtual fields or properties, where I can override how to read and save custom fields. (Simple python properties won't work with Django admin)
  • Editable callables for admin (not sure if it is even possible)
  • Any other means to display and process custom fields in admin, except of creating custom forms and moving the logic into the forms.
Art
  • 2,235
  • 18
  • 34
  • I can't imagine what an "editable callable" is. Why don't you want to put the logic into the forms, though? – Daniel Roseman Oct 22 '15 at 08:08
  • Take a look on `upper_case_name` [here](https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display) However, they are always read-only, even if you use a @property with a @prop_name.setter. Forms, well, they are simply not made for it, so it's kinda violating the concepts. – Art Oct 22 '15 at 08:20
  • I think Custom Forms will be the way....also architecturally it wouldn't make sense to have non-django model fields in a django model class. What you actually want is a ViewModel which is what a CustomForm can provide you. – Chirdeep Tomar Oct 22 '15 at 08:27
  • Now I'm confused. Are you talking about editing things on the list page, or the edit detail page? – Daniel Roseman Oct 22 '15 at 08:28
  • Daniel, I want edit things on the edit page. Callables allow you only to display things, but on the both list and edit views. You can use them in both list_display and formsets. – Art Oct 22 '15 at 08:34

1 Answers1

-2

I think you can use a none-model class, which wrapper the Model class and have some extra fields, where you can set/get or save to other place

hiennt
  • 900
  • 7
  • 16