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
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 Jan 23, 7:14 pm, Karen Tracey wrote:
> Take a look at the implementation of CursorDebugWrapper
> __getattr__ in django/db/backends/util.py -- CursorDebugWrapper defers to
> the wrapped cursor for anything it itself doesn't implement.
Thanks, Karen. You're exactly right. I was coming at it fro
Requesting a sanity check before I file a ticket.
The API for directly accessing a database cursor() changes depending
on if DEBUG is True or False. (Excepting execute() and executemany().)
This shell session spells it out more clearly:
http://dpaste.com/hold/112331/
Is this intentional?
Thank
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
On Dec 8, 8:00Â am, chewynougat <[EMAIL PROTECTED]>
wrote:
> Could anyone tell me if I can pass the current user to a form wizard
> step so I can prepopulate their object details in the form? If so,
> how?
It depends on where exactly you need to access the current user. If
you can do it *after* f
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
On Oct 18, 3:40 am, Torsten Bronger <[EMAIL PROTECTED]>
wrote:
> I try to achieve the following HTML table layout:
>
> .+--+---+
> .| 1 | |
> .+--+---+
> .| 2 | |
> .+--+---+
> .| 3 |
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
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.
--~--~-~--~~~--
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, 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 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
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 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:
...
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, 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 10, 9:42 pm, Adi <[EMAIL PROTECTED]> wrote:
> The application flow works like this: You create a Relation object
> within the context of an Owner Object. There is a rule that says that
> a owner cannot have two Relation with the same pet value. How can I
> create a validation on the form th
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
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 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 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 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 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.
I'm using the __init__() method in a few models to save state for
later use in save(), e.g.::
class MyModel(models.Model):
...
def __init__(self, *args, **kwargs):
super(MyModel, self).__init__(*args, **kwargs)
self.old_value = self.value
def sa
On Apr 23, 9:23 am, Justin Bronn <[EMAIL PROTECTED]> wrote:
> > A PointField from that same model containing lat/long pairs obtained
> > from the Google geocoder.
Quick follow-up in case anyone else has a similar problem. The Google
geocoder annoyingly returns latitude and longitude as y/x instea
On Apr 24, 4:44 am, nickloman <[EMAIL PROTECTED]> wrote:
> class MyForm(forms.Form):
> def __init__(self, user, data=None):
> forms.Form.__init__(self, data)
>
> self.fields['my_options'] =
> ModelChoiceField(queryset=SomeModel.objects.get_users_objects(user))
You're on the ri
On Apr 22, 11:54 am, Justin Bronn <[EMAIL PROTECTED]> wrote:
> (1) What geographic fields are in your model, what type are they
> (e.g., PointField, etc.), and their SRID.
A plain PointField, e.g.: ``location = PointField()``. I believe
GeoDjango defaults to WGS84 for the SRID.
> (2) The geometr
I'm calculating the distance between two plain PointFields in the GIS
branch using the distance GeoQuerySet method [1] and I'm coming up
with some confusing results.
The distance between nearby things is often about right, maybe off by
a mile or two. But the distance between farther locations is
I'm really new to GeoDjango myself, and I agree that jumping right in
is a bit of a shock. Hopefully someone more knowledgeable will also
pipe-up, but I think I can start you off in the right direction.
On Apr 14, 9:43 pm, Alex Ezell <[EMAIL PROTECTED]> wrote:
> The system would then show them tr
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
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 Feb 19, 7:08 pm, cyberjack <[EMAIL PROTECTED]> wrote:
> Thanks for the suggestion, but there has got to be a simple way to
> solve this problem. Does anyone else have an idea for solving this
> problem?
It's just a regular Django view that's doing the work here. Take a
look at the `change_stag
Another workaround: I used JavaScript to open links on the change_list
page in a pop-up window (helps to append `?_popup=1` to the URL). It's
not perfect (you have to refresh the change_list page to see your
changes), but it keeps all your filtering intact.
I believe redirecting to an URL of your
On Feb 7, 3:06 pm, [EMAIL PROTECTED] wrote:
> Can you please give an example of what the list_filter be
> in the model, to get the filterting to work?
Is it just not showing up after the existing list_filter options?
Assuming your current list_filter looks like:
list_filter = ('affiliation', 'pu
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
On Feb 6, 2:55 pm, Florian Lindner <[EMAIL PROTECTED]> wrote:
> For a) it's important for me to have the possibility to embed raw
> HTML. AFAIK markdown provides hat possiblity, is it also possible with
> textile and reST?
For a) you'll never be left wanting with RestructuredText. It is *by
far*
On Feb 3, 7:56 pm, [EMAIL PROTECTED] wrote:
> Is there a way to select both 'A' and 'B' under affiliation and get
> both Tom and Diane?
You can use non-standard filters in the Admin by manually typing the
in the URL. For example:
http://yoursite/admin/yourapp/student/?school__in=1,2
Unfortunatel
On Jan 28, 7:59 pm, Peter Rowell <[EMAIL PROTECTED]> wrote:
> You can also add an 'order' field to the subordinates, but you are
> only looking at one of them at a time in admin, so ... it requires the
> user to do a lot of remembering/note-taking.
I have an app with an order field, and I was thi
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
I'd like to be able access the individual radio buttons of a
ChoiceField using the RadioSelect widget directly from a template.
After quite a bit of searching, I don't think this is currently
possible with newforms but I was wondering if anyone knows of
something I missed.
An earlier workaround (
In the Django world (and the newspaper world), the canonical term for
what you're looking for is 'slug' and Django even has a built-in slug
model field [1].
If you're just using the built-in Admin, then it even has JavaScript
that will create the slug based on another model field.
However, if yo
On Dec 30 2007, 6:46 pm, makebelieve <[EMAIL PROTECTED]> wrote:
> Part of a form of mine has a drop down to choose a region which is a
> foreign key to the object I'm updating. Further, I have a link to add
> a new region if the user does not see what they want. If a user adds
> a new region it
It's really as simple as including the view in your urlconf and
copying the relevant template parts from Django. Here are two stripped-
down examples.
http://dpaste.com/23815/
http://dpaste.com/23814/
You can use the built-in login in much the same way. Just copy the
relevant parts of the templa
> The Project and ProjectUnits are defined before the Crews are
> assigned, but when assigning a Crew to a ProjectUnit I'd like to know
> if the Crew is already scheduled to work that day. That's allowed,
> but I'd like a confirmation alert when this happens, or ideally, have
> the droplist for
> 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
Hello!
> It actually works! In the admin interface it displays the 'contact'
> field as a combination of the 'first' and 'last' fields of the
> contact, which is exactly what I wanted. But, my question is how did
> it know to do that? What if I had wanted it to display the
> 'login_name' inste
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 creates in a model get_FO
On Oct 24, 5:21 am, Florian Lindner <[EMAIL PROTECTED]> wrote:
> I'm looking for an example on how to use the
> django.views.generic.create_update.update_object generic view.
The create and update generic views haven't been updated for newforms
yet. There's a Django Snippet [1]_ that might be hel
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
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
If you're only doing one or two, use callables [1]_ which will ignore
your view prefix::
from django.conf.urls.defaults import *
from models import Abbreviation
import django.views.generic.list_detail.object_list as object_list
info_dict = { "queryset": Abbreviation.objects.all()
Your best bet is probably to use ``save(commit=False)`` [1]_ to get a
Profile instance, then set the user fk and call ``save()`` again. This
is the example from the newforms docs::
# Create a form instance with POST data.
>>> f = AuthorForm(request.POST)
# Create, but don't save the
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
Can fixtures have auto-incrementing primary keys or must you have
specific PKs in the the serialized json/xml/etc files? If not, is
there a reason for this?
I'm programmatically generating fixtures from Freebase.org queries for
a project. Although it's not a much extra work to add a pk counter, i
On Sep 4, 4:24 am, Nader <[EMAIL PROTECTED]> wrote:
> I am a new in Django world. I have installed Django and have made a
Welcome! :-)
> The Model in this application looks like :
>
> class ContactInfo(models.Model):
> contactId = models.IntegerField(primary_key=True)
Quick note: This isn't n
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 Groups
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
> is there a way to show the value of the field without making it
> editable?
This isn't possible by throwing an option into your field definition.
If you trust your Admin-site users, the easiest thing to do is
probably add the disabled [1]_ attribute to the element via custom
admin javascript [
> It works like a charm, but I'm obviously getting duplicates, and the
> choices are not sorted.
Looks like set() may do the job (I've never used it, but I'm glad to
learn about those related functions).
Another option may be tacking distinct() onto your query.
.. _distinct: http://www.djangopro
On Aug 2, 3:01 am, Jens Diemer <[EMAIL PROTECTED]> wrote:
> We have the shortcut get_or_create() [1], but whats about a
> create_or_update() ?
One exists as a patch_. I've been using it with the current svn for a
while without problems. I find that an update_or_create() shortcut is
particularly
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 sample on over riding t
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'm a little fuzzy on how Django imports additional app URLconfs. I've
got two parts of an app that are closely related to one another,
however I'd like to give them both root URLs.
myproject/urls.py::
urlpatterns = patterns('',
(r'^feature1/', include('myproject.apps.myapp.urls')),
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 = field
>
> class B(A)
> del a
The form object has the initial values in a couple places in dicts.
Since it's a dict you can access it's fields with the dot-syntax. I
just successfully tried this on one of my forms::
{{ form.fields.FIELDNAME.initial }}
or::
{{ form.initial.FIELDNAME }}
Just watch that your view is p
> Well, in general, I'm pretty new to web development including javascript
> (but with 7 years of python coding) so I just wanted to see what (and
> how) people do newforms and jQuery to get the idea.
This__ isn't interesting, but it *is* an example. :-)
.. __: http://groups.google.com/group/dja
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
A `related thing`__ came up on the Django Dev list this week.
I'm not that old-school. :-) I use that `{% if user.is_authenticated
%}` all over my site and it's a pain to import and call all the stuff
you need for render_to_response over and over. So this is what I
changed all my views to this we
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)
Stolen from wamber.net.
- whiteinge
Malcolm has a really `good write-up`__ about the reasoning behind
newforms (and oldforms) and why it's not just part of the model.
If you find yourself having to do this sort of thing a lot, I would
suggest putting those BaseForm class definitions right next to the
model class in models.py. I do
The name of the fields will be the same name you use in your model.
You can replace the loop with explicit calls for each field::
self.fields['name'].widget.attrs['class'] = yourClass1
self.fields['username'].widget.attrs['class'] = yourClass2
Or if you want to pass a list in as an argu
I hope I understand what you're asking: that you want to add a CSS
class to each form field generated by the form_for_* helpers?
If so, you could make a small `base class`_ to do that::
class BaseYourForm(forms.BaseForm):
def __init__(self, *args, **kwargs):
super(BaseYou
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!
- whiteinge
On Jun 22, 4:54 pm
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
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
Until Malcolm swoops in with the answer to your question about the
docs, you can use callables in your urlconf to accomplish what you
want.
from django.contrib.auth.decorators import login_required
from django.views.generic.simple import direct_to_template
urlpatterns = patterns('',
(r'^some
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 username to the template us
Malcom is right, they're not as bad as they sound. :-)
In the case of the two things you mentioned wanting, latest news and a
calendar, the following existing template tags may just hook you up:
James Bennett's get_latest__ is copy-and-paste-able and works very
well. I use a slightly modified ve
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
Stuff like that calendar and the latest news are what templatetags
excel at doing. They are deceptively powerful.
.. __:
http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags
.. __:
http://www.b-list.org/weblog/2006/06/07/django-tips-write-better-template-tag
The only argument that is `required for the create_object generic
view`__ is a model.
.. __:http://www.djangoproject.com/documentation/generic_views/#django-
views-generic-create-update-create-object
I've run into this problem a few times when I was getting started. It
took me a while to get acc
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]> wrote:
> Thanks Gu
I'm doing something pretty similar sounding with jQuery. I wanted to
check for form validation errors via Ajax and do a regular form
submission otherwise.
The JavaScript:
http://dpaste.com/hold/8571/
The Python:
http://dpaste.com/hold/8572/
The code might be a little weird looking. I'm relying
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':
# do stuff...
- whiteinge
On Ap
If it helps, I'm using anchors in a get_absolute_url() function in a
model for a forum app, and they're working just fine (even with
pagination).
def get_absolute_url(self):
paginate_by = 30
posts = self.thread.post_set.count()
if posts > paginate_by:
page = '?page=%s' % ((pos
86 matches
Mail list logo