Hi,

I learned django during the last days. Here are my impressions
and some questions.

Background: I develop web applications with python since 6 years.
First with Zope, then with quixote and ZODB. 

I am missing a CurrencyField. It could be a subclass of FloatField
but with a currency symbol. (100,00 *Eur*)

First I missing a way to sync the database with the model. The command
syncdb has a bad name. It should be called initdb. But you can live
without autosync: Redirect the output of sqlall to a file. Update model, 
redirect the output again, and then "diff old.sql new.sql" shows
you what you need to execute in a sql shell (ALTER TABLE ... (ALTER|DROP|ADD) 
COLUMN ...)

I am sorry, but I don't like the template language. I have no problem to
have HTML in python code. The newforms.form_for_model() and form_for_instance
are cool. I missed a complete example for creating and modifying an object.
Here is how I did it:

# WFBA Imports
from wfba.models import MyObject
from wfba.views import base

def myobject(request, object_id):
    # HTTP Basic Auth has already happened
    user=User.objects.get(username=request.environ["REMOTE_USER"])
    form=request.POST
    if not form:
        form=None
    if object_id=="add":
        MyObjectForm=forms.form_for_model(MyObject)
        title="Create new MyObject"
    else:
        myobject=MyObject.objects.get(id=object_id)
        MyObjectForm=forms.form_for_instance(myobject)
        title="MyObject Nr. %d" % myobject.id
    af=MyObjectForm(form)
    if af.is_valid():
        obj=af.save()
        return django.http.HttpResponseRedirect(obj.get_absolute_url())

    if object_id=="add":
        af.fields["user"].initial=user.id
        af.fields["status"].initial="new"
        
    return django.http.HttpResponse('''
       %s
       <form action="%s" method="post">
        <table border="1">
         %s
        </table>
        <input type="submit" value=" Save ">
       </form>
       %s
     ''' % (
        base.header(request, title),
        request.path,
        af.as_table(),
        base.footer()))

But: This form does not look as goog as the admin interface.
Example: A DateField does not have the Calendar Popup. I found no
way to add this (class="vDateField").

If I understood it right, you should set null=True for FloatField and 
DateField (and not blank=True) if it is optional. The newforms library
does not handle this correct. If there is no blank=True in the model,
it complains (ignores null=True). If I use blank=True the sql insert fails,
since the empty string is not a valid date.

Newforms: I like the as_table() output. Except: The errors should be in a
third column: <td>...</td>.

I am missing an (epydoc) API documentation. Some important methods (e.g. 
Model.save()) don't have a docstring!

I use the unicode branch and there were only some minor problem, which I fixed 
with two small patches (added to Trac). But USE_I18N must not be set to
true. If I do, I get errors, which I could not fix myself.

Back to templates: I might use templates, if I could make function calls with
arguments. I just want to pass the request object to my method. I found no way 
to do this. Yes, I know you can create own tags, but that's too complicated.

TEMPLATE_STRING_IF_INVALID: The zen of python: "Errors should never pass 
silently.". I want an exception if the template can't resolve a variable.

I already ordered the django book. 

Model.get_FOO_display(): I think two different namespaces get together, which 
should better be seperated. Model.fields.FOO.display() would be better. Some
fields don't have this method. This would make a loop over all fields and 
display them much easiert.

Introspection: How to get all fields of a model instance? I discovered 
obj._meta.fields. Is this an offical API?


Admin Template (Table of all rows):
   {% for result in results %}
    <tr class="{% cycle row1,row2 %}">
     {% for item in result %}{{ item }}{% endfor %}
    </tr>
   {% endfor %}
How can you do the same with python code?

Nevertheless I like django a lot. Maybe some parts can get fixed before 1.0.

 Thomas



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to