As an example i wanted to have the username editable inside the profile. Since the Django default user doesnt have a foreign key to profile i cant just use an inline admin for the user model, so my next idea was to solve it with properties just getting from and saving to the related user model.
Am Mittwoch, 14. Februar 2018 13:54:30 UTC+1 schrieb Gonzalo Delgado: > > On 14/2/18 08:05, Andy wrote: > > Im trying to have a custom admin that is also able to edit some model > > properties, but putting those properties into my fieldsets its > complaining > > What would mean to edit a property (assuming this means an attribute > that isn't a model field) in your app? Where would the data go? > > > Unknown field(s) (foo, bar) specified for Profile. Check > fields/fieldsets/exclude attributes of class ProfileAdmin. > > The properties work in list_display, but im missing something for the > edit page. > > > The Django admin will look only for Django fields in the edit forms, > that's why you're getting the errors. > Since list_display is only for showing data, it will display any > attribute in your model. > > > Can i actually do this? So far i didnt find any hint on editing > properties with the admin. > > What you can do is use a custom model form and add fields to it for the > attributes you want to be able to "edit", but you'll also need to define > what happens with the data either in the custom form class itself, or in > the ModelAdmin class by extending the change_view method. > > See the documentation for details: > > https://docs.djangoproject.com/en/2.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.form > > > -- > Gonzalo Delgado > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to email@example.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2c65aa7c-3695-49dd-8769-a5b940997917%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.