Web development status
Julio César Carrascal Urquijo
jcesar at phreaker.net
Mon Jan 22 09:12:18 PST 2007
Antti Holvikari wrote:
> On 1/22/07, Hasan Aljudy <hasan.aljudy at gmail.com> wrote:
>> I wish we'd have a framework similar to Django, however, come to think
>> of it .. I'd rather use Django than wait for a D clone .. which I don't
>> think can be more powerful since D doesn't have any dynamic reflection
>> capabilities.
>
> Hmm, hope I'm not missing something here but why would you need
> reflection for that?
>
Django uses python's reflections capabilities to bind classes to SQL
tables and build administration interfaces in ways that I don't thing
even the compile time reflection capabilities of D can implement.
The following code taken from the Django tutorial admin interfaces for
this Master/Details model with all the features you will expect:
Pagination, searching, basic validation and form field grouping. Adding
filtering and custom validation is really easy.
from django.db import models
class Poll(models.Model):
question = models.CharField(maxlength=200)
pub_date = models.DateTimeField('date published')
class Admin:
fields = (
(None, {'fields': ('question',)}),
('Date information', {'fields': ('pub_date',)}),
)
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(maxlength=200)
votes = models.IntegerField()
class Admin:
pass
As you can see, Django uses reflection to build all of this
functionality with just some hints from the programmer.
More information about the Digitalmars-d
mailing list