Django framework: ListView with CreateView -
i new in django programming, , have simple question.
i have model
class dhcp(models.model): class meta: ordering = ('gateway',) verbose_name = _(u'dhcp configuration') verbose_name_plural = _(u'dhcp configurations') gateway = models.ipaddressfield(_(u'gateway'), null=true) dns_primary = models.ipaddressfield(_(u'dns primary'), null=true) dns_second = models.ipaddressfield(_(u'dns second'), blank=true) leases_time = models.integerfield() nat = models.ipaddressfield(_(u'nat'), blank=true) max_time = models.integerfield() def __unicode__(self): homecoming self.gateway
and question :
and want list dhcp objects in database, , add together more object. want on same template.
for example: if have 3 objects in database, show , show form add together more obj. when add together 1 more object form, want show added object.
thanks!
dusan ristic
have class based views, more listview , createview. question comes quite often, should find reply on here somewhere. check post out.
what you're looking this:
class dhcpview(forms.createview): model = dhcp template_name = "list_and_create_dhcp.html" def get_context_data(self, **kwargs): kwargs["object_list"] = dhcp.objects.all() homecoming super(dhcpview, self).get_context_data(**kwargs)
django django-models django-forms django-templates
No comments:
Post a Comment