mardi 26 août 2014

Creating front-end forms like in Django Admin


Vote count:

0




I was curious if there was a way to replicate the Django admin interface - specifically the forms when adding an object - in the front end... Here's my scenario:



class Area(models.Model):
name = models.CharField(max_length=100)

class SubArea(models.Model):
name = models.CharField(max_length=100)
area = models.ForeignKey(Area)

class Product(models.Model):
name = models.CharField(max_length=150)
area = models.ForeignKey(Area, null=True, blank=True)
subarea = models.ForeignKey(SubArea, null=True, blank=True)


So If I setup a form in the frontend for the Product model, I have no way of adding Area or SubArea objects. In the Django admin, however, I'm able to easily add these objects by clicking the "+" next to the fields.


I am looking for the easiest possible solution (while still being secure) to allow for fronted creating of the Foreign Keys without having to setup separate forms. Not sure if that is even possible, but wanted to reach out to the community for advice.


Thanks! J



asked 43 secs ago







Creating front-end forms like in Django Admin

Aucun commentaire:

Enregistrer un commentaire