[Not quite sure where the right place is to post this]
The general problem is that I would like to change the default output of
forms across my site to have a consistent presentation that isn't of one
as_p(), as_table(), or as_ul(). What I wanted to do was to add a quick
function as_div() as a mixin helper class that would give me standard
output across all of the forms on my site.
The challenge - Forms allow for some level of customization, but only
via the self._html_output(...) operation, turns out that when you dig
into this you run into two problems.
1. The only way to create forms is with formatted print specifiers,
which don't allow for "optional" tag generation based on
information availability (e.g. errors, help)
2. If you wanted to create your own _html_output() method -- via
cut-n-paste -- you quickly discover that class BoundForm() is not
exported from django.forms. Which means that you now need to
cut-n-paste that out as well.
Proposal - Allow for the extension (mixin) of the forms via the
following methods:
def _gen_normal(self, normal_row, **kwargs) :
return normal_row % kwargs
def _gen_error(self, error_row, toperrors) :
return error_row % force_unicode(toperrors))
.. inside _html_output(...) change the formated prints to things like ..
output.append(self._gen_normal(errors=force_unicode(bf_errors),
label= force_unicode(label),
field= unicode(bf),
help_text= help_text,
html_class_attr=
html_class_attr))
output.insert(0, self._gen_error(error_row, top_errors))
That way if you wanted to have custom output for a form you could write
something like:
def _gen_normal(self, **kwargs) :
parts = [
u'' % kwargs,
u'%(label)s%(errors)s%(field)s' % kwargs,
]
if kwargs['help_text'] :
parts.append('%s' %
kwargs['help_text'])
parts.append('')
return ''.join(parts)
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
I'm doing that in a few other place (setting the page title, for
example). The problem is that I would like to have the extended inside
of a block and potentially conditionally (e.g. only include this
JavaScript if you're not logged in).
--koblas
On 4/21/10 4:29 PM, Tim Shaffer wrote:
Can you put the whole script tag in a block?
= template.html =
{% block extra-js %}
{% endblock %}
= base.html =
{% block extra-js %}{% endblock %}
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
I ask this question knowing that it's almost anti-django template
patterns, but I ask after spending the last few hours trying to figure a
way to shoe horn this functionality in. The basic idea is that I would
like to say something like this:
{% extends "base.html" %}
{% block content %}
{% extendgroup javascript "foo.js" %}
{% extendgroup javascript "bar.js" %}
... more block content ...
{% endblock %}
=== base.html
...
{% extendgroup javascript %}
{% endextendgroup %}
I've attempted to attache the list of javascript files to
Node -- cant' since there is no Signal for begin template rendering
parser -- wrong lifecycle
context -- the extend block is rendered with some local variables.
The only thing left is to promote "extendgroup" to be the parallel to
"extends" and render it's children... Though this really isn't my goal.
Any suggestions or other thoughts of how a template can append to a list
of resources to be used.
--koblas
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
I'm trying to get a better understanding of django performance in a
production setting.
Specifically I've seen notes that say that operations like sending mail
will block all production traffic to your server for the duration of the
send. That got me thinking about other backend calls, like sending
email call external URLs etc? Just to make it very specific:
Is there any difference in the performance in a django application between:
* A MySQL call that takes 0.1 seconds
* Sending email to your local server that takes 0.1 seconds to complete
* Making a urllib.open() call that takes 0.1 seconds
My general understanding is that all three are equal in terms of the
performance impact on your site yielding a theortical performance of 10
pages / second.
Is this right, or is there some magic that makes MySQL "better" than
just a urllib call.
--koblas
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
Just currious what people are doing for "best practices" in the realm of
building apps.
Specifically I have a tendency to create a lot of "one-off" websites
(e.g. Django App) and use a few standard apps across all of them. What
catches me up all of the time is naming systems.
If I was to create a new website "flow" my general tendency would be to
end up with an directory structure like this:
.../app
/flow/
/registration/
/etc../
.../lib/
...
Also, while I'm asking, though I've not yet done it this way, in the top
level urls.py file, is there any reason not to do something like:
(r'^registration/', include('registration.urls')),
(r'^', include('flow.urls')),
To move everything up to the top level?
Thanks,
--koblas
--~--~-~--~~~---~--~~
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
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---
Just to add my $0.02 cents to this, I too would like a better way to
extend django.contrib.auth.models.User than the current approach. The
two biggest "problems" that I have are:
* Everything depends on django.contrib.auth.models.User -- which means
that while you could swap out your authenticator you still basically
have to go and rip apart everybody's applications to support your user
object.
* To the above point, it also means that to construct your own User
object means you can't use contrib.admin since it depends on the User
object.
What would be really nice is to have something like:
django.auth.interface.User
Which in turn would instantiate something from settings.USER_MODEL
(default contrib.auth.modes) this might mean you could subsume
AUTH_PROFILE_MODULE into the USER_INSTANCE for most developers. Up shot
is that I can now still use public applications and the admin system,
but now somebody can just create a "facebook.models.User" class that
mirrors using facebook as the authenticator and get everything for free...
--koblas
Dana wrote:
> Hello All,
>
> I am looking to create a user model that extends the Auth "User"
> model, like how James Bennett outlines in his article "Extending the
> User Model" [1] by creating a FK to the "User" model and everything is
> going fine other than one issue.
>
> I would like to make "email" become the unique field and not need
> "username" when creating user accounts. Now, I don't mind using
> username for the Django admin, but for my own user section on the
> front end I want people creating accounts/logging in using an email. I
> am wondering if there is any clear way of doing this without having to
> roll my own auth app?
>
> I played with the idea of having my "save()" function create a random
> username when saving but that is obviously an ugly solution. Is there
> an easier way to do this that I am overlooking?
>
> Thanks for all your time!
> Dana W
>
> [1] http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/
> >
>
--~--~-~--~~~---~--~~
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
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---
I've recently discovered FormWizard -- trying to replace my own "Wizard"
in some code.
I've got the following flow -- roughly :
1) authentication info (username/password)
2) use auth info to get a list of things -- present list in choice
field...
3) given that choice, present another list -- technically optionally
[there might be only one choice]
The problem is that FormWizard creates a new object everytime you call
get_form(), so the ability to populate the choices field in step #2 is
defeated.
has anybody worked around this problem, or did I miss something?
--koblas
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
I'm not sure if this is possible to do without writing a templatetag
(ok, that's my theory).
Basic idea is that I have a tree structure that I want to render into a
template, the one example that I found pre-rendered a template into a
template variable and then rendered it into the page.
What I would really like to be able to do is something akin to:
...html...
{% render node %}
{% render children %}
html...
Any quick answers, before I spend the afternoon figuring out if a
template tag is going to work?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
13 matches
Mail list logo