Re: Changing the "name" of a DB object & displaying the ID

2007-07-26 Thread Andreas Pfrengle
Hi Matt, I don't know about the behaviour of 1to1 fields, but did you just try it with class Admin: pass like in ? Then the model should be editable in the admin Or if you want to change the __str__ (which should afaik be

Re: DB-Lookup on dynamically created fieldname

2007-07-25 Thread Andreas Pfrengle
...it can really be that easy. Thanks Doug. :) --~--~-~--~~~---~--~~ 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

i18n: newform validation errors: some translate, some not

2007-10-06 Thread Andreas Pfrengle
Hello Djangonauts, I was making a form for a german language site, so any errors that are thrown during the validation of a newform *should* be translated into german. the request.LANGUAGE_CODE is 'de', and it's also working for *some* of the errors, but not for all. To test this, I've put up a

Re: i18n: newform validation errors: some translate, some not

2007-10-07 Thread Andreas Pfrengle
Hello Malcolm, > Are the error strings in question in the > django/conf/local/de/LC_MESSAGES/django.po file and are they translated > there (i.e. "msgstr" is not just the empty string)? I've looked through the django.po file and think there's the reason for it. Some msgids for the error messages

Re: Django Browser Games?

2007-10-08 Thread Andreas Pfrengle
Here, next one in the line :) Fantasy-strategy-roleplaying-MMOG (German/English). Not openly developed (and not much developed at all yet), but I wonder if we are possibly all writing similar chunks of code ;) Andreas --~--~-~--~~~---~--~~ You received this

Re: Multilanguage - I know what I want, should I do it this way?

2007-10-12 Thread Andreas Pfrengle
AFAIK there is no possibility to use mulitple column primary keys in django. But I don't think you need them. If you don't wan't to use other tables with fks, you could use sth like this: class Foo(models.Model): title = models.CharField() content = models.TextField() language =

Re: Need help with related objects.

2007-10-12 Thread Andreas Pfrengle
Perhaps you should provide your full models, since day as well as worker in class WorkingDay refer to a model called Notary. I'm probably also not sure what you are trying to describe with your models - but shouldn't worker in WorkingDay refer to your class worker (btw: call it Worker with big W,

Re: How to find out if a string is contained within another string

2007-10-15 Thread Andreas Pfrengle
> I'm thinking that I might have to create a for loop, which loops > through every Discounter record and checks to see if the 'code' > variable is in the 'message variable. Depending on the number of your Discounter-records, this can result in many queries. Perhaps instead you could take every

Re: How to find out if a string is contained within another string

2007-10-16 Thread Andreas Pfrengle
Since I haven't much experience with regex, I also can't give you the solution right away. Perhaps you have to try a bit: http://docs.python.org/lib/re-syntax.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

dumpdata from values set by model's __init__

2007-10-21 Thread Andreas Pfrengle
Hello group, I've stumbled upon sth. where I'm not sure if this is an intended behaviour or not. I tried to dump my db-data to a json-fixture and load it again, where I got the error that a float-value can't be converted to Decimal (using postgres with psycopg2). I traced the problem back and

Re: dumpdata from values set by model's __init__

2007-10-22 Thread Andreas Pfrengle
Hello Malcolm, thanks again for your immediate answer, that makes it clearer to me how dump/loaddata works. I thought the data in the fixture would be written directly to the db, but it makes sense to do this via instantiating Testtable again, calling again the __init__, and hence calculating a

How do navigate through frames / framesets from a view?

2007-10-28 Thread Andreas Pfrengle
Depending on the user's input in a form, I want to redirect to a view that's content should be rendered in a corresponding target frame (this can be either content in a "content"-frame or a new frameset in "_top" if the user chooses a new personal layout). Is it possible to do this via

Re: How do navigate through frames / framesets from a view?

2007-10-29 Thread Andreas Pfrengle
Hmm, that's fine if I know in advance where the form should lead to - I could even do this with a template variable {{ target }} I suppose. But what if the same form contains the information what the target should be? Somehow I think I'd have to do some AJAX / Javascript workaround, both of which

Re: How to make such query with django ORM?

2007-11-28 Thread Andreas Pfrengle
> I need to get all blogs that belong to certain user and are empty (do > not have any articles). I can't figure out how to make it with without > extra() method. Here's a solution that should give you a list (not a QuerySet) of all the blogs. Don't know if this is best practice though. You can

Choices of ChoiceFields dependent on other ChoiceField in admin interface

2007-12-08 Thread Andreas Pfrengle
Hello group, I wanna use the admin interface for manipulating the db-data. I have a hierarchy of categories and products that shall belong to one or more categories. Here are the models I currently have: class Category(models.Model): name = models.CharField(max_length=30) parent =

Noob question: Which Linux distribution is "best" for Django?

2007-12-09 Thread Andreas Pfrengle
Hello, till now I've been experimenting with Django (development version) under Win2k. But Windows sucks. So I dare to make my first steps with Linux. Most of you will surely say I won't regret this decision ;-). But since I haven't any experience with Linux yet, I want to choose a distribution

Re: Noob question: Which Linux distribution is "best" for Django?

2007-12-11 Thread Andreas Pfrengle
Thanks for so many replies and the helpful links. Ubuntu really seems to be a good solution as far as I can tell by now. I'll give it a try. At least now I know what I will do on Christmas :-) --~--~-~--~~~---~--~~ You received this message because you are

Re: Noob question: Which Linux distribution is "best" for Django?

2007-12-12 Thread Andreas Pfrengle
VMware is free as are the > appliances. > > I use ubuntu primarily. > > j > > On Dec 9, 9:57 am, Andreas Pfrengle <[EMAIL PROTECTED]> wrote: > > > Hello, > > > till now I've been experimenting with Django (development version) > > under Win2k. But Wi

Re: How to modify every element in a list all at once

2007-12-17 Thread Andreas Pfrengle
You have to convert s.price.name to float (or .9 to a DecimalObject if the float-precision should be a problem). This should work: for s in s2: s.price.name = float(s.price.name) * .9 s.price.save() On Dec 16, 8:43 pm, Greg <[EMAIL PROTECTED]> wrote: > Shabda, > I added the

Re: Choices of ChoiceFields dependent on other ChoiceField in admin interface

2007-12-21 Thread Andreas Pfrengle
On Dec 8, 11:40 pm, Andreas Pfrengle <[EMAIL PROTECTED]> wrote: > Hello group, > > I wanna use the admin interface for manipulating the db-data. I have a > hierarchy of categories and products that shall belong to one or more > categories. Here are the models I currently h

"syncdb --database=xxx" not working

2011-12-31 Thread Andreas Pfrengle
Hello, I've tried to setup a project that supports two different databases, a postgres-db and a mysql-db. The DATABASES-setting is configured properly with a 'default' key for the mysql-db and 'pg' for the postgres. However, if I try to syncdb the postgres-db, manage.py accesses the 'default'

Django AJAX polling: Best practice?

2011-06-30 Thread Andreas Pfrengle
Hello everyone, We have a game-application where several players should interact in realtime (i.e. change attributes of a "game"-object, which is a django model instance). To my knowledge, best / easiest method for this problem would be AJAX-polling several times per second, to check whether the

Re: Django AJAX polling: Best practice?

2011-07-01 Thread Andreas Pfrengle
Thanks so far for showing me that I was on the completely wrong track ;-) I found that there is really not much official information available about Hookbox: . That doesn't make an easy decision for Hookbox. Has anyone experience with socket.io and gevent instead? Looks

Add attributes (css-class) to formfield

2011-07-13 Thread Andreas Pfrengle
Hello, I know about assigning attributes to widgets, like shown here: or here: However, I want to assign an additional attribute

Re: Add attributes (css-class) to formfield

2011-07-13 Thread Andreas Pfrengle
Hello Shawn, thanks for your answer, however that's not exactly what I wanted. Now the html renders to: No. of properties However, I would want: No. of properties Additionally, I can't access {{ field.widget.attrs.div_css }} to get the class directly, I get

Re: Add attributes (css-class) to formfield

2011-07-13 Thread Andreas Pfrengle
Hello Andre, it took me some time, but since I couldn't get insight in suggestion 1) and 2) really seemed too ugly, I've discovered an intermediate solution. I came around it when trying to make suggestion 2) a little less ugly, and after all it's still quite easy ;-) 3) Write a template-filter

Re: Add attributes (css-class) to formfield

2011-07-15 Thread Andreas Pfrengle
Tom, it's really so easy, thank you! Seems now I've learned the hard way how forms and fields are working ;-) Andreas -- 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

Loop over a form's choices (radio button) and render it

2010-08-07 Thread Andreas Pfrengle
Hello, what I want to do is to add a radio button into the last column of a data table. The user shall be able to select exactly one of the table's rows. I was thinking about defining a SelectForm with one 'select'-field (ChoiceField) with a RadioSelect-widget. In the template, I would then need

Re: Loop over a form's choices (radio button) and render it

2010-08-07 Thread Andreas Pfrengle
Thinking about it, instead of the radio button it would be even better if I could select just the whole datarow. But I have no idea how to do it :-? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Loop over a form's choices (radio button) and render it

2010-08-11 Thread Andreas Pfrengle
Just to push it up again... any ideas? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com.

Re: Loop over a form's choices (radio button) and render it

2010-08-14 Thread Andreas Pfrengle
Hello Bill, thanks for your answer. However, I've never written a template filter yet. Would you present the code of your checkboxiterator? Is there sth. on djangosnippets? Andreas -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: Loop over a form's choices (radio button) and render it

2010-08-22 Thread Andreas Pfrengle
Hello Bill, thanks for the code. It took half the weekend, but finally I built upon this to get a radiobutton-iterator. This was a bit more complicated, since the RadioInput widget has no own render-method, so I needed to introduce a helper class that derives from RadioInput. I've put the code

import model from other module

2010-07-18 Thread Andreas Pfrengle
Hello, is there a possibility to import a model into models.py from any other module? In my models.py I'm trying to do: #models.py: from _external_modules.django_timer import Tim #django_timer.py: from django.db import models print 'test' class Tim(models.Model): This should import a

Re: import model from other module

2010-07-20 Thread Andreas Pfrengle
I've tried it with and without installing in settings.INSTALLED_APPS, didn't work, table wasn't created vis syncdb. > This might be the info you're > missing:http://docs.djangoproject.com/en/dev/ref/models/options/#app-label This seems to work, however, since I want to use my external modules

Re: import model from other module

2010-07-20 Thread Andreas Pfrengle
I've tried it with and without installing in settings.INSTALLED_APPS, didn't work, table wasn't created vis syncdb. > This might be the info you're > missing:http://docs.djangoproject.com/en/dev/ref/models/options/#app-label This seems to work, however, since I want to use my external modules

Re: import model from other module

2010-07-22 Thread Andreas Pfrengle
David, thanks for the explanation. It suddenly reminds me of the django tutorials or first chapters I've read probably 3 years ago. That's surely the right way to do it. I will try that next week. -- You received this message because you are subscribed to the Google Groups "Django users" group.

Django doesn't load css

2010-07-28 Thread Andreas Pfrengle
Hi, we've been trying for hours now to include a css-file in our project, but it just doesn't work and we don't know why. We've already reduced the project to the absolute minimum of necessary code: #settings.py: PROJECT_PATH =

Re: Django doesn't load css

2010-07-28 Thread Andreas Pfrengle
Hello Kostia, I get a template syntax error with your method, since I haven't defined a "static" view. How does your static-view look like? I've already tried it like described here --> but I don't get it work either, I get a TypeError: bad operand type for unary +: 'list' for the urlpattern

Re: Django doesn't load css

2010-07-28 Thread Andreas Pfrengle
Hallo everyone, thanks for the many answers, the problem is solved. There must have been an error in the urls.py. Now it works with the static serving: # from urls.py: site_media = os.path.join(os.path.dirname(__file__), 'site_media') urlpatterns += patterns('', url(r'^site_media/(?P.*)$',

request.LANGUAGE_CODE-sensitive choices in forms.ChoiceField?

2010-01-07 Thread Andreas Pfrengle
Hello, I am trying to implement a ChoiceField that's choices shall be calculated during form instantiation in the view depending on the users preferred language (according to request.LANGUAGE_CODE from LocaleMiddleware). Example forms.py: CHOICES = zip( [x.number for x in

Re: request.LANGUAGE_CODE-sensitive choices in forms.ChoiceField?

2010-01-07 Thread Andreas Pfrengle
On 7 Jan., 13:22, Tomasz Zieliński <tomasz.zielin...@pyconsultant.eu> wrote: > On Jan 7, 1:04 pm, Andreas Pfrengle <a.pfren...@gmail.com> wrote: > > > > > Hello, > > > I am trying to implement a ChoiceField that's choices shall be > > calculated du

Re: request.LANGUAGE_CODE-sensitive choices in forms.ChoiceField?

2010-01-07 Thread Andreas Pfrengle
On 7 Jan., 13:22, Tomasz Zieliński <tomasz.zielin...@pyconsultant.eu> wrote: > On Jan 7, 1:04 pm, Andreas Pfrengle <a.pfren...@gmail.com> wrote: > > > > > Hello, > > > I am trying to implement a ChoiceField that's choices shall be > > calculated du

Re: request.LANGUAGE_CODE-sensitive choices in forms.ChoiceField?

2010-01-09 Thread Andreas Pfrengle
On 7 Jan., 18:17, Tom Evans <tevans...@googlemail.com> wrote: > 2010/1/7 Andreas Pfrengle <a.pfren...@gmail.com>: > > > However I'm wondering how I would transform this concept on Formsets. > > I think I would somehow need to expand already the formsets __init_

Re: Possibility of recursive rendering

2010-01-10 Thread Andreas Pfrengle
On 10 Jan., 10:42, Amit Sethi wrote: > Hi I wish  to know if it is possible to use recursive rendering ? . What I > mean by that is that their is a template which renders no of comments on a > paragraph . SInce their are many paragraphs what i wish to send is  a list >

text in translation strings?

2010-01-10 Thread Andreas Pfrengle
Hello, I'm having a template, where a link shall be inside a translation- marked text. I see two ways how to accomplish this, but both don't work: 1. {% trans "You need to login before you can do anything" %} I get an template syntax error: "Searching for value. Unexpected end of string"

Re: text in translation strings?

2010-01-11 Thread Andreas Pfrengle
> {% url login as login_url %} > {% blocktrans %}You need to login before > you can do anything {% endblocktrans %} > > I'm curious if this is good guess, so please let me know. It works! Didn't know that the url tag can name its result with "as". Thanks again :-) -- You received this message

Re: NoReverseMatch:

2010-01-17 Thread Andreas Pfrengle
Your urls.py needs to contain sth. like that: urlpatterns = patterns('your_app.views', url(r'^the_url_you_want_for_tellfriend$', 'name_of_viewfunction', name='tellfriend'), ) the last argument, name='tellfriend', is what the {% url %} tag is searching for in your urlpatterns, and

Re: List as filterinput, possible?

2010-01-17 Thread Andreas Pfrengle
You could try myDevices = Device.objects.filter(group__in=groups) see: http://docs.djangoproject.com/en/1.1/ref/models/querysets/#in -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

How to lazy-sort a list of translation strings alphabetically

2010-01-17 Thread Andreas Pfrengle
For a multilingual project, I have a ChoiceField and want to display the choices in alphabetical order - according to the current language. Example: choices = ((1, _('Some choice')), (2, _('Another choice')), (3, _('One more choice'))) In English it should be ordered 'Another choice', 'One more

Multilingual project with applications in different default-languages

2010-01-17 Thread Andreas Pfrengle
We are working on a django-project that shall support several languages. i18n works so far, translation strings are marked, po-files can be created and LocaleMiddleware is also installed. We've decided to start with German as default locale (so all translation strings in python code and templates

Re: NoReverseMatch:

2010-01-17 Thread Andreas Pfrengle
attern r'^refer/$', maybe that's the reason? > > On Jan 17, 8:40 am, Andreas Pfrengle <a.pfren...@gmail.com> wrote: > > > Your urls.py needs to contain sth. like that: > > > urlpatterns = patterns('your_app.views', > >     url(r'^the_url_you_want_for_tellfri

Re: NoReverseMatch:

2010-01-17 Thread Andreas Pfrengle
> I am putting same pattern because both tellfriend and hero belongs to > same template. > > refer template has two form. Okay, so want to display two forms on one template and want some logic that depends on which of the two "Submit" buttons the user pressed. Is that assumption right? urls.py

Re: How to lazy-sort a list of translation strings alphabetically

2010-01-26 Thread Andreas Pfrengle
On 25 Jan., 20:36, Matthias Kestenholz wrote: > Alternatively, you could write your own Field or > Widget which implements the sorting -- it's not that hard. I was just starting to write "It doesn't work" when I found this here:

Re: Multilingual project with applications in different default-languages

2010-01-27 Thread Andreas Pfrengle
Hello Matthias, > It is possible, but you _will_ get a chaos (or have already gotten one > in case you've already gone down that road). thanks for pointing me onto the painful truth. We _have_ the chaos... but it's not that big yet ;-) > If you need to fix > the english version later, the

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-10 Thread Andreas Pfrengle
On 5 Feb., 09:21, Ken Chida wrote: > I tried my best to search for an answer but my efforts yielded nothing.   > Allow me to give you a simple example to illustrate my problem.  Let's > pretend that I want to have a login form on every single page on my > website.  Obviously,

values_list of ordered annotated QuerySet

2011-03-18 Thread Andreas Pfrengle
Hello, I want to annotate a Queryset, order it by the annotated field and then return a simple (ordered) values_list of the ids of the objects: Wizard.objects.filter(**filterargs).annotate(wpower=Sum('creatures__power')).order_by('- wpower').values_list('id', flat=True) The 'Creature'-Model has

Re: values_list of ordered annotated QuerySet

2011-03-22 Thread Andreas Pfrengle
just pulling it up again... -- 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

Re: values_list of ordered annotated QuerySet

2011-03-22 Thread Andreas Pfrengle
Thank you, it works! :-) -- 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

Creating a number array in a model?

2007-06-03 Thread Andreas Pfrengle
Hi all, I'm looking for a good possibility to handle integer and decimal arrays in a database. I'm using postgresql, which seems to have array types; but since I'm not very familiar with sql (or databases at all), I won't like to fall back to code it directly. So is there any other easy way to

Re: newb: Model DateTimeField and Timedelta

2007-07-03 Thread Andreas Pfrengle
I'd suggest: from datetime import datetime, timedelta p = Post() # create an instance of Post # p.created_at should now be a datetime-object to python p.created_at + timedelta(weeks=2)# will also be a datetime object see also: http://docs.python.org/lib/module-datetime.html

DB-Lookup on dynamically created fieldname

2007-07-24 Thread Andreas Pfrengle
Hello group, I have some models in my app that have several fields. First, my code picks dynamically one of the models from a string-variable, sth. like: mdl = eval(model_name), where model_name contains the name the model. Then, I want to lookup a field in that model, but again I also only got