order_with_respect_to and edit_inline in MR
Hi, I switched my code over to M-R this past weekend and was surprised that it went pretty smoothly. There are a couple things in my models that aren't working anymore though. The first is order_with_respect_to. I have an inline edited object that I want to order with respect to its related object. I have this in my model: class Link(models.Model): date = models.ForeignKey(NewsList, edit_inline = models.TABULAR) ... class Meta: order_with_respect_to = 'date' I have dom-drag.js in the appropriate place, but ordering isn't working in the admin interface anymore. I could probably figure this out by diving into the source but was hoping someone could give me a quick answer here first. Even when I remove dom-drag, it doesn't display an ordering box like it used to. The other thing that doesn't work anymore is customizing the edit_inline interface by subclassing BoundRelatedObject. I remember mention back in February that Jacob was working on changing this, but I haven't been following the list closely enough to keep up with this and I can't find anything from searching the archive. Thanks for your help! Colleen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: MySQL + FastCGI + Dreamhost = Trouble with foreign key in admin
Okay, I figured out what the SQL query is that's causing this error: INSERT INTO `polls_choices` (`poll_id`,`choice`,`votes`,`_order`) VALUES (7, `not much`, 0,(SELECT COUNT(*) FROM `polls_choices` WHERE `poll_id` = 7)) ERROR 1093 (HY000): You can't specify target table 'polls_choices' for update in FROM clause According to mysql, it's version 5.0.18-standard-log. This error occurs if I issue this query directly to my database. So, is this a mysql bug, or is there something obviously wrong about the query? This is a big problem for me right now as it affects all foreign keys edited inline in my models. Thanks for any help anyone can provide. I'm supposed to have this installed to show the prototype to a client on Monday and this is kind of a show stopper. Colleen Colleen Owens wrote: > I'm not sure what query the admin interface is sending exactly, but I > was able to reproduce this at the command line with just these simple > commands. (I'm not sure--is there some easy way to spit out the SQL > associated with these commands?) > > >>> from django.models.polls import polls > >>> from datetime import datetime > >>> p = polls.Poll(question="What's up?", pub_date=datetime.now()) > >>> p.save() > >>> p.add_choice(choice='Not much', votes=0) > Traceback (most recent call last): > File "", line 1, in ? > File "/home/coowwa/src/django/django/utils/functional.py", line 3, in > _curried > return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + > morekwargs.items())) > File "/home/coowwa/src/django/django/core/meta/__init__.py", line > 1192, in method_add_related > obj.save() > File "/home/coowwa/src/django/django/utils/functional.py", line 3, in > _curried > return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + > morekwargs.items())) > File "/home/coowwa/src/django/django/core/meta/__init__.py", line > 1026, in method_save > ','.join(placeholders)), db_values) > File "/home/coowwa/src/django/django/core/db/base.py", line 10, in > execute > result = self.cursor.execute(sql, params) > File "/home/coowwa/src/django/django/core/db/backends/mysql.py", line > 32, in execute > return self.cursor.execute(sql, params) > File > "/home/coowwa/local/lib/python2.4/site-packages/MySQLdb/cursors.py", > line 137, in execute > self.errorhandler(self, exc, value) > File > "/home/coowwa/local/lib/python2.4/site-packages/MySQLdb/connections.py", > line 33, in defaulterrorhandler > raise errorclass, errorvalue > _mysql_exceptions.OperationalError: (1093, "You can't specify target > table 'polls_choices' for update in FROM clause") > >>> > > Julio Nobrega wrote: > > Can you paste the query here? I think the problem is an unsupported > > feature by Mysql... Do you have another Mysql install to test? > > > > On 3/2/06, Colleen Owens <[EMAIL PROTECTED]> wrote: > > > > > > I forgot to say this is with current Django trunk. > > > > > > -- Forwarded message -- > > > From: Colleen Owens > > > Date: Thu, 02 Mar 2006 03:34:08 - > > > Subject: MySQL + FastCGI + Dreamhost = Trouble with foreign key in > > > admin > > > To: "Django users" <django-users@googlegroups.com> > > > > > > I'm getting an error when I try to modify a foreign key edited inline > > > in the admin interface using MySQL + FastCGI on a Dreamhost account. I > > > get the same type of error when I try to modify a Poll object (with > > > inline Choices) from the tutorial, so I know it's not my model that's > > > the problem. > > > > > > I've tried this with sqlite3 running on my local machine and I have no > > > problem with editing these models. I see from the chat logs that > > > someone else was having this problem a week or two ago, but he didn't > > > seem to figure it out (he switched to postgres and said that everything > > > worked fine). Unfortunately mysql is the easiest option on Dreamhost. > > > > > > OperationalError at /admin/polls/polls/add/ > > > (1093, "You can't specify target table 'polls_choices' for update in > > > FROM clause") > > > Request Method: POST > > > Request URL:http:///admin/polls/polls/add/ > > > Exception Type: OperationalError > > > Exception Value:(1093, "You can't specify target table > > > 'polls_choices' for update in FROM clause") > > > Exception Location: > > > > > > /home/coowwa/local/lib/python2.4/site-packages/MySQLdb/connections.py > > > in defaulterrorhandler, line 32 > > > > > > > > > > > > > > > > > > -- > > Julio Nobrega - http://www.inerciasensorial.com.br --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: MySQL + FastCGI + Dreamhost = Trouble with foreign key in admin
I'm not sure what query the admin interface is sending exactly, but I was able to reproduce this at the command line with just these simple commands. (I'm not sure--is there some easy way to spit out the SQL associated with these commands?) >>> from django.models.polls import polls >>> from datetime import datetime >>> p = polls.Poll(question="What's up?", pub_date=datetime.now()) >>> p.save() >>> p.add_choice(choice='Not much', votes=0) Traceback (most recent call last): File "", line 1, in ? File "/home/coowwa/src/django/django/utils/functional.py", line 3, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "/home/coowwa/src/django/django/core/meta/__init__.py", line 1192, in method_add_related obj.save() File "/home/coowwa/src/django/django/utils/functional.py", line 3, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "/home/coowwa/src/django/django/core/meta/__init__.py", line 1026, in method_save ','.join(placeholders)), db_values) File "/home/coowwa/src/django/django/core/db/base.py", line 10, in execute result = self.cursor.execute(sql, params) File "/home/coowwa/src/django/django/core/db/backends/mysql.py", line 32, in execute return self.cursor.execute(sql, params) File "/home/coowwa/local/lib/python2.4/site-packages/MySQLdb/cursors.py", line 137, in execute self.errorhandler(self, exc, value) File "/home/coowwa/local/lib/python2.4/site-packages/MySQLdb/connections.py", line 33, in defaulterrorhandler raise errorclass, errorvalue _mysql_exceptions.OperationalError: (1093, "You can't specify target table 'polls_choices' for update in FROM clause") >>> Julio Nobrega wrote: > Can you paste the query here? I think the problem is an unsupported > feature by Mysql... Do you have another Mysql install to test? > > On 3/2/06, Colleen Owens <[EMAIL PROTECTED]> wrote: > > > > I forgot to say this is with current Django trunk. > > > > -- Forwarded message -- > > From: Colleen Owens > > Date: Thu, 02 Mar 2006 03:34:08 - > > Subject: MySQL + FastCGI + Dreamhost = Trouble with foreign key in > > admin > > To: "Django users" <django-users@googlegroups.com> > > > > I'm getting an error when I try to modify a foreign key edited inline > > in the admin interface using MySQL + FastCGI on a Dreamhost account. I > > get the same type of error when I try to modify a Poll object (with > > inline Choices) from the tutorial, so I know it's not my model that's > > the problem. > > > > I've tried this with sqlite3 running on my local machine and I have no > > problem with editing these models. I see from the chat logs that > > someone else was having this problem a week or two ago, but he didn't > > seem to figure it out (he switched to postgres and said that everything > > worked fine). Unfortunately mysql is the easiest option on Dreamhost. > > > > OperationalError at /admin/polls/polls/add/ > > (1093, "You can't specify target table 'polls_choices' for update in > > FROM clause") > > Request Method: POST > > Request URL:http:///admin/polls/polls/add/ > > Exception Type: OperationalError > > Exception Value:(1093, "You can't specify target table > > 'polls_choices' for update in FROM clause") > > Exception Location: > > > > /home/coowwa/local/lib/python2.4/site-packages/MySQLdb/connections.py > > in defaulterrorhandler, line 32 > > > > > > > > > > > -- > Julio Nobrega - http://www.inerciasensorial.com.br --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: MySQL + FastCGI + Dreamhost = Trouble with foreign key in admin
I forgot to say this is with current Django trunk. -- Forwarded message -- From: Colleen Owens Date: Thu, 02 Mar 2006 03:34:08 - Subject: MySQL + FastCGI + Dreamhost = Trouble with foreign key in admin To: "Django users" <django-users@googlegroups.com> I'm getting an error when I try to modify a foreign key edited inline in the admin interface using MySQL + FastCGI on a Dreamhost account. I get the same type of error when I try to modify a Poll object (with inline Choices) from the tutorial, so I know it's not my model that's the problem. I've tried this with sqlite3 running on my local machine and I have no problem with editing these models. I see from the chat logs that someone else was having this problem a week or two ago, but he didn't seem to figure it out (he switched to postgres and said that everything worked fine). Unfortunately mysql is the easiest option on Dreamhost. OperationalError at /admin/polls/polls/add/ (1093, "You can't specify target table 'polls_choices' for update in FROM clause") Request Method: POST Request URL:http:///admin/polls/polls/add/ Exception Type: OperationalError Exception Value:(1093, "You can't specify target table 'polls_choices' for update in FROM clause") Exception Location: /home/coowwa/local/lib/python2.4/site-packages/MySQLdb/connections.py in defaulterrorhandler, line 32 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
MySQL + FastCGI + Dreamhost = Trouble with foreign key in admin
I'm getting an error when I try to modify a foreign key edited inline in the admin interface using MySQL + FastCGI on a Dreamhost account. I get the same type of error when I try to modify a Poll object (with inline Choices) from the tutorial, so I know it's not my model that's the problem. I've tried this with sqlite3 running on my local machine and I have no problem with editing these models. I see from the chat logs that someone else was having this problem a week or two ago, but he didn't seem to figure it out (he switched to postgres and said that everything worked fine). Unfortunately mysql is the easiest option on Dreamhost. OperationalError at /admin/polls/polls/add/ (1093, "You can't specify target table 'polls_choices' for update in FROM clause") Request Method: POST Request URL:http:///admin/polls/polls/add/ Exception Type: OperationalError Exception Value:(1093, "You can't specify target table 'polls_choices' for update in FROM clause") Exception Location: /home/coowwa/local/lib/python2.4/site-packages/MySQLdb/connections.py in defaulterrorhandler, line 32 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: custom admin view for edit_inline object
On 11 Feb, 2006, at 06.55, Robert Wittams wrote: > I do not know how to make it any clearer than that. MyBoundRelatedObject > is a class. > > You do *not* need to make up a new constant like TABULAR. It is purely a > mechanism that allows people to specify the tabular view or whatever > without making the core system depend on the admin code. Okay, I get it now. Sorry, I need to read more carefully. It would save me a lot of time. Colleen
Re: custom admin view for edit_inline object
On 09 Feb, 2006, at 13.21, Robert Wittams wrote: > > The overrides stuff is just to allow TABULAR and STACKED to continue to > work, without meaning that the core django has a dependency on the admin > code. > > As you are defining your own class, that shouldn't matter for you, you > can just use the class directly, eg > > from path.to.custom.admin.code import MyBoundRelatedObject > > class Whatever(Model): > parent = ForeignKey(edit_inline=MyBoundRelatedObject) > > I really didn't document this very well at all. It would be great if you > could write a paragraph or two when you get this working, and submit it > for inclusion in the docs. > PS > Jacob is currently changing this code. So it might be that all this gets > broken in the near future, as the plan seems to be to abandon non-AJAX > edit inline AFAIK. I'd be happy to write this up once I get it working. The problem I'm having right now is that there seems to be no elegant way of updating the dictionary bound_related_object_overrides in admin_modify.py to let it know about additional view types. I can, of course, edit it directly in admin_modify, but this isn't very nice. Any suggestions? All ideas I can come up with involve changing the admin code. Colleen
Re: custom admin view for edit_inline object
> There is a simple way to create special admin templates for one object. > See > http://code.djangoproject.com/wiki/NewAdminChanges#Adminconvertedtoseparatetemplates > > HTH, > Edgars Thanks for the link, I hadn't seen this before. I basically derived the same solution on my own, except that I added a new section of the change_form template that could be overridden. Colleen
Re: custom admin view for edit_inline object
So I'm replying to my own message here, but I want to tell you how I did this in case a) someone wants to show me a better way b) it could be useful to someone Again, what I'm trying to do is customize the way inline-edited objects are displayed for one of my applications (without affecting any other application). First I changed line 52 of django/contrib/admin/templates/admin/change_form.html to read: {% for related_object in bound_manipulator.inline_related_objects %}{% block related_object_display %}{% edit_inline related_object %}{% endblock %}{% endfor %} (i.e. I added the block and endblock tags). Then I created another change_form.html file in my template directory that simply contains: {% extends "admin/change_form" %} {% block related_object_display %}{% include "admin/news/edit_news_inline" %}{% endblock %} admin/news/edit_news_inline simply points to my custom template that contains the code I want. I'll customize the url rewrite to point to the default change_form for all applications, but my news application will point to my new change_form. Does this seem like a reasonable way to do this? I still don't quite have a handle on all this so sometimes I feel like I'm doing things in a very convoluted way. Thanks. Colleen
Re: application level settings
On 1/11/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote: On 1/11/06, Colleen Owens <[EMAIL PROTECTED]> wrote:> My latest question - I want to have some settings that apply to an> application (not the objects within that application's model but to the > application as a whole). For example, I want to have options like the> maximum number of objects that should be displayed and various display> options that are set by the system administrator through the admin > interface. I know I can do this by writing some basic Python code and a> custom view for the admin interface. This seems like a more general problem> though, so I was wondering if Django has some built-in way of handling this. Hey Colleen,I'm not sure this answers your question, but feel free to make up yourown settings. See the docs here: http://www.djangoproject.com/documentation/settings/#creating-your-own-settingsAdrian This isn't exactly what I'm looking for. This would work, but it doesn't seem very elegant. I want the administrator of this site to be able to modify nearly everything through the admin interface. At the moment, I'm thinking about just creating a Configuration class for my app (and forcing it to be a singleton) and storing that in the database. This still feels a little clumsy, but I think it will work. Colleen
scheduling capabilities?
And another question quick on the heels of the last one...Does Django have any built-in scheduling capabilities, like "run X every 15 minutes"? Or should I stick with Twisted for that? Thanks again. Colleen
application level settings
Hi. First I want to thank everyone for answering my really basic questions. The responses I've gotten here have been extremely helpful. I'm starting to get the hang of Django a little bit and I love it so far. My latest question - I want to have some settings that apply to an application (not the objects within that application's model but to the application as a whole). For example, I want to have options like the maximum number of objects that should be displayed and various display options that are set by the system administrator through the admin interface. I know I can do this by writing some basic Python code and a custom view for the admin interface. This seems like a more general problem though, so I was wondering if Django has some built-in way of handling this. Thanks! Colleen
Fwd: customizing appearance of foreign key edited inline
I'm resending this question because I'm still having trouble figuring this out. I'm interested in customizing how a inline-edited foreign key appears in the admin interface. Is there some way to do this? Thanks.-- Forwarded message --From: Colleen Owens <[EMAIL PROTECTED]>Date: Jan 4, 2006 1:17 PM Subject: customizing appearance of foreign key edited inlineTo: django-users@googlegroups.comHi, I'm having trouble figuring out how to customize the appearance of a foreign key that's edited inline in the admin interface. For example, if I wanted to change how the poll choices from the tutorial are displayed, by suppressing the number of votes, or changing the order in which the votes and choices are displayed, is there a way to do this? Thanks. Colleen
Re: help passing data from view to template
Okay, yeah this was a dumb question, foolishly asked before I got through part 4 of the tutorial. I see now that calling get_link_list from within my template will do what I need. I didn't realize that get_link_list would preserve ordering.On 12/21/05, Colleen Owens <[EMAIL PROTECTED]> wrote: I'm a Django newbie. This follows up on a question I asked before and a very helpful answer to on this list. So I have a list of dates and for each date I have a list of link objects I want to display. I'm trying to figure out how to best pass this data from my view to the template. I tried this and several variations on this, but I'm not properly accessing the variable keys that I'm passing into my Context object. I guess what I really don't understand is what can be passed into the template and how it's accessed. All the examples I could find just pass in very simple lists. def index(request): date_list = newslists.get_list(order_by=["-date"]) args = {'date_list': date_list} for date in date_list: dateids = date.get_link_order() datelinks = [] for id in dateids: datelinks.append(links.get_object(id__exact = id)) args[] = datelinks t = loader.get_template('news/index') c = Context(args) return HttpResponse(t.render(c)) (nevermind that even if this worked, the list wouldn't be very pretty) {% for date in date_list %} {{ date }} {% for link in date %} {{ link.title }} {% endfor %} {% endfor %} Thanks for your help! Colleen