Re: Limiting a ForeignKey to a subset of values

2010-05-05 Thread Javier Guerra Giraldez
On Thu, May 6, 2010 at 1:03 AM, Xavier Ordoquy wrote: > Hi, > > I currently have a foreign key for which the model should allow the selection > of a subset of objects depending on another object value. > > Let's say model A has a foreign key on model B. Model A & B have a field > called restrict

Re: Make MPs answer to us

2010-05-05 Thread Darren Mansell
On 6 May 2010 07:41, Darren Mansell wrote: > > > On 6 May 2010 00:35, Russell Keith-Magee wrote: > >> On Thu, May 6, 2010 at 3:04 AM, Darren Mansell >> wrote: >> > >> > It's election day tomorrow. This is a great web site for lots of info >> about what's really going on: >> > [http://www.38degr

Re: Make MPs answer to us

2010-05-05 Thread Darren Mansell
On 6 May 2010 00:35, Russell Keith-Magee wrote: > On Thu, May 6, 2010 at 3:04 AM, Darren Mansell > wrote: > > > > It's election day tomorrow. This is a great web site for lots of info > about what's really going on: > > [http://www.38degrees.org.uk] > > This is a forum about using Django. The si

Limiting a ForeignKey to a subset of values

2010-05-05 Thread Xavier Ordoquy
Hi, I currently have a foreign key for which the model should allow the selection of a subset of objects depending on another object value. Let's say model A has a foreign key on model B. Model A & B have a field called restriction. For a given A object, I'd like to display B objects that have

Django 1.2 release candidate available

2010-05-05 Thread James Bennett
Tonight we're proud to announce, finally, the first Django 1.2 release candidate. If all goes well, it will also be the *only* release candidate, and Django 1.2 final will release one week from today. For more information, consult: * The Django project weblog: http://www.djangoproject.com/weblog/

Re: Variable-length forms

2010-05-05 Thread Peter
Thanks. I'd totally misread what that page was about. Now I see it's basically what I want. Cheers. On May 4, 9:02 am, Shawn Milochik wrote: > http://docs.djangoproject.com/en/1.1/topics/forms/formsets/ > > That ought to help out. > > Shawn > > -- > You received this message because you are su

Using the FormWizard with models

2010-05-05 Thread Wiiboy
Hi guys, Another question about the FormWizard: is it possible to provide an existing instance of a model for the forms in the wizard? -- 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

Re: Can I map authenticated users to specific databases via a database Router?

2010-05-05 Thread Russell Keith-Magee
On Thu, May 6, 2010 at 7:58 AM, Parker wrote: > I'm trying to port part of an existing application to Django.  In the > other application, each user has their data stored on separate > databases with identical schemas. > > For example, if we have users A, B and C, there are 3 databases > ("Databas

Can I map authenticated users to specific databases via a database Router?

2010-05-05 Thread Parker
I'm trying to port part of an existing application to Django. In the other application, each user has their data stored on separate databases with identical schemas. For example, if we have users A, B and C, there are 3 databases ("DatabaseA", "DatabaseB", "DatabaseC") each having two tables: blo

Re: Make MPs answer to us

2010-05-05 Thread Russell Keith-Magee
On Thu, May 6, 2010 at 3:04 AM, Darren Mansell wrote: > > It's election day tomorrow. This is a great web site for lots of info about > what's really going on: > [http://www.38degrees.org.uk] This is a forum about using Django. The site you reference is in no way relevant to that topic (as far a

set_cookie seemingly adding double quotes to cookie value

2010-05-05 Thread Keijik
Hi, I'm pretty new to Django development. I have a page where I set some cookies based on responses to a POST. I'm finding that for certain values, set_cookie is resulting in the cookie value being enclosed in double quotes. This seems to happen for longer values with non-alphanumeric characters

Admin pre-save hooks

2010-05-05 Thread Thomas Neumeier
Hi, I've got two apps, called A and B. A has a model called X and B has model called Y. B hooks into the X's save-Method via the pre_save-Signal and throws an IntegrityError under dertain conditions. Everything like in: http://docs.djangoproject.com/en/dev/ref/signals/#ref-signals This works p

Password reset email sent several times

2010-05-05 Thread newbiedjango
Hi All, I am using the django-registration app and when try to send a password reset email it sends 5 mails at once when its suppose to send it only once. Can anyone who has faced this problem or anyone who knows how to rectify this. I am a newbie in django so please go easy. Many Thanks -- You

Disabling (or find a workaround for) the comment security checks

2010-05-05 Thread Federico Capoano
Hello to all, I've just launched my new web-site powered by django and i'm very satisfied. I've implemented StaticGenerator to improve the performance and loading speed and I have to admit is brilliant. Unfortunately i've noticed the comment system doesn't work. This happens because the pages of

Re: Template not displaying validation errors [solved]

2010-05-05 Thread mhulse
Hi Karen! Thanks so much for your quick reply, I really appreciate it. :) > form.is_valid() is what annotates the existing form with error information > in the case where there are errrors. However, if form.is_valid() returns > False, the code here immediately overwrites the existing (now annotate

Re: Template not displaying validation errors

2010-05-05 Thread Karen Tracey
On Wed, May 5, 2010 at 6:04 PM, mhulse wrote: >if form.is_valid(): # All validation rules pass. > ># Q objects/pagination here... > >else: > >form = SearchForm() > form.is_valid() is what annotates the existing form

Template not displaying validation errors

2010-05-05 Thread mhulse
Hi, I have spent half the day googling and testing my code with no luck getting an error message to appear via my template. I am hoping ya'll could provide a little assistance. :) forms.py: class SearchForm(forms.Form): q = forms.CharField( max_length = 128,

Re: Django ValidationError for DateField

2010-05-05 Thread Karen Tracey
On Wed, May 5, 2010 at 5:33 PM, LeeRisq wrote: > This is mostly me just venting, but why is it if you run a query like > this: > > a = Model.objects.get(pk=1) > > Which has an attribute with an output of: > > a.date = None > > I pass that to a template, change some other attribute and then > atte

Re: Noob questions: Syntax, Python listserv, utility/helper methods?

2010-05-05 Thread mhulse
> HTH, Very much so! Thanks so much Peter, I really appreciate your help. :) One last question: I have been working with django-schedule (just been doing the templating) and I noticed that the author of that code prepended underscores to all of his included files: ... _detail.html _dialogs.html

Django ValidationError for DateField

2010-05-05 Thread LeeRisq
This is mostly me just venting, but why is it if you run a query like this: a = Model.objects.get(pk=1) Which has an attribute with an output of: a.date = None I pass that to a template, change some other attribute and then attempt to pass it back in: date = request.GET['a.date'] b = Model.obj

Re: QuerySet.distinct and aggregates

2010-05-05 Thread Wedg
The Beta name field is actually an FK to another model, like this: Payment (Alpha) <- AppliedPayment (Gamma) -> Invoice (Beta) -> Location (Name) The actual call I had tried was Payment.objects.filter(appliedpayment__invoice__location=loc).distinct().aggregate(Sum('amount')) (where amount is a

Re: Getting object representing the current user

2010-05-05 Thread Daniel Roseman
On May 5, 9:30 pm, Paul wrote: > I have the following model (stripped of comments and __unicode__ for > brevity) which defines  a comment in my Django app (I'm not using the > comment module provided with Django for various reasons): > > class Comment(models.Model): >   comment = models.TextField(

Getting object representing the current user

2010-05-05 Thread Paul
I have the following model (stripped of comments and __unicode__ for brevity) which defines a comment in my Django app (I'm not using the comment module provided with Django for various reasons): class Comment(models.Model): comment = models.TextField() added_by = models.ForeignKey(User) ad

Re: permissions at per specific object instance

2010-05-05 Thread Dj Gilcrease
On Wed, May 5, 2010 at 4:09 PM, zweb wrote: > I need to build "permissions at per specific object instance" for my > app. > > Anyone has already done it ?  Also it says django developers are > already discussing it.. > > You can please refer me to the threads or blog posts on it. http://djangoadv

Re: permissions at per specific object instance

2010-05-05 Thread Peter Herndon
http://packages.python.org/django-authority/ or, an alternative: http://pypi.python.org/pypi/django-objectpermissions/ ---Peter Herndon On May 5, 2010, at 4:09 PM, zweb wrote: > "Permissions are set globally per type of object, not per specific > object instance. For example, it's possible to

permissions at per specific object instance

2010-05-05 Thread zweb
"Permissions are set globally per type of object, not per specific object instance. For example, it's possible to say "Mary may change news stories," but it's not currently possible to say "Mary may change news stories, but only the ones she created herself" or "Mary may only change news stories th

Re: cascade deletion happens before pre_delete signal is sent?

2010-05-05 Thread msoulier
On Apr 3, 6:23 pm, Tomasz Zieliński wrote: > I believe that this question was asked on this group a long time ago, > and the answer was that pre_delete signal was fired *before* actual > deletion occured, > but *after* objects were collected for deletion (i.e. after list of > objects that were to

Re: QuerySet.distinct and aggregates

2010-05-05 Thread zinckiwi
I'd try both and compare the processing time. What is the nature of the Beta.name equivalent in your actual model? If it is a simple field (e.g. INT) I doubt the overhead would be too bad. What might be tripping me up is having your Gamma being linked to your Alpha through an intermediate model. Si

Open source CMS (if based on Django better)

2010-05-05 Thread Jonatan.mv
What would be you recommended CMS?. Could you please give some reasons (pro and cons)?. I'm investigating on these: - PyLucid v0.8.x stable, v0.9 alpha - FeinCMS v1.1.0 stable - django-simplecms - django-cms-2.0 2.0.2 stable , 2.1 alpha - google-sites By the way... I like how google-sites work,

How to override a method in auth backend.py

2010-05-05 Thread lray
We store groups/ roles in another table due to legacy reasons. I need to override following method in auth backend, by my own method to get permissions from a custom role permission table. How can I do it? >>> override following method to get permissions from legacy table >>> role_permissions

Re: Syntax for displaying field values from parent model(s) in a template?

2010-05-05 Thread Daniel Roseman
On May 5, 6:27 pm, Derek wrote: > I  have set of models, with relationships D -> C -> B -> A, where the > "->" indicates a "many to one" relationship. > > I have been able to create a filtered queryset on child model D, based > on a value in a parent model A, using the following syntax: > > my_que

Make MPs answer to us

2010-05-05 Thread Darren Mansell
It's election day tomorrow. This is a great web site for lots of info about what's really going on: [http://www.38degrees.org.uk] Darren -- 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...@googlegro

Re: How to adapt some code provided by friend

2010-05-05 Thread Frank
I hate to chime in here but I recently started using Django, quite successfully. I'm also a consent-student. I fear that you are going to have a lot of trouble using Django (or anything like it) if you don't build some basics. To successfully use a product like Django, basic knowledge of at least

Syntax for displaying field values from parent model(s) in a template?

2010-05-05 Thread Derek
I have set of models, with relationships D -> C -> B -> A, where the "->" indicates a "many to one" relationship. I have been able to create a filtered queryset on child model D, based on a value in a parent model A, using the following syntax: my_query = D.objects.filter(C__B__A__name__icontain

Altering object order in formsets with can_order

2010-05-05 Thread Paulo Almeida
Hi, I'm having a hard time grasping the concept of the can_order argument, when creating formsets. Once objects are created and saved through the formset, is it possible to reorder them? Where does the order information get stored? I tried just adding can_order=True when creating the formset (it's

Re: QuerySet.distinct and aggregates

2010-05-05 Thread Wedg
> qs = Alpha.objects.filter(gamma__beta__name='Beta').distinct()) > id_list = [x.id for x in qs] > total = > Alpha.objects.filter(id__in=id_list).aggregate(total=models.Sum('id')).get('total') I'm sure this approach would work fine, however I feel like it might be a performance issue when the Alph

Re: AdminField Rendering Question

2010-05-05 Thread geraldcor
Oh of course. Probably the one file I didn't look at. I think a subclass is in order. Thank you very much for the direction. Greg On May 5, 5:01 am, patrickk wrote: > there you > go:http://code.djangoproject.com/browser/django/trunk/django/contrib/adm... > > unfortunately, it´s all hardcoded. i

Re: django_audit 0.0.2

2010-05-05 Thread Dj Gilcrease
On Wed, May 5, 2010 at 10:49 AM, Gustavo Narea wrote: > On May 5, 3:45 pm, Dj Gilcrease wrote: >> I also think Euan Goddard has already registered django-audit on pypi >> (http://pypi.python.org/pypi/django-audit/0.9/) > > That's what I meant, Euan and I work together :) Ahh ok, well I wont be

Re: [ANN] django_nav 0.6

2010-05-05 Thread Dj Gilcrease
Now in PYPI http://pypi.python.org/pypi/django_nav/ -- 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...@googl

Re: How to alter the value of a field in admin pages and turn off-autoescaping

2010-05-05 Thread Massimiliano della Rovere
I wanted the date in this format: %A %d %B %Y %H:%M:%S I found a solution to point #2: format_data = re.compile(r'(?<=\d)\s(?=[A-Za-z])|(?<=[A-Za-z])\s(?=\d)', re.LOCALE | re.UNICODE) list_display = ('x',) def x(self, row): return mark_safe(format_data.sub(' ', formats.localize(row.call_sta

Re: django_audit 0.0.2

2010-05-05 Thread Gustavo Narea
On May 5, 3:45 pm, Dj Gilcrease wrote: > I also think Euan Goddard has already registered django-audit on pypi > (http://pypi.python.org/pypi/django-audit/0.9/) That's what I meant, Euan and I work together :) - Gustavo. -- You received this message because you are subscribed to the Google Gr

Re: django_audit 0.0.2

2010-05-05 Thread Dj Gilcrease
On Wed, May 5, 2010 at 10:06 AM, Gustavo Narea wrote: > Hello, > > I would suggest you try to register "django_audit" on PYPI and see if > it allows you to do so. > > We had already registered the package"django-audit" (note the hyphen > instead of an underscore, which is exactly how we've always

[ANN] django_nav 0.6

2010-05-05 Thread Dj Gilcrease
Code @ http://code.google.com/p/django-nav/ This is a bug fix release to make conditionals work again. Before 1.0 is ready to go I want to add the ability to dynamically generate nav manus either via a DB, Config file, Cache, etc. -- You received this message because you are subscribed to the G

Re: Insert model data into every page (base.html)

2010-05-05 Thread Bill Freeman
See: http://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors On Wed, May 5, 2010 at 10:06 AM, Martin Tiršel wrote: > Hello, > > I need to insert some data from database onto every page, so I inserted them > into base.html. Until now, I was using generic views but it doesn'

Re: change an object from parent to child

2010-05-05 Thread Steve Bywater
Here is a realistic example: I have a model Employee that is a subclass of User, the standard django authentication class, and a model called Supervisor that subclasses Employee. I have Bob, an instance of Employee, that I want to promote to Supervisor. So trying to move the Bob object to the chil

Re: django_audit 0.0.2

2010-05-05 Thread Gustavo Narea
Hello, I would suggest you try to register "django_audit" on PYPI and see if it allows you to do so. We had already registered the package"django-audit" (note the hyphen instead of an underscore, which is exactly how we've always spelled it). I'm not sure if PYPI will let you register "django_aud

Insert model data into every page (base.html)

2010-05-05 Thread Martin Tiršel
Hello, I need to insert some data from database onto every page, so I inserted them into base.html. Until now, I was using generic views but it doesn't seems to be ideal for this case. Is there a way how to achieve this behaviour with generic views or I have to insert needed model into ever

Re: django_audit 0.0.2

2010-05-05 Thread Euan Goddard
On May 4, 11:21 am, Dj Gilcrease wrote: > Google code wont let me change the project name without deleting and > recreating the project so I just added a note to the top That is quite annoying. I hope you can find a good solution to that problem. > "This is a fairly comprehensive Audit Trail App

Re: Empty foreign keys in forms after Apache/PostgreSQL reset

2010-05-05 Thread Xanthus
On May 5, 7:54 am, Tom Evans wrote: > On Wed, May 5, 2010 at 5:54 AM, Xanthus wrote: > > Hi all. I will try do my best to explain my setup and the sequence of > > actions triggering the issue: > > > 1. Machine starts and all is fine. > > 2. We do the following operations (through and automated sc

Re: QuerySet.distinct and aggregates

2010-05-05 Thread zinckiwi
> In [29]: > Alpha.objects.filter(gamma__beta__name='Beta').values('id').aggregate(model > s.Sum('id')) > Out[29]: {} > > In [30]: > Alpha.objects.filter(gamma__beta__name='Beta').values('name').aggregate(mod > els.Sum('id')) > Out[30]: {} That's odd -- I would have expected #29 to work (though

Re: How to adapt some code provided by friend

2010-05-05 Thread Daniel Roseman
On May 5, 1:05 pm, Etienne Python wrote: > Well actually, I copied all of the data (including the database), not only > the code. But indeed, like you say, the problem is not solved yet just by > installing mysql. > > So I followed the alternative solution you suggested. Now I get another > error

Re: How to adapt some code provided by friend

2010-05-05 Thread Etienne Python
Well actually, I copied all of the data (including the database), not only the code. But indeed, like you say, the problem is not solved yet just by installing mysql. So I followed the alternative solution you suggested. Now I get another error actually: when I run ./manage.py syncdb like you sug

Re: Django encoding

2010-05-05 Thread Karen Tracey
On Wed, May 5, 2010 at 6:17 AM, Lukáš wrote: > Hey, > > I have a little problem with django encoding. I have got everything in > the DB set as utf8. Now when I get them from db with django, the > encoding gets broken. For some reason django "thinks" (maybe knows) > the data is latin1, which would

Re: How to adapt some code provided by friend

2010-05-05 Thread Etienne Python
ok, I have done that now, but I'm affraid I still get the same result... :-( On May 5, 1:26 pm, "ge...@aquarianhouse.com" wrote: > install MySQLdb :) > > On May 5, 1:23 pm, Etienne Python wrote: > > > > > > > On May 5, 12:42 pm, Daniel Roseman wrote: > > > > On May 5, 11:06 am, Etienne Python

Re: How to adapt some code provided by friend

2010-05-05 Thread Daniel Roseman
On May 5, 12:23 pm, Etienne Python wrote: > > File "c:\python26\lib\site-packages\django\db\backends\mysql\base.py", > line 13, in >    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) > django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb > module: No module named

Re: How to adapt some code provided by friend

2010-05-05 Thread ge...@aquarianhouse.com
install MySQLdb :) On May 5, 1:23 pm, Etienne Python wrote: > On May 5, 12:42 pm, Daniel Roseman wrote: > > > > > On May 5, 11:06 am, Etienne Python wrote: > > > > Hey all, > > > > I'm a real beginner at both Django and Python, so excuse me if my > > > question looks silly to you. > > > > A fri

Re: How to adapt some code provided by friend

2010-05-05 Thread Etienne Python
On May 5, 12:42 pm, Daniel Roseman wrote: > On May 5, 11:06 am, Etienne Python wrote: > > > > > > > Hey all, > > > I'm a real beginner at both Django and Python, so excuse me if my > > question looks silly to you. > > > A friend of mine did me a huge favour by coding a form for me. > > However,

Re: Admin custom filters

2010-05-05 Thread tom
sorry to interrupt with no solution, but I have a similar problem: I wnat to allow choosing mutiple choises : year = 2003 OR year = 2007 or, year = 2003 AND year = 2007. (something like checkbox) I guess one can implement the filter from scratch, but I think there is might be a way to add this func

Re: AdminField Rendering Question

2010-05-05 Thread patrickk
there you go: http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/widgets.py#L88 unfortunately, it´s all hardcoded. if you need to customize the widget, you may want to write your own and subclass the given one. hope that answers your question. regards, patrick On 5 Mai, 01

Django encoding

2010-05-05 Thread Lukáš
Hey, I have a little problem with django encoding. I have got everything in the DB set as utf8. Now when I get them from db with django, the encoding gets broken. For some reason django "thinks" (maybe knows) the data is latin1, which wouldnt be a problem if I would tell him to use latin1, which f

Re: Empty foreign keys in forms after Apache/PostgreSQL reset

2010-05-05 Thread Tom Evans
On Wed, May 5, 2010 at 5:54 AM, Xanthus wrote: > Hi all. I will try do my best to explain my setup and the sequence of > actions triggering the issue: > > 1. Machine starts and all is fine. > 2. We do the following operations (through and automated script): > a. stop Apache > b. stop Postgresql >

How to alter the value of a field in admin pages and turn off-autoescaping

2010-05-05 Thread Massimiliano della Rovere
1st question) I am trying to change the way some of DateTimeField are displayed in the change_list page of the admin site (django 1.2 svn): how to do it? Not knowing which method to define or override in the ModelAdmin class, I opted for a different solution: I added a string in the list_display t

Re: How to adapt some code provided by friend

2010-05-05 Thread Daniel Roseman
On May 5, 11:06 am, Etienne Python wrote: > Hey all, > > I'm a real beginner at both Django and Python, so excuse me if my > question looks silly to you. > > A friend of mine did me a huge favour by coding a form for me. > However, I would like to modify a couple of details in the page. > > I have

How to adapt some code provided by friend

2010-05-05 Thread Etienne Python
Hey all, I'm a real beginner at both Django and Python, so excuse me if my question looks silly to you. A friend of mine did me a huge favour by coding a form for me. However, I would like to modify a couple of details in the page. I have copied the code and the folders linked to the website to

Managing JS and CSS. Performance by grouping external files

2010-05-05 Thread Jonatan.mv
Thinking in performance (reduce HTTP request) I'm working on the idea that that each page includes just one JS and one CSS with the required modules in inside. ¿Do you know any tool to achieve this? ¿How do you recommend to manage external JS and CSS? I read some about pyjamas but it seem to be co

Re: Customize what's a NULL for legacy data

2010-05-05 Thread Ole Laursen
On May 4, 8:08 pm, Ole Laursen wrote: > The problem is that if I try to access foo.bar in any way, Django > tries to lookup a bar with id 0 or -1 and throws an exception. My > forms break, and the serializers break, making it hard to write test > code. Does anyone know of an easy way to get around

Re: Working out some custom API stuff

2010-05-05 Thread Daniel Roseman
On May 5, 4:46 am, Nick wrote: > Here's the deal. I'm working on a custom API for moving information > about. I am stuck at a point in creating my view. > It might be best just to get into the details. > > Here is the model: > > class entry(models.Model): >     question = models.CharField('Questio

Re: SCORM(Sharable Content Object Reference Model) Compliant for Django?

2010-05-05 Thread Zeal
Thanks Skylar. django-scorm-rest-rte has really less documentation for studying. Maybe, SCORM is not the hot technology for LMS. Does anyone use any else LMS technology with Django in the world? I think LMS is really a hot topic in the future, and even now. If there is any possibility to ship LMS