Re: get translated text from ugettext_lazy() result
[fixed top-posting] On Thu, Feb 26, 2009 at 09:31, Matej <matej.pun...@gmail.com> wrote: > On Feb 26, 3:38 pm, Alex Gaynor <alex.gay...@gmail.com> wrote: >> On Thu, Feb 26, 2009 at 4:36 AM, Matej <matej.pun...@gmail.com> wrote: >> >> > Hello. >> > I would like to get my translated text from ugettext_lazy() result. >> > How can I do that? >> >> > Example: >> >http://dpaste.com/1744/ >> >> > #models.py >> > RATING_CHOICES = ( >> > ('0', _('I don\'t know')), >> > ('1', _('Very bad')), >> > ('2', _('Bad')), >> > ('3', _('OK')), >> > ('4', _('Good')), >> > ('5', _('Excelent')), >> > ) [...] >> Perhaps you're looking for this >> method:http://docs.djangoproject.com/en/dev/ref/models/instances/#get-foo-display > This looks like it should work but it does not. > WebStoreRating fields delivery and ui have defined > choices=RATING_CHOICES > >>>> r = WebStoreRating.objects.filter(pk=1) >>>> r = r[0] >>>> r.get_delivery_display() > 3 >>>> r.get_ui_display() > 3 Just a guess: you're using some kind of *integer* model field but since your choices are tuples with *strings* as the first element. Use integers for the first element of each tuple instead: RATING_CHOICES = ( (0, _('I don\'t know')), (1, _('Very bad')), (2, _('Bad')), (3, _('OK')), (4, _('Good')), (5, _('Excelent')), ) Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 'blocktrans' doesn't allow other block tags (seen u'plural') inside it
On Thu, Feb 5, 2009 at 4:21 PM, Tipan <t...@ortengo.co.uk> wrote: > [...] > > Docs show: > {% blocktrans count list|length as counter %} > There is only one {{ name }} object. > {% plural %} > There are {{ counter }} {{ name }} objects. > {% endblocktrans %} > > My template has: > {% blocktrans with user_points_value as user_points_value_t %}That's > {{ user_points_value_t}} entry.{% plural %}That's > {{ user_points_value_t}} entries.{% endblocktrans %} > > Throws a template syntax error: > 'blocktrans' doesn't allow other block tags (seen u'plural') inside it You want to use "count" instead of "with" in the blocktrans tag: >>> from django.template import Context, Template >>> t = Template(""" ... {% load i18n %} ... {% blocktrans count user_points_value as user_points_value_t %} ... That's {{ user_points_value_t}} entry. ... {% plural %} ... That's {{ user_points_value_t}} entries. ... {% endblocktrans %} ... """) >>> print t.render(Context({'user_points_value': 1})).strip() That's 1 entry. >>> print t.render(Context({'user_points_value': 2})).strip() That's 2 entries. Cheers, Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Saving tests' output to a file in Windows
On Mon, Jul 21, 2008 at 12:13 AM, Julien Phalip <[EMAIL PROTECTED]> wrote: > Anyway, I can't really debug these errors because the output doesn't > entirely fit in the command window. So I'd like to save the output in > a file, but it doesn't work. I tried: > > set PYTHONPATH=E:\django > runtests.py --settings=settings > results.txt > > But the file remains empty. I wonder if that's because Django crashes > and the writing is interrupted somehow. > > Do you know how I can get it to write the whole output in a text file? You can redirect both stdout and stderr to a file like this: set PYTHONPATH=E:\django runtests.py --settings=settings > results.txt 2>&1 Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Adding and removing template dirs on the fly
On Thu, Jul 17, 2008 at 8:04 AM, 3xM <[EMAIL PROTECTED]> wrote: > I already tried loading templates a la > > '%s/name_of_template.html' % channel_template_folder > > but the result is that it when the template includes other templates, > it will look for it in the same folder, not doing the fallback thing > to the main generic template folder (as it is looking for something in > a subfolder with the name of the value of channel_template_folder). > > Does it make sense? Right, the includes will be relative to TEMPLATE_DIRS. > I'll try to illustrate the current template structure to clarify: > > .../templates >part_1.html >part_2.html >/channel_a >part_1.html >/channel_b >part_2.html > > (I hope the identation in the above doesn't get ignored as whitespace) > > So, normally I load e.g. 'part_1.html' which, somewhere in it, > includes 'part_2.html'. That works just fine. > > But for Channel A I used to load 'channel_a/part_1.html', which will > also include 'part_2.html'. But now the template system will look for > a file called 'channel_a/part_2.html' which doesn't exist. The template system will only look for "part_2.html" under "channel_a" if "channel_a" is in your TEMPLATE_DIRS. > And for Channel B, where I only want 'part_2.html' to be different > from the generic, I can't get it to work without adding > 'templates/channel_b' to TEMPLATE_DIRS. A "solution" is to copy all > templates each time I want to make differences, but that seems quite > stupid to me. Or you could leave TEMPLATE_DIRS alone and use this in "channel_b/part_1.html": {% include "channel_b/part_2.html" %} > So what I want is to temporarily add 'templates/channel_b' to > TEMPLATE_DIRS for requests for playlists from Channel B. Is it somehow > possible? But is it a good idea? If it turns out that the only solution for your problem is to have some fallback mechanism when including templates, you could always write a template tag to do just that. And maybe you can solve it using some combination of template inheritance, inclusion and select_template. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Adding and removing template dirs on the fly
On Thu, Jul 17, 2008 at 6:23 AM, 3xM <[EMAIL PROTECTED]> wrote: [...] > I am making a generic system for generating some playlists. Playlists > for most channels look exactly the same, but some has small > differences in how it should appear (e.g. they should not include a > thumbnail for the video, or maybe the order of the data presented > should be slightly different). > > I'm using a set of templates, each one for each part of the playlist, > making it easy - in theory - to alter small parts of the playlist for > each channel, simply by adding another template directory for the > specific channel. Have you seen the section on loading templates in the documentation? It contains a tip that describes how you can use select_template to nicely deal with this type of situation: http://www.djangoproject.com/documentation/templates_python/#loading-templates Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: request getlist() in order?
On Wed, Jul 16, 2008 at 7:29 PM, Rob Hudson <[EMAIL PROTECTED]> wrote: > > If I have a form like the example: > > > > >The Beatles >The Who >The Zombies > > > > > And I call request.POST.getlist('bands'), is the order of the bands > going to always be the same as provided in the select box? > > Or another case, if I have the form: > > > Select bands in the order you want them to play: > >The Beatles >The Who >The Zombies > > >The Beatles >The Who >The Zombies > > >The Beatles >The Who >The Zombies > > > > > In this case, only 1 item can be selected per select box but they are > all named the same so I can get them as a list via getlist(). Will > the value of getlist() be in order as selected in the form? I'd expect this to be the case. The HTML specification requires browser to submit forms (application/x-www-form-urlencoded and multipart/form-data) encoded in such a way that the order in which the name/value pairs is the order in which they appear in the document[1], and Django's request processing preserves this order when converting the encoded data to MultiValueDicts. > I'm trying to determine if I can do something the easy way (depend on > the order as provided in the form) or do I have to name the fields in > such a way to remember the order on POST. You most likely can, but I don't think you should: the order in which things appear on a page is a presentational issue. Arien [1] http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Need help in using ComboField for Forms
On Thu, Jul 17, 2008 at 1:57 AM, Kadusale, Myles <[EMAIL PROTECTED]> wrote: > Can anybody help me by sending snippets of code on using ComboField in > forms? Something like this from the regression tests? http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/fields.py?rev=7859#L1104 Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Modulo of 4 not working right
On Wed, Jul 16, 2008 at 11:01 AM, Marty Alchin <[EMAIL PROTECTED]> wrote: > Of course, you're welcome to go with Scott's suggestion of doing all > the math in one line, but it loses a bit readability going that way. > On the flip side, it probably executes slightly faster, but probably > not enough to make much different in the real world. Faster and more readable (imho): >>> def make_divisible_by_4(num): ... div, mod = divmod(num, 4) ... return mod and (div + 1) * 4 or num ... >>> make_divisible_by_4(8) 8 >>> make_divisible_by_4(10) 12 >>> make_divisible_by_4(33) 36 Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How to access the label of a model instance
On Tue, Jul 15, 2008 at 2:08 PM, Arien <[EMAIL PROTECTED]> wrote: > Oh, I see, you want the verbose_name of each field. I suppose you > could write a templatetag that you could use like this: > > {% verbose_name layer.heating_temperature %} > {{ layer.heating_temperature }} > > After parsing the templatetag's argument, you'd resolve the model > instance and insert this in the template: > > model_instance._meta.get_field(field_name).verbose_name The basic idea (and only that): class VerboseNameNode(template.Node): def __init__(self, model, field): self.model, self.field = model, field def render(self, context): model = template.Variable(self.model).resolve(context) return model._meta.get_field(self.field).verbose_name def do_verbose_name(parser, token): tag_name, var = token.split_contents() model, field = var.split('.') return VerboseNameNode(model, field) Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How to access the label of a model instance
On Tue, Jul 15, 2008 at 1:22 PM, Torsten Bronger <[EMAIL PROTECTED]> wrote: > Arien writes: >> You'll have to make layer._meta.verbose_name available to the >> template under some other name. > > Unfortunately, I use model polymorphism and model inheritance in > this case and can't pass anything but the common base class to the > template. How about sticking this on the base class then? @property def verbose_name(self): return self._meta.verbose_name > Therefore, I collect all verbose_names in an "all_labels" dict in my > models.py: > > all_labels = {} > for cls in [cls for cls in _globals.values() if inspect.isclass(cls) and > issubclass(cls, models.Model)]: >local_labels = {} >for field in cls._meta.local_fields: >local_labels[field.name] = field.verbose_name >all_labels[cls.__name__] = local_labels Oh, I see, you want the verbose_name of each field. I suppose you could write a templatetag that you could use like this: {% verbose_name layer.heating_temperature %} {{ layer.heating_temperature }} After parsing the templatetag's argument, you'd resolve the model instance and insert this in the template: model_instance._meta.get_field(field_name).verbose_name Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: escape filter
On Tue, Jul 15, 2008 at 12:22 PM, Fernando Rodríguez <[EMAIL PROTECTED]> wrote: > > El mar, 15-07-2008 a las 12:25 -0400, Ned Batchelder escribió: > >> You're misunderstanding the role of the escape filter. It isn't meant >> to create HTML entities for accented characters. All it does is escape >> characters that could be dangerous for XSS attacks (" ' < > &). And by >> the way, in the latest code, escaping is automatic, so you may not need >> it at all. > > OK, thanks. That makes sense. > > However, I still need to convert those accented character into html > entities. Is there any pre-built filter for this? I checked the > refrence in "The definitive guide to django" but saw none. (I assumed you wanted to escape the characters < > & " ' in your flatpages for some reason, but that doesn't seem to be the case.) Why do you need to use HTML entities for accented characters? What is the problem you're trying to solve? Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How to access the label of a model instance
On Tue, Jul 15, 2008 at 12:00 PM, Torsten Bronger <[EMAIL PROTECTED]> wrote: > > Hallöchen! > > Arien writes: > >> On Tue, Jul 15, 2008 at 10:53 AM, Torsten Bronger >> <[EMAIL PROTECTED]> wrote: >> >>> In a display template (not a form, just display), I write the >>> following: >>> >>>{% trans 'Temperature:' %} >>>{{ layer.heating_temperature }} >>> >>> I'd like to use the verbose_name of the model instance instead of >>> hard-wiring the label in the template. How can I access it? >> >> The verbose_name is at layer._meta.verbose_name. You can't access >> it like that from your template, though. > > Okay, thanks! However, then what is the "official" way to do it? Sorry for being unclear. What I meant was that you can't use layer._meta.verbose_name in the template, because template variables and attributes can't start with an underscore. You'll have to make layer._meta.verbose_name available to the template under some other name. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: escape filter
On Tue, Jul 15, 2008 at 11:00 AM, Fernando Rodríguez <[EMAIL PROTECTED]> wrote: > > Hi, > > I'm using this simple template with flatpages: > > > >{{ flatpage.title|escape }} > > > >{{flatpage.title|escape}} >{{ flatpage.content|escape }} > > > > > I was expecting to see all accented chars in title and contents to be > displayed properly escaped, however, I'm seing the "raw" chars. What am > I doing wrong? You can use the force_escape filter to escape <, >, quotes and ampersands. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How to access the label of a model instance
On Tue, Jul 15, 2008 at 10:53 AM, Torsten Bronger <[EMAIL PROTECTED]> wrote: > > Hallöchen! > > In a display template (not a form, just display), I write the > following: > >{% trans 'Temperature:' %} >{{ layer.heating_temperature }} > > I'd like to use the verbose_name of the model instance instead of > hard-wiring the label in the template. How can I access it? The verbose_name is at layer._meta.verbose_name. You can't access it like that from your template, though. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: integer digit limit
On Tue, Jul 15, 2008 at 10:30 AM, Bobby Roberts <[EMAIL PROTECTED]> wrote: > I've got an IntegerField setup with a max_value of 20. I'm > wondering how to limit the initial input on the form field to no more > than 6 characters. You can pass the fields widget an optional attrs keyword argument (a dictionary) for HTML attributes of the widget. The HTML attribute you're looking for is maxlength: some_field = forms.IntegerField(widget=forms.TextInput(attrs={'maxlength': 6})) Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Trying to install django
On Tue, Jul 15, 2008 at 9:58 AM, Arien <[EMAIL PROTECTED]> wrote: > On Tue, Jul 15, 2008 at 9:27 AM, Ralph <[EMAIL PROTECTED]> wrote: >> >> I'm trying to install django for the first time. [...] > What I do is this: > > 1. check out the svn version to some directory, for example > c:\svn\django-trunk. From the command-line: > > svn co http://code.djangoproject.com/svn/django/trunk/ c:\svn\django-trunk > > (that should be one line) > > 2. create a file called django.pth in the site-packages directory and > enter the path of the directory you used in step 1. > > In your case you should end up with the file > > C:\Python25\Lib\site-packages\django.pth > > which contains > > c:\svn\django-trunk > > (or whatever path you used in step 1.) Using TortoiseSVN, step 1 would be: select "SVN Checkout..." from the context menu, fill in http://code.djangoproject.com/svn/django/trunk/ for URL of the repository and c:\svn\django-trunk (or whatever you want to use) for the checkout directory. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Trying to install django
On Tue, Jul 15, 2008 at 9:27 AM, Ralph <[EMAIL PROTECTED]> wrote: > > I'm trying to install django for the first time. > > I've read through at least 3 tutorials on how to install django and by > using parts of all three I managed to get the django files installed, > but I followed this command > >>>> import django > > I get > > Traceback > File "", line 1, in > ImportError: No module named django > > > I'm using > Vista > Python25 > > The directory structure is like this:- > Python25\Lib\site-packages\django\django\bin If you check out a svn version to your site-packages, you should have a path like this: Python25\Lib\site-packages\django\bin What I do is this: 1. check out the svn version to some directory, for example c:\svn\django-trunk. From the command-line: svn co http://code.djangoproject.com/svn/django/trunk/ c:\svn\django-trunk (that should be one line) 2. create a file called django.pth in the site-packages directory and enter the path of the directory you used in step 1. In your case you should end up with the file C:\Python25\Lib\site-packages\django.pth which contains c:\svn\django-trunk (or whatever path you used in step 1.) Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Site wide date format
On Tue, Jul 15, 2008 at 8:14 AM, Adam Peacock <[EMAIL PROTECTED]> wrote: > > I'm looking for a consistent way to format dates across my site, > without having to put the format into every template. Is it possible > to set a default date format for the "date" filter? For example, I > want {{ var.date|date }} to format to {{ var.date|date:"l, F j Y" }} > unless I specify otherwise, but still have the ability to format it > differently in some cases. Is this possible? Use the DATE_FORMAT setting: http://www.djangoproject.com/documentation/settings/#date-format Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Setting the time on a datetimefield
On Tue, Jul 15, 2008 at 7:25 AM, Tim Sawyer <[EMAIL PROTECTED]> wrote: > In my form I have: > > datetime = > forms.DateField(widget=forms.TextInput({'class' : > 'date-pick'}),label="Available > date") > > yet it's a DateTimeField in the model. Why not use a DateTimeField in your form and change the widget instead? For example: datetime = forms.DateTimeField( widget=forms.DateTimeInput(format='%Y-%m-%d', attrs={'class' : 'date-pick'}), label="Available date" ) (Note the attrs={...} for the class.) > This means that the reason that the value fetched from the form is only a date > is because of the type in the form. Assigning this date only value from the > form to the model attribute means I can't use replace(hour=23) on it any > more. I don't really understand why, but I'm sure there's a logical > explanation! The logical explanation is that adjusting the hour of a date doesn't make sense, because a date doesn't have any hour. ;-) Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Setting the time on a datetimefield
On Tue, Jul 15, 2008 at 4:57 AM, Tim Sawyer <[EMAIL PROTECTED]> wrote: > In my code, I did this: > > self.datetime = pForm.cleaned_data['datetime'] > > the datetime parameter passed from the form only contained the date, with no > time, so I assume the value in datetime then was only a date. This shouldn't happen: a DateTimeField normalizes to a datetime.datetime object. Are you sure you're not using a DateField in your form? Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: delete or update a model
On Tue, Jul 15, 2008 at 4:50 AM, Alfredo Alessandrini <[EMAIL PROTECTED]> wrote: > How can I update or delete a model? Saving changes to objects: http://www.djangoproject.com/documentation/db-api/#saving-changes-to-objects Deleting objects: http://www.djangoproject.com/documentation/db-api/#deleting-objects Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: instance needs to have a primary key value before a many-to-many relationship can be used.
On Tue, Jul 15, 2008 at 2:06 AM, tom17 <[EMAIL PROTECTED]> wrote: > > Found out: > id = models.AutoField(primary_key=True) Or leave the id field out entirely. See: http://www.djangoproject.com/documentation/model-api/#automatic-primary-key-fields Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Multi-level template blocks
On Mon, Jul 14, 2008 at 11:54 PM, Gregg Lobdell <[EMAIL PROTECTED]> wrote: > I'm converting an application from hand-constructed Python that builds > a large web site to Django templates. The site has multiple layers. > All pages share the same basic layout, header, footer, etc. On each > intermediate layer, some features are added, but there are several > flavors of page within each layer. I thought I could arrange it as > follows: > > base.html > - > > {{title}} > > Header Stuff > {%block contents%}{%endblock%} > Footer Stuff > > - This is a valid Django template. > layer1.html > - > {%extends base.html%} > {%block contents%} > Layer One has cool {{noun}}. > {%block layer_special%}More layer specialization here, that will be > filled in later.{%endblock%} > Layer One closing stuff. > {%endblock%} > - This template is valid as well, but it doesn't do what you think: it extends the template that base.html evaluates to instead of extending the template named "base.html". To use the literal value "base.html", you need to put quotes around the template name: {% extends "base.html" %} > layer1-special1.html > - > {%extents layer1.html%} > {%block layer_specials%} > You need more than {{noun}}. You can be special. Sometime you gotta > {{verb}}. > {%endblock%} > - Aside from the typo ("extents" should be "extends"), this is fine. > In Python: > from django.template import Context, Template, loader > t = loader.get_template("layer1-special1.html") > c = Context( { "title":"Layer One Special One", "noun":"Stuff", > "verb":"Django" } ) > print t.render(c) > > should print: > > > Layer One Special One > > Header Stuff > > Layer One has cool Stuff. > > You need more than Stuff. You can be special. Sometime you gotta > Django. > > Layer One closing stuff. > > Footer Stuff > In that case you'll need to make sure you're using either layer_special or layer_specials as a block name. ;-) Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How to display the images in the template page under the django development server
On Fri, Jul 11, 2008 at 4:37 AM, Eric Liu <[EMAIL PROTECTED]> wrote: > When I create a app and try to show a image in the the html ,I ran > into trouble that is the images can't be shown in the page.following > is my page code: > > [...] > > [...] In HTML, the end tag of the img element must be omitted. This isn't related to your problem, but it might be nice to know. > in urls.py: > > from django.conf.urls.defaults import * > from mysite.view import current_time,ahead_hours > from django.conf import settings > > urlpatterns = patterns('', > (r'^time/$', current_time), > > (r'^site_media/(?P.*)$', 'django.views.static.serve', > {'document_root': 'D:/test/mysite/mysite_media'}), > ) This says that any URL path starting with /site_media/ will be handled by django.views.static.serve and that the text following this prefix is taken as the path to the file to be served relative to the directory D:/test/mysite/mysite_media (the document_root). This means that when a request arrives for a URL path like /site_media/PATH/TO/SOME/FILE.EXT this view function will (try to) serve the file located on disk at D:/test/mysite/mysite_media/PATH/TO/SOME/FILE.EXT So, going the other way, if you want the file D:/test/mysite/mysite_media/imgs/search.gif the URL path to use is /site_media/imgs/search.gif > and in settings.py: > MEDIA_ROOT = "D:/test/mysite/mysite_media" > MEDIA_URL = 'http://localhost:8080/mysite_media/' This MEDIA_URL doesn't match what you've specified in your URLconf. You'll want to pick one of the two. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Too many values to unpack error
On Wed, Jul 9, 2008 at 9:27 AM, Fernando Rodríguez <[EMAIL PROTECTED]> wrote: > > Hi, > > I'm getting this error while calling .as_table() on a form. This is how > I define the form and the view function: > > from django import newforms as forms > > TOPIC_CHOICES = ( ('general', 'General enquiry'), > ('bug', 'Bug report'), > ('suggestion' 'Suggestion'), > ) You're missing a comma in the last-but-one line. (It evaluates to the concatenation of the two strings, so you get a sequence with lots more than two elements.) Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Response wit File Name
On Wed, Jul 9, 2008 at 4:43 AM, jurian <[EMAIL PROTECTED]> wrote: > > Is there any way to specify the filename that a HTTPResponse will be > saved as on the browser side? > > (without using the 'Content-Disposition' header, I see many responses > with filenames that don't use this header) I think you'll find that the name the browser suggests is based on the Content-Disposition header or something that looks like a file name at the end of the URL (before the question mark and query string, if any). Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Grouping Items In Multiple Categories
On Tue, Jul 8, 2008 at 11:25 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Does anyone know of an elegant way in Django to group database items > under 2 categories. Don't know about elegant, but something like this would work: {% regroup committees by state as committee_state_list %} {% for committee_state in committee_state_list %} {{ committee_state.grouper }} {% regroup committee_state.list by committee_type as committee_type_list %} {% for committee_type in committee_type_list %} {{ committee_type.grouper }} {% for committee in committee_type.list %} {{ committee.name }} {% endfor %} {% endfor %} {% endfor %} Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: newforms-admin: root() takes exactly 3 arguments (2 given)
On Mon, Jul 7, 2008 at 6:31 PM, furby <[EMAIL PROTECTED]> wrote: > > here's my urls.py: > * > 1 from django.conf.urls.defaults import * > 2 from django.contrib import admin > 3 from wizcal.app.models import site1 > 4 > 5 urlpatterns = patterns('', > 6 # Example: > 7 # (r'^wizcal/', include('wizcal.foo.urls')), > 8 > 9 # Uncomment this for admin: > 10 (r'^admin/.*', site1.root), > 11 ) > * > > admin.site.root() takes 3 arguments: self, request, url. There is no > way to specify arguments in urls.py, so I have no idea how to fix > this. You want to capture the part of the path that' s "inside" your admin site: (r'^admin/(.*)', site1.root) This way the view gets its three arguments. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: sessions in template (outside of views)
On Mon, Jun 30, 2008 at 3:27 PM, Bobby Roberts <[EMAIL PROTECTED]> wrote: > > in my view I have: > > > from django.template import RequestContext > from django.template import Template, Context > > [... session variables set here...] > > return render_to_response('step3.html', > context_instance=RequestContext(request)) > > > and in my template i have: > >Account #: > {{ request.session.AccountNum }} > > > it prints nothing to the screen unless i explicitly pass a variable. Are you sure you have activated the request context processor? In other words, do you have something like this in your settings file? TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.request", ) There's more explanation about this in the docs here: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: sessions in template (outside of views)
On Mon, Jun 30, 2008 at 8:12 AM, Bobby Roberts <[EMAIL PROTECTED]> wrote: > > ok i'm totally lost i guess... > > in my view i setup my session variables as such... > >request.session['Street2']=request.POST.get('Street2','') >request.session['City']=request.POST.get('City','') >request.session['State']=request.POST.get('State','') >request.session['ZipCode']=request.POST.get('ZipCode','') > > and when i want to pass back to the template i am doing the following: > >return render_to_response("step2.html", 'form': form}, > context_instance=RequestContext(request)) > > now my question here is how do i pass those session variables back to > the template. If you have activated the request context processor, the request is *automatically* passed to the template. (That was the point of all this, right?) So to display the value of request.session['City'], for example, you'd use this in your template: {{ request.session.City }} Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: sessions in template (outside of views)
On Sun, Jun 29, 2008 at 9:08 AM, Bobby Roberts <[EMAIL PROTECTED]> wrote: > > So I have to explicitly pass the session variables to the template to > use them? That kind of defeats the purpose of session variables > doesn't it? If they are in session we should be able to access them > easier than passing them from view to template throughout our > application. Variables that happen to hold session data are no different from other variables. If you want to have access to a variable in a template, you'll have to make the variable available to the template somehow. You can do this by passing the variable to the template yourself, or (in some cases) you can have a context processor do that for you. This is one of those cases: you can have request.session added implicitly if you do what Daniel Roseman wrote and active the django.core.context_processors.request context processor, making sure to always use a RequestContext when rendering the template. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: intial form field values using session variables
On Fri, Jun 27, 2008 at 1:12 PM, Bobby Roberts <[EMAIL PROTECTED]> wrote: > > [...] I'm trying to print those session variables to the screen in > step 2 (ie the 2nd form) so the user can review what was previously > entered on the first fom. (If this page immediately follows the first page, you could of course take the values for the request itself.) > as an old ASP programmer when we wanted to just print a session > variable we'd code: > > <%=session("whatever")%> > > What is the django equiv? > > I'm trying this: > > {{request.session["whatever"] }} > > but it says it can't parse the remainder... Use the syntax of Django's template language: {{ request.session.whatever }} Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Newforms and textareas
On Fri, Jun 27, 2008 at 11:04 AM, Roodie <[EMAIL PROTECTED]> wrote: > > Hello, > > I have a slight problem. I am using a custom form field to do some > extra validation / filtering on a specific kind of field. The code is > very simple: > > class HtmlEditorField(forms.Textarea): >def clean(self, value): >value = filter_common( value ) >return super(HtmlEditorField, self).clean(value) This won't work. The forms.Textarea you're subclassing is a *widget*, not a *field*! > And I use this field to render the textareas: > > class RandomEditForm( ModelForm ): >description = HtmlField() > > Now the question is: where can I set the ROWS attribute for this > Textarea? See http://www.djangoproject.com/documentation/newforms/#specifying-widgets Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: ModelForm's error dict is filled before is_valid() is called
On Fri, Jun 27, 2008 at 10:39 AM, omat <[EMAIL PROTECTED]> wrote: > > At the instant I initialize my form, the errors dict is filled, > although the documentation says, the validation happens after form > instance's is_valid() method is called. > > [example snipped] > > Is the documention or the behavior wrong? Neither. As explained in the docs "the form's data will be validated the first time either you call is_valid() or access errors", see http://www.djangoproject.com/documentation/newforms/#using-forms-to-validate-data Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: intial form field values using session variables
On Fri, Jun 27, 2008 at 8:42 AM, Bobby Roberts <[EMAIL PROTECTED]> wrote: > > i'm trying to use session variables as initial values for certain form > fields as such: > >AccountNum = forms.CharField > (initial=request.session["AccountNum"],max_length=20, required=True, > label = "Account #") > > i'm getting this: > > NameError: name 'request' is not defined > > > how do i use a session variable for initial data? You can pass in an "initial" argument when you instantiate your Form, as explained here: http://www.djangoproject.com/documentation/newforms/#dynamic-initial-values Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Collecting referrers data
On Fri, Jun 27, 2008 at 3:45 AM, Alessandro <[EMAIL PROTECTED]> wrote: > So, it's possible to make a shortcut before my urls and generic views > to record referrers data? You could write some middleware to do just that. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How best to delete one of multiple records?
On Tue, Jun 24, 2008 at 4:42 AM, Spy187 <[EMAIL PROTECTED]> wrote: > > AND BTW using GET for side effects can be extremely convenient when > used for debugging purposes as you can directly modify the URL. What's convenient during development isn't necessarily a good idea in a production setting. (For example, using Django's development webserver or having DEBUG = True in your settings module.) Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: File IO Operations
On Tue, Jun 24, 2008 at 4:34 AM, aruns <[EMAIL PROTECTED]> wrote: > > is it possible to create a file/folder using django. > i want to perform all the IO operations using django. See "Reading and Writing Files" in the chapter "Input and Output" of the Python tutorial[1] and the documentation for the os module[2]. Arien [1] http://docs.python.org/tut/node9.html [2] http://docs.python.org/lib/os-file-dir.html --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: dynamic value of a ModelChoiceField
On Mon, Jun 23, 2008 at 10:34 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > here's my model: > > class Recipe(modesl.Model): > > recipetitle = models.CharField() > cooking_method = models.ForeignKey(CookingMethod) > > class CookingMethod(models.Model): > > cookmethodname = models.CharField() > > > forms.py > > class RecipeForm(forms.Form): > >title = forms.CharField() >cookmethod = > forms.ModelChoiceField(queryset=CookingMethod.objects.all()) > > views.py > > def edit_recipe(request,recipe_id): > > if request.method == "POST": >yadda yadda > >else: > recipe = Recipe.objects.get(id=recipe_id) > recipeform = RecipeForm() > recipeform.fields['title'] = recipe.recipetitle > recipeform.fields['cooking_method'] = recipe.cooking_method > > [...] when an existing recipe is being edited, the recipe title is > retrieved correctly, but the corresponding recipe cooking method is > not displayed in the html element. instead, the one > corresponding to the empty label (--) shows up. Ehhmm... Have you actually executed the code above? (You can't "assign" to a form's fields like that.) Anyway, you may want to read the documentation for newforms[1] and ModelForms[2]. Arien [1] http://www.djangoproject.com/documentation/newforms/ [2] http://www.djangoproject.com/documentation/modelforms/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How best to delete one of multiple records?
On Mon, Jun 23, 2008 at 1:51 PM, Peter Melvyn <[EMAIL PROTECTED]> wrote: > > On 6/23/08, Emil Styrke <[EMAIL PROTECTED]> wrote: > >> Having a GET request delete records is usually a bad idea - see for example >> http://www.w3.org/2001/tag/doc/whenToUseGet.html > > Yes, this is a recommendation, not a dogma. IMHO GET method is > suitable for dense tables with dozens of operations. Whether it's a good idea to use GET or not doesn't depend on presentation issues. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Trouble querying across relationships
On Wed, Jun 18, 2008 at 11:21 PM, Austin Govella <[EMAIL PROTECTED]> wrote: > I'm pulling all events for a city: > > events = Event.objects.filter(city=city) > > Each event can have a set of attractions like food, dancing, drama, > djs, live music, art, etc. > > How do I query the list of attractions for events in that city? (Query > all attractions that are tied to events in that city) You're looking for "lookups that span relationships": http://www.djangoproject.com/documentation/db-api/#lookups-that-span-relationships In this case, you want something like "filter the attractions in such a way that the name of the city of the related event is ... and eliminate duplicates in the resulting list": attractions = Attraction.objects.filter(event__city__name='...').distinct() The details depend on your exact models, but that's the idea. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: redirect with post parameters
On Wed, Jun 18, 2008 at 4:48 AM, Masklinn <[EMAIL PROTECTED]> wrote: > On 17 Jun 2008, at 18:34 , Daniel Hepper wrote: >> This is not how a redirect works. If your view returns a >> HttpResponseRedirect, Django sends a HTTP 302 code back to the browser >> along with the new URL. The browser of the user then requests the >> new URL. > > Actually, it should be possible to do it by sending an HTTP 307 > instead of a 302: > > * 302 was originally "Moved Temporarily", but implemented the wrong > way by pretty much every UA. It shouldn't, in fact, be used anymore > (unless the client only implements HTTP/1.0). Now renamed "Found" As long as it's not relevant if the UA treats the response as per 303 or per 307 semantics, there's no problem. > * 303, added in HTTP/1.1, "See Other". Indicates that the response can > be found at another URI *accessed via GET* This is sort of true, but not really. (It's similar to confusing pointers (in C) or references with values.) > * 307, added in HTTP/1.1, "Moved Temporarily", indicates that the > request should be repeated against another URI. This means that a POST > request receiving a 307 should lead to another POST request with the > same parameters (note: I'm not sure if you can ask for an alteration > of the post parameters, but I doubt it) If the request method is not "safe" (not GET or HEAD), the UA must not automatically redirect without user confirmation. This is not a solution to the original problem. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Template engine
On Fri, Jun 13, 2008 at 9:48 AM, Norman Harman <[EMAIL PROTECTED]> wrote: > Template's white space handling is one of the few things that irks me > about Django. I hate having to make confusing formating, jamming stuff > all on the same line just to get white space correct. > > I really wish it had some whitespace handling tools like Cheetah > http://www.cheetahtemplate.org/docs/users_guide_html/users_guide.html#SECTION00068 Or Template Toolkit's: http://template-toolkit.org/docs/manual/Syntax.html#section_Chomping_Whitespace Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Can Someone Do something about ALL THIS SPAM
On Thu, Jun 5, 2008 at 7:37 AM, James Matthews <[EMAIL PROTECTED]> wrote: > I hate having to remove the spam emails that come through the Django mailing > list! Is there anything we can do it? Yeah, spam is annoying. > James > > -- > http://search.goldwatches.com/?Search=Movado+Watches > http://www.jewelerslounge.com > http://www.goldwatches.com ^^^^^ Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: django_sessions table getting out of hand
On Fri, May 9, 2008 at 7:28 AM, Matt Davies <[EMAIL PROTECTED]> wrote: > What's the best method of keeping the django_sessions table from growing so > large? Well, there's django/bin/daily_cleanup.py ;-) Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Translation issues in admin app
On Fri, Apr 25, 2008 at 7:45 AM, Boris Ozegovic <[EMAIL PROTECTED]> wrote: > Croatian language has many declination rules, and therefore, only two > meta rules (verbose_name and verbose_name_plural) aren't enough. Can > I somehow modified translation rules, and have exact model word on > exact admin pages. for example, if model name is 'robot', can i have > > 'dodaj robota' on first page, and 'robot je promijenjen' on some other > > in English: > 'add robot' and 'robot has changed' No, I don't think you can do that. However, you can probably translate the phrases in such a way as to always use the same case for the model's verbose name. Something like: "add robot" -> "... ROBOTA" "robot changed" -> "... ROBOTA" (meaning: "[the user has] changed robot") I'm guessing you'll end up giving your models verbose names in the accusative ("robota") instead of in the nominative ("robot")... But at least it will be pretty on the outside. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---