Tag: newforms

Here you can see a listing of all the posts tagged with newforms on this website.

  • newforms-admin in Django's trunk and {new,}forms

    Posted on July 19, 2008 at 13:21 +0200 Tagged with , , ,

    After nearly more than a year of development Brian Rosner merged the newforms-admin branch into trunk last night. This marks the last missing branch getting merged into trunk before the 1.0 release. Big kudos and thanks to Brian and everybody else involved in the development on this branch.

    Another big change happened last night: newforms is now finally the "official" forms library for Django. At least it now resides directly within django.forms.

    Both of these changes are backwards-incompatible, yet fully documented (1, 2). For everyone running on trunk (and who hasn't been preparing for this merge) this means some work esp. if you've messed around quite a lot with oldadmin. Also some of the styling in NFA looks a little bit different than before thanks to the move away from the old form manipulator modules which added some special classes to each form-element. If it annoys you, check out #5609.

    0 comments

  • Bye form_for_*

    Posted on Dec. 31, 2007 at 01:13 +0100 Tagged with , ,

    Hmm... just noticed a big change in Django's newforms API which happened in r6844 (so basically on Dec 2nd): form_for_model and form_for_instance got deprecated in favor of the the new ModelForm class. The motivation behind this move is quite well documented on the django-dev mailinglist, but for me personally it seems to boil down to replace form_for_* with a much more declarative syntax (which is a good thing).

    So if you for instance have a model Game like this (if I understood it correctly)

    class Game(models.Model):
        name = models.CharField(max_length=150)
        ...
    

    you could easily create a form class for it like this:

    class GameForm(forms.ModelForm):
        class Meta:
            model = Game
    

    I really can't wait to actually play around with this since it just makes everything all so much more consistent :-)

    For some details checkout the new modelforms documentation page.

    0 comments

  • Customizing newforms

    Posted on June 1, 2007 at 13:09 +0200 Tagged with , ,

    You like newforms but are a little bit uncertain how to style your forms using CSS with form.as_ul? Well, if you want more CSS classes to style upon, here a simple way on how to get them the easy way.

    This mini-tutorial will show you how to add CSS classes to the help text and position the errorlist differently for fields in a newform-Form rendered with as_p() (although this also should apply to all the other rendering methods).

    [more ...]

    2 comments

  • Django's newforms and model constraints

    Posted on May 27, 2007 at 00:20 +0200 Tagged with ,

    Today I wanted to use one of Django SVN's new features: A newforms's forum for a model instance that only uses a subset of its fields (For example if a model has the fields a, b and c, you could easily create a form that only handles a and b).

    But I found a small problem: You can use such a form, to also write the data back to the database and in the process use the model's data validation and integrity checks. For some reason, only the validation is actually performed, while integrity problems still raise an IntegrityError which you'll have to deal by yourself.

    [more ...]

    0 comments