Easily solved the problem once I realized the difference between
HttpRequest and HttpResponse objects (doh!).
In the event another nub is looking to make stuff happen post-
successful login/logout here's the (now obvious) pseudo-code solution:
def user_login(request):
response = django.contr
There's a good writeup on template tags on B-List (with some copy-and-
pasteable sample code).
http://www.b-list.org/weblog/2006/06/07/django-tips-write-better-template-tags
Cheers.
- whiteinge
On Feb 25, 5:57 am, Dirk Eschler <[EMAIL PROTECTED]> wrote:
> On Sonntag, 25. Febru
On a semi-related note, I'd probably be able to muddle through this on
my own using the Python console, but I don't know how to fake the
'request' variable in that environment; is this easy to do?
Thanks very much,
- whiteinge
--~--~-~--~~~---~--~-
On Dec 3, 12:37 am, Bartek SQ9MEV <[EMAIL PROTECTED]> wrote:
> I know I should use cache.delete('a'), but how can I get key for
> particular fragment?
The key is 'fragment_name:additional:arguments:seperated:by:colons'.
> What is better idea? Use signals (I do not know too mouch about them
> yet
request, instance=instance)
If that's more confusing than helpful, post your code and I'll give
you a more specific example. :)
- whiteinge
.. [1]
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method
.. [2]
http://docs.djangoproject.com/en/dev/ref/con
On Jan 11, 9:53 pm, "pyramid...@gmail.com"
wrote:
> I am slightly confused with starting out
> I just want to start with the initial index page
You just need a line in your main urlconf (the one specified in your
settings.py file) that maps directly to an HTML file in your templates
directory. H
A slight variation that doesn't require repeating the whole navigation
div in each base_SECTION.html template:
# base.html
{% block content %}...{% endblock %}
{% block navigation %}
Section
1
Section
2
{% endblock %}
# base_section1.html
{% extends "base.html" %}
{% block active_secti
ble with an unpatched Django. See the
following tickets:
.. [1] http://code.djangoproject.com/ticket/4785
.. [2] http://code.djangoproject.com/ticket/4592
.. [3] http://code.djangoproject.com/ticket/6458
- whiteinge
--~--~-~--~~~---~--~~
You received this message because
?
Thanks.
- whiteinge
--~--~-~--~~~---~--~~
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
dj
I was coming at it from the other
direction and relying too much on the shell. Quandary solved.
- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this grou
On Jan 23, 10:22 pm, Vbabiy wrote:
> How can I get the user model when I use the client to login in to the
> application?
This method is a little ugly, but it works::
from django.contrib.auth.models import User
def test_showAccountWithZeroTrackers(self):
self.client.login(userna
On Feb 9, 9:01 am, Alfonso wrote:
> but is there a similar syntax for displaying HTML blocks depending on
> the user group?
Not builtin, no. But easy to add with a filter:
http://www.djangosnippets.org/snippets/847/
--~--~-~--~~~---~--~~
You received this message
7;,
(r'^someurl/', login_required(direct_to_template), { 'template':
'template.html', }),
)
- whiteinge
On Jun 6, 10:09 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> > An explanation of what you expect to happen and what is actually
>
Have you seen the existing `Django Brasil`__ group? It's got 165
members and seems pretty active.
.. __: http://groups.google.com/group/django-brasil
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" g
You're nearly there, you just need to return your cleaned value.
Here's one of mine:
if self.cleaned_data.get(field_name) > assets.get_usable_assets():
raise ValidationError(u'You only have %s points available for
betting.'
% assets.get_usable_assets())
return self.cleaned_data.get(f
Sorry, accidentally hit the submit button.
Here's your example finished (don't forget self in the def!):
def clean_lines(self):
if not format_is_correct( lines ):
raise forms.ValidationError('Bug..')
return self.cleaned_data.get(lines)
Good luck!
- whitein
BaseYourForm)
.. base class:
http://www.djangoproject.com/documentation/newforms/#using-an-alternate-base-class
.. fields argument:
http://www.djangoproject.com/documentation/newforms/#using-a-subset-of-fields-on-the-form
Cheers.
- whiteinge
On Jun 24, 12:47 pm, l5x <[EMAIL PROTECTED]> wrote:
> Hell
_for_model(YourModel, form=BaseYourForm)
list_of_required = ['name', 'username']
form = YourForm(yourlistoffields=list_of_required)
Cheers.
- whiteinge
On Jun 24, 2:46 pm, l5x <[EMAIL PROTECTED]> wrote:
> And what if I need a class only in selected field
ngo-users/msg/74aaef38380f2c31
Cheers.
- whiteinge
On Jun 24, 4:49 pm, l5x <[EMAIL PROTECTED]> wrote:
> This is a great stuff and I'm really glad that you show me that, but I
> still wonder if it is possible to do sth like that in a model ;-)
> I mean:
>
> Model looks lik
Not sure if this is what you're looking for, or if there's an official
way to to this, but I'm using this::
def get_admin_url(self):
return "%s/%s/%s/%s/" % ("/admin", self._meta.app_label,
self._meta.object_name.lower(), self.id)
S
p/django-developers/browse_thread/thread/e0a59d1eaa84c7b4/#
- whiteinge
On Jun 29, 12:13 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 6/29/07, Kirk Strauser <[EMAIL PROTECTED]> wrote:
> ...
>
> > return render_to_response('index.html',
> >
I'm having a problem with threadlocals in a custom manager making
queries for the wrong user. I've Googled around quite a bit, and
haven't found the answer -- except others *do* seem to be successfully
using threadlocals in Managers. Ostensibly this is a import-time vs.
execution-time problem, but
ps.google.com/group/django-users/msg/c8f7d18eb79d9aa1
I find the two frameworks to be a pretty solid match.
- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to thi
ur view is passing the whole form object to the
template, not `form.as_p()` (or something).
- whiteinge
On Jul 11, 12:32 pm, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> Hi there!
>
> I was just wondering how to access the value I've set in the view with
> Form(initial={'
I don't have much experience with sub-classing forms, but I suspect
`del self.fields[a]` should do the trick. Let us know!
- whiteinge
On Jul 15, 7:04 am, Eratothene <[EMAIL PROTECTED]> wrote:
> Fixed examples mistakes:
>
> class A(forms.Form)
> a = field
> b = fi
y, feature2_urls.py)?
myproject/urls.py::
urlpatterns = patterns('',
(r'^feature1/',
include('myproject.apps.myapp.urls.feature1')),
(r'^feature2/',
include('myproject.apps.myapp.urls.feature2')),
)
- whiteinge
--~--~-
Thanks, guys.
On Jul 19, 12:52 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
> If you just want to specify the urls as listed, you could always
> create a urls folder in myapp, put an __init__.py in there, and create
> myapp/urls/feature1.py and myapp/urls/feature2.py.
>
>
> Nathan Ostga
I found the forms from James Bennett's Django Registation app helpful
when I was first learning newforms.
http://django-registration.googlecode.com/svn/trunk/registration/forms.py
- whiteinge
On Jul 30, 2:08 am, james_027 <[EMAIL PROTECTED]> wrote:
> Hi,
>
> is there any s
ango-developers&q=3182
- whiteinge
--~--~-~--~~~---~--~~
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,
.
.. _distinct: http://www.djangoproject.com/documentation/db-api/#distinct
- whiteinge
--~--~-~--~~~---~--~~
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@googlegrou
javascript [2]_.
.. [1] http://www.w3.org/TR/html401/interact/forms.html#disabled
.. [2] http://www.djangoproject.com/documentation/model-api/#js
- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Dja
Depending on your ultimate output needs, ASCIIMathML.js may be a good
solution:
http://www1.chapman.edu/~jipsen/mathml/asciimathdemo.html
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To pos
The CRUD generic views haven't been updated for newforms yet. In the
meantime you can try using this snippet:
http://www.djangosnippets.org/snippets/99/
- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google G
the database).
The docs can be pretty daunting at first, but stick with 'em and feel
free to run any questions you have past this list!
Good luck,
- whiteinge
.. [1]
http://www.djangoproject.com/documentation/model-api/#automatic-primary-key-fields
.. [2]
http://www.djangoproject.com/docu
pk counter, it
is the second time this has struck me as annoying. Would the devs be
open to a patch for this sort of thing?
Thanks,
- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users&quo
Thanks for the replies, both.
> This idea has occurred to me before, and I can see how it could be
> useful, but I got caught up on one significant detail: how do you
> handle references? When you specify the PK, you provide an identifier
> to use as a cross reference. If this identifier no longe
x27;t save the new author instance.
>>> new_author = f.save(commit=False)
# Modify the author in some way.
>>> new_author.some_field = 'some_value'
# Save the new instance.
>>> new_author.save()
.. [1] http://www.djangoproject.com/documenta
! Let us know if you have further questions.
- whiteinge
--~--~-~--~~~---~--~~
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 fr
workaround ([1], [2]) doesn't seem to work any longer since
as_widget() appears to return a string. (Based on the workaround I
presume as_widget() used to return an iterable object.)
Any advice would be very much appreciated.
Thanks.
- whiteinge
.. [1]
http://groups.google.com/gro
ModelChoiceField. Currently not documented, but here's example code.
Use your browser's find for "ModelChoiceField".
http://www.djangoproject.com/documentation/models/model_forms/
On Jan 24, 9:47 pm, shabda <[EMAIL PROTECTED]> wrote:
> I want to use the ChoiceField to show choices depending on
nstructions. Hope it helps or gives
you a better idea.
.. [1] http://www.djangosnippets.org/snippets/568/
- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To p
after. Your question inspired me to clean it up a bit and
post it to Django Snippets. It might have a bug or two, but I tested
it with your use-case and it worked just fine.
http://www.djangosnippets.org/snippets/581/
- whiteinge
--~--~-~--~~~---~--~~
You r
er is not aware of using a markup language. Or should I just stick
> with {{ comment.content | escape | urlizetrunc:40 | linebreaks }}?
For b) I'm pretty ambivalent. Textile seems to be on the way out
though.
- whiteinge
--~--~-~--~~~---~--~~
You received
On Feb 7, 2:01 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I know I can't do what I am trying to do in the Media class, but how
> can I do this? How can I name that folder from the media_type
> fieldname?
You have to override the _save_FIELD_file method in your model. Marty
Alchin has a
or B');
The first argument needs to be the exact text of the list_filter
heading (the H3 element) that you're trying to hook on to.
Email me off-list if that didn't get it working. I'm happy to help.
- whiteinge
--~--~-~--~~~---~--~~
You received t
RL of your choosing is (or will be)
possible with the newforms-admin branch.
- whiteinge
--~--~-~--~~~---~--~~
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@g
by suggesting newforms-admin; I don't know for sure that
this is possible. It is far more flexible than the current Admin, so I
have high hopes, and other people also want this same functionality
[2].
.. [2] http://code.djangoproject.com/ticket/6002
- whiteinge
--~--~-~--~~-
On Mar 10, 3:28 am, Julian <[EMAIL PROTECTED]> wrote:
> def render_to_response(*args, **kwargs):
> kwargs['context_instance'] = RequestContext(request)
> return _render_to_response(*args, **kwargs)
That's exactly how Snippet #3 [1] does it. I personally prefer using
the built-in direct_to
On Apr 5, 6:36 am, J. Pablo Fernández <[EMAIL PROTECTED]> wrote:
> and what I want to do is print the individuals type="radio" ...> without any label, list or anything.
No, this isn't currently possible.
If you don't mind patching your Django installation, there's a ticket
[1] with a patch tha
", hopefully I didn't confuse you even more! :-P
Good luck.
- whiteinge
--~--~-~--~~~---~--~~
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@goog
cations is off by
quite a bit. The distance between Salt Lake City and Chicago is
reported as just over 10,000 miles, for example.
I'm not sure how to go about troubleshooting this. Any advice would be
very much appreciated.
- whiteinge
.. [1] http://code.djangoproject.com/wiki/GeoDj
with GIS? The best I've seen so far is the
link below.
So now that you know more about my setup, how would I find the
distance between two users in a model?
Thanks for your help so far, Justin.
- whiteinge
.. __:
http://www.sharpgis.net/post/2007/05/Spatial-references2c-coordinate-sys
27;t use the above quite as much, but it's
still very useful for non-ModelForms.
- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-u
d longitude as y/x instead of x/
y.
Not so obvious if you don't know lat/long very well.
Thanks, Justin, for pointing this out on IRC, and for all the other
helpful links.
- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
where, or am I doing
something fragile that should be done another way?
- whiteinge
--~--~-~--~~~---~--~~
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@googleg
On Apr 28, 6:30 pm, Szaijan <[EMAIL PROTECTED]> wrote:
> The base urls function properly, i.e. /visionary/accounts/register
> goes where it is supposed to, but when resulting URLs are called, they
> all get called as /accounts/register/complete instead of /visionary/
> accounts/register/complete.
On May 1, 10:04 am, "Guillaume Lederrey"
<[EMAIL PROTECTED]> wrote:
> This of course doesnt work because the request isnt in the scope. I
> could redefine a view in my views.py and do the work on the request
> manually, but i have a feeling there is a solution to do that directly
> in my urls.py.
On May 4, 5:42 am, "Guillaume Lederrey" <[EMAIL PROTECTED]>
wrote:
> I havent done any functional programming in a long time , but ... isnt
> there a way to use an anonymous function (if that's what it is called)
> and do the wrapper "inline" ? Something like :
Yeah, something like that would wor
On May 16, 6:27 am, Greg Taylor <[EMAIL PROTECTED]> wrote:
> class Form_SKU(ModelForm):
> """
> The form for updating SKUs.
> """
> selected = self.instance.colors
``self`` isn't in scope here, try the code below (and it wouldn't hurt
to read-up on Python OOP).
class Form_SKU(Mod
On Jun 5, 7:36 am, Berco Beute <[EMAIL PROTECTED]> wrote:
> My model has a ForeignKey that renders as a SELECT field in HTML. The
> problem is that there's an empty value ('-') that I would like
> to hide.
Presuming you are using newforms (i.e. not the Admin), then override
the ModelChoic
On Jun 7, 4:18 pm, Berco Beute <[EMAIL PROTECTED]> wrote:
> Quite a lot of work for something so simple
I agree that overriding default widgets is currently too much work.
But here's a slightly shorter version that works in exactly the same
way as your example::
class SomeForm(forms.ModelFor
f form.is_valid():
...
else:
form = RelationForm(instance=instance)
return render_to_response(...)
Hope that's helpful.
- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Goog
On Jun 19, 3:23 pm, Huuuze <[EMAIL PROTECTED]> wrote:
> In this example, what if you wanted to selectively remove a value from
> the choice list.
For that you'll have to move the field declaration into the form's
__init__ method::
class SomeForm(forms.ModelForm):
class Meta:
On Jun 19, 3:45 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote:
> if self.instance.state == 'processing':
> queryset = queryset.exclude(state='new')
The above lines aren't quite right ``self.instance`` is an instanc
On Jun 19, 4:36 pm, Adi <[EMAIL PROTECTED]> wrote:
> In order to set up the initial values on a couple of fields of my
> form, I need to pass in a couple of model objects to my ModelForm's
> init method.
Try this::
class YourForm(forms.ModelForm):
class Meta:
...
Stuart Grimshaw wrote:
> but it was throwing syntax errors on "player.player.first_name == '' ?
> player.player.username : player.player.first_name)"
It looks like you're trying to use a ternary operator here, but only
Python 2.5 and later has one (and the syntax is different [2]). The
good news
On Jun 25, 12:13 pm, twenger26 <[EMAIL PROTECTED]> wrote:
> def wrapper_for_wizard(request):
> return AddOrderWizard([OrderForm1, OrderForm2Quote, OrderForm3])
You're on the right track! You need to pass your list of forms to the
wizard constructor, as you're doing, as well as pass the reque
On Jun 26, 7:53 am, mwebs <[EMAIL PROTECTED]> wrote:
> gallery = forms.ChoiceField(Gallery.objects.filter( ...))
You want to use a ModelChoiceField [1] instead of a ChoiceField. It
takes a QuerySet as an argument::
class PictureForm(forms.Form):
...
gallery = forms.ModelChoic
On Jun 26, 8:29 am, Huuuze <[EMAIL PROTECTED]> wrote:
> How can I add an empty value as the initial value?
At the moment you have do a bit of leg-work for this. Something like
the following should work (untested)::
from django.contrib.localflavor.us.us_states import STATE_CHOICES
from dj
On Jun 26, 12:00 pm, Huuuze <[EMAIL PROTECTED]> wrote:
> Just out of curiosity, are the Django devs working on a patch? I
> wasn't able to find a ticket for this issue.
Little consistency tweaks like this one will become more important
once 1.0 lands, imo.
--~--~-~--~~~--
e = '?page=%s' % ((posts / paginate_by) + 1)
else:
page = ''
return "%s%s#post_%s" % (self.thread.get_absolute_url(),
page, self.id)
- whiteinge
On Mar 15, 2:19 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
I've been happily using limodou's suggestion with the jQuery framework
for a few weeks, hopefully whatever framework you're using also sends
the X-Requested-With header--it just feels cleaner.
if request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest':
;m relying on a 403
response header to detect validation errors and the X-Requested-With
request header to detect Ajax.
Feel free to drop me a line for more explanation if you want.
- whiteinge
On Apr 13, 8:29 am, "Tipan" <[EMAIL PROTECTED]> wrote:
> I've created a view t
Personally, I use a toolkit to lessen cross-browser compatibility
problems as well as to speed quick, little functionality (eg.
animations). I chose jQuery because it's small, unobtrusive, and I
love the CSS-like syntax.
- whiteinge
On Apr 18, 3:11 am, Tipan <[EMAIL PROTECTED]> wrot
m is
they haven't been updated for Django's newforms yet--so use caution,
things may change when they're updated.
Good luck.
- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django
-tags
Just put them in your flatpages/default.html template.
- whiteinge
On Jun 2, 10:42 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi All.
>
> I have got a question about flatpages. Supposed I have a "static" page
> that says how great my product i
convenient.
.. __:
http://www.b-list.org/weblog/2006/11/16/django-tips-get-most-out-generic-views
.. __: http://www.djangobook.com/en/beta/chapter09/#cn377
.. __:
http://www.pointy-stick.com/blog/2006/06/29/django-tips-extending-generic-views/
- whiteinge
On Jun 2, 11:24 am, Nathaniel Whitein
ound atoponce's comment at the bottom useful.
.. __: http://www.djangosnippets.org/snippets/129/
Good luck!
- whiteinge
On Jun 2, 9:14 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sat, 2007-06-02 at 14:54 -0700, [EMAIL PROTECTED] wrote:
> > Oh no, that can not be! I just r
If you're using generic views your templates should already have the
`user` object in their context. You should be able to just use
{{ user }} to get the current user's username.
- whiteinge
On Jun 4, 8:51 am, konryd <[EMAIL PROTECTED]> wrote:
> Is it possible to send usern
ot;xgm.AbbrDB.views",
(r"^$", "search"),
(r'^list/$', object_list, info_dict),
)
urlpatterns += patterns("django.views.generic.list_detail",
(r'^list/$', 'object_list', info_dict),
)
Whoops, mind the typo. Should be::
urlpatterns = patterns("xgm.AbbrDB.views",
(r"^$", "search"),
)
urlpatterns += patterns("django.views.generic.list_detail",
(r'^list/$', 'object_list', info_dict),
)
--~--~-~--~~~---~--~~
You rece
On Sep 30, 2:23 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Given the age of that ticket, however, is the procedure that "requires
> a bit of work" documented anywhere?
Or you could just use SmileyChris' implementation [1]_ for now (which
works well).
.. [1] http://smileychris.tactful.c
ww.djangoproject.com/documentation/newforms/#using-forms-in-views-and-templates
.. [4] http://www.djangoproject.com/documentation/newforms/#form-for-instance
The only generic views that are currently not working are create and
update.
- whiteinge
--~--~-~--~~~-
Did you include the port in your MEDIA_URL setting? [1]_
MEDIA_URL = 'http://localhost:8000/media/'
.. [1] http://www.djangoproject.com/documentation/settings/#media-url
- whiteinge
On Oct 29, 4:30 am, Przemek Gawronski <[EMAIL PROTECTED]>
wrote:
> Hi, the ImageField
ordering = ('first', 'last')
.. [1] http://www.djangoproject.com/documentation/model-api/#id7
.. [2] http://www.djangoproject.com/documentation/model-api/#ordering
Cheers!
- whiteinge
--~--~-~--~~~---~--~~
You received this message because yo
> What's is your opinion about how long it takes until these forms are
> implemented with newforms in SVN?
The devs work on Django in their spare time, so there isn't a strict
timetable for updates. My advice is not to wait -- forge ahead using
the afore-mentioned snippet or regular views.
Keep
give you a quick
yes-or-no view.
.. [1]
http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships
.. [2] http://www.djangoproject.com/documentation/model-api/#list-display
Maybe someone else will have a suggestion that makes mine look silly.
Either way, good luck!
- whiteing
f the template:
http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/templates/admin/login.html
- whiteinge
On Oct 31, 10:26 am, Gigs_ <[EMAIL PROTECTED]> wrote:
> can anyoune give me simple example how to use:
> django.contrib.auth.views.password_c
ModelChoiceField instead -- it'll handle all that
ForeignKey business for you automatically. It not currently
documented, but you can find example usage here [1] (use your
browser's find).
.. [1] http://www.djangoproject.com/documentation/models/model_forms/
Cheers.
- whiteinge
--~--~--
89 matches
Mail list logo