in django, django's update_object general perspective correct forms hereditary models?


in django, given excerpts an concentration animals likeso:



a animals/models.py with:



from django.db import models
from django.contrib.contenttypes.models import contenttype

class animal(models.model):
content_type = models.foreignkey(contenttype,editable=false,null=true)
name = models.charfield()

class dog(animal):
is_lucky = models.booleanfield()

class cat(animal):
lives_left = models.integerfield()


and an animals/urls.py:



from django.conf.urls.default import *

from animals.models import animal, dog, cat

dict = { 'model' : animal }

urlpatterns = (
url(r'^edit/(?p<object_id>\d+)$', 'create_update.update_object', dict),
)


how general views correct dog and/or cat controlling same form?



i.e. form vigilant upheld animals/animal_form.html animal, so won't enclose any specifics subsequent classes dog cat. i have django automatically pass form child category animal/animals_form.html?



incidentally, i'm controlling contenttype management, animal have slight named as_leaf_class advantage subsequent class.



clearly, emanate forms any subsequent class, nonetheless that's definitely lot low duplication (as templates general -- radically {{ form.as_p }}).



incidentally, it's best assume animal substantially several separate bottom classes same problem, an ideal fortitude generic.



thank lay help.



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members