please help me to solve the anchor tag issue
Hi.. I want to implement "HELP" in my project. For time being i am planning to do a general help by including all help contents in the same html file(say for example-help.html). My application contains some 10 pages (search page, login page, form submit page, report page,...etc ) with a Help-Button. When clicking on help button, i want to show the content in the HELP page regarding the particular page accessed by the enduser. Example: --- help.html file seems to be {% extends "base.html" %} {% block content %} Search 1. 2. 3. Report 1. 2. 3. etc. {% endblock %} --- If a user click help button from the report page, then it should show the Report section from the help.html. Its just like a anchor tag used to navigate within one page. Can anyone help me out? thanks in advance... --~--~-~--~~~---~--~~ 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: Issue with saving existing model when using inlineformsets
additional info: The error happens in formset.save() --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Issue with saving existing model when using inlineformsets
All, I have an issue with using InlineFormSets. Save of a new model goes without any issue. However, I have a problem with saving an existing model. When I save I get a KeyError without much info. Other than it happened in "/usr/lib/python2.5/site-packages/django/ forms/models.py in save_existing_objects". I noticed an older ticket that talked about the form.id missing on the template. If I am correct managementform takes care of that. I'd appreciate some pointers on this issue. Maeck ### View code class ClassPaymentProductForm(ModelForm): class Meta: model = ClassPaymentProduct class ClassPaymentForm(ModelForm): class Meta: model = ClassPayment def edit_classpayment(request, classpayment_id=None): # View parameters Form= ClassPaymentForm InlineForm = ClassPaymentProductForm Model = ClassPayment InlineModel = ClassPaymentProduct template= 'test.html' data_id = classpayment_id if data_id == None: data = Model() else: data = Model.objects.get(id = data_id) InlineFormSet = inlineformset_factory(Model, InlineModel, can_delete=True) if request.method == "POST": mainform= Form(request.POST, instance=data) formset = InlineFormSet(request.POST, request.FILES, instance=data) if mainform.is_valid() and formset.is_valid(): mainform.save(request) formset.save() if '_save' in request.POST: return HttpResponseRedirect('/test/') if '_addanother' in request.POST: return HttpResponseRedirect('../add/') else: mainform= Form(instance=data) formset = InlineFormSet(instance=data) return render_to_response(template, { 'mainform' : mainform, 'formset' : formset, }) ### Template {% for f in formset.management_form %} {{ f }} {% endfor %} {% for field in formset.forms.0 %} {% if not field.is_hidden %} {{ field.label }} {% endif %} {% endfor %} {% for f in formset.forms %} {% for field in f %} {% if not field.is_hidden %} {{ field }} {% endfor %} --~--~-~--~~~---~--~~ 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: How to embed django into a custom web server
On Dec 13, 12:05 pm, Jim wrote: > Hi, > > I'm experimenting with building a web server with embedded python and > I'd like to setup and include Django. The server works by loading a > main python script into memory at startup and then script registers a > callback routine to handle incoming messages. The script looks > something like this: > > import MyWebServer > > # Initialization code > > def my_callback(connection_name, request, size): > MyWebServer.sendReply(connection_name, 'hello world', 11) > > MyWebServer.set_callback(my_callback) > > First of all, does this seem like a reasonable approach? Second, what > do I need to do to setup the Django environment using this > architecture? Make your web server support WSGI API standard and then you can just use Django WSGI interface. The WSGI specification is documented at: http://www.python.org/dev/peps/pep-0333/ Graham --~--~-~--~~~---~--~~ 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: No documentation link on admin interface.
On Fri, 2008-12-12 at 19:51 -0600, James Bennett wrote: > On Fri, Dec 12, 2008 at 6:24 PM, Malcolm Tredinnick > wrote: > > which isn't as far out of bounds as it looks. You get there from the 1.0 > > release notes, to the porting document, which then links to that page. > > But, for people coming directly to Django 1.0, we've missed something. > > I'll fix that when I get a chance. > > The default root URLConf created by 'django-admin.py startproject' > also includes a pattern for this; you still need to have the admindocs > app in INSTALLED_APPS for the default templates to be picked up, but > it's a start. True. I'd forgotten that. > If you've got other stuff to hack on, I can put together some docs and > commit them over the weekend. Go for it, then. I'm not running out of things to do. Thanks. :-) Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to embed django into a custom web server
Hi, I'm experimenting with building a web server with embedded python and I'd like to setup and include Django. The server works by loading a main python script into memory at startup and then script registers a callback routine to handle incoming messages. The script looks something like this: import MyWebServer # Initialization code def my_callback(connection_name, request, size): MyWebServer.sendReply(connection_name, 'hello world', 11) MyWebServer.set_callback(my_callback) First of all, does this seem like a reasonable approach? Second, what do I need to do to setup the Django environment using this architecture? Thanks in advance, Jim --~--~-~--~~~---~--~~ 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: No documentation link on admin interface.
On Fri, Dec 12, 2008 at 6:24 PM, Malcolm Tredinnick wrote: > which isn't as far out of bounds as it looks. You get there from the 1.0 > release notes, to the porting document, which then links to that page. > But, for people coming directly to Django 1.0, we've missed something. > I'll fix that when I get a chance. The default root URLConf created by 'django-admin.py startproject' also includes a pattern for this; you still need to have the admindocs app in INSTALLED_APPS for the default templates to be picked up, but it's a start. If you've got other stuff to hack on, I can put together some docs and commit them over the weekend. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: model string reprentations
On Fri, 2008-12-12 at 09:50 -0500, Karen Tracey wrote: > On Fri, Dec 12, 2008 at 7:33 AM, ben852 wrote: > > Hi, > I am new to django and programming. > I have a problem with the method _str_( ). > Following the tutorial, I edited my models.py file in > mysite/books and > wrote: > [snip] > > The fact that you are using __str__ instead of __unicode__ indicates > you are using a very old release of Django. If you are just starting > out you should really start with the latest 1.0.2 release, it is a > much better base to learn and build on, with many significant feature > additions, countless bugs fixed, and API stability. I hate to write this, since it will no doubt complicate the situation, but ... Whilst using __unicode__ is preferable in some respects (will certainly lead to neater code), Django also handles using __str__ in models. The developer is responsible for ensuring that __str__ returns UTF-8 encoded "str" objects, but it's actually the __str__ method that is called in a lot of cases. Internally, the default Model.__str__ checks for a __unicode__ method and calls that, encoding the output as UTF-8. So using __str__ isn't illegal or anything -- but the original poster's code will fail as written the first time somebody uses non-ASCII characters in their name, since it's not encoding the output. Regards, Malcolm > --~--~-~--~~~---~--~~ 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: Django templates and new lines
On Fri, 2008-12-12 at 02:33 -0800, pihentagy wrote: > Hi all! > > I ran into the problem mentioned here: > http://groups.google.com/group/django-users/browse_frm/thread/c9e569f7370c9c80/3b645501e9b67aa8 > > Does anybody know whether anything happened after that thread? The situation hasn't changed. With good reason: it's hard. See http://groups.google.com/group/django-users/browse_thread/thread/e473b1bea4c6774f/53c1630222f249d3 for a recent re-emergence, with some brief explanation by me as to why it's hard. Regards, Malcolm --~--~-~--~~~---~--~~ 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: No documentation link on admin interface.
On Fri, 2008-12-12 at 16:05 -0800, waltbrad wrote: > I'm using 1.0 -- I keep reading that there is supposed to be one in > the upper right hand corner. I finally had to use Google images to > find an illustration. > > But I don't have that link displayed. I do have the "change > password / logout" links, but not the doc link. > > Can anybody throw me a hint? The documentation for this has fallen through the cracks since it was split off from the admin interface (before 1.0). Add django.contrib.admindocs to your INSTALLED_APPS list. Then add (r'^admin/doc/', include('django.contrib.admindocs.urls')), to your URL Conf file. This is documented here: http://code.djangoproject.com/wiki/NewformsAdminBranch#Movedadmindocviewsintodjango.contrib.admindocs which isn't as far out of bounds as it looks. You get there from the 1.0 release notes, to the porting document, which then links to that page. But, for people coming directly to Django 1.0, we've missed something. I'll fix that when I get a chance. Regards, Malcolm --~--~-~--~~~---~--~~ 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: No documentation link on admin interface.
On Dec 12, 2008, at 5:05 PM, waltbrad wrote: > > I'm using 1.0 -- I keep reading that there is supposed to be one in > the upper right hand corner. I finally had to use Google images to > find an illustration. > > But I don't have that link displayed. I do have the "change > password / logout" links, but not the doc link. > > Can anybody throw me a hint? > > Thanks. The admin documentation requires docutils to be installed. http://docutils.sourceforge.net/ > > --~--~-~--~~~---~--~~ 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: Reducing the number of my view's database queries
On Fri, 2008-12-12 at 10:29 -0800, erikcw wrote: > Thanks for all of the responses. Just wanted to share where I'm at at > this point: [... *argh* my eyes!...ok, snipped...] > This seems to work. If you know of any performance tweaks I'd love to > hear about them (however it is incredibly fast compared to my original > solution). > > The only problem is that "zz" throws a database error. > (OperationalError: (1054, "Unknown column 'start_rank' in 'field > list'")) - ant ideas how I can get "zz" working? All the above looks quite long and involved, so if it works better for you, great. I'm not going to wade through it all. If things get slower, reducing it to a simpler example would help. :-) As for the database error, you can't do that in SQL: your "zz" column depends on start_rank, which is another output column (a column that appears only in the select statement). You can only use what are called "input columns" in computed columns: which basically means direct table columns and results of nested selects in FROM clauses. This allows database servers to be *much* more efficient, since they don't have to process the select columns until the very last moment and they don't have to work recursively. Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
No documentation link on admin interface.
I'm using 1.0 -- I keep reading that there is supposed to be one in the upper right hand corner. I finally had to use Google images to find an illustration. But I don't have that link displayed. I do have the "change password / logout" links, but not the doc link. Can anybody throw me a hint? Thanks. --~--~-~--~~~---~--~~ 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: apache+mod_wsgi+django problem with objects which stay in memory
On Dec 13, 10:18 am, vytautas wrote: > [Fri Dec 12 13:27:07 2008] [error] Model read finished. Duration > 1.2693259716 > [Fri Dec 12 13:27:07 2008] [error] Model validity check skipped > [Fri Dec 12 13:27:09 2008] [error] Model read finished. Duration > 1.23547005653 > [Fri Dec 12 13:27:09 2008] [error] Model validity check skipped > [Fri Dec 12 13:27:18 2008] [error] Model read finished. Duration > 1.28153181076 > [Fri Dec 12 13:27:18 2008] [error] Model validity check skipped > > here we have one object, every time that object is recreated, and here > is a reason why we lost a data. > program working with scheme of my program is samething like that: > > step1->step2->step3->result > > and in every step I update the data, and from this data I get the > info wich is necassary for future, but when apache became the request > from server, then the object, in which I save data, are recreated and > my data is lost:/ > my object is dictonarie. > > my english is broken, sorry =] Which is why am not 100 percent what you mean. Anyway, read: http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading Apache on UNIX is a multi process web server. If you are making modifications to objects cached in memory in a request handler and then expecting you to see changes for all subsequent requests, it will not work, as subsequent requests could be against a different process. Apache and/or mod_wsgi may also recycle processes depending on configuration and so if you don't have an external persistence mechanism such that data survives across process lifetime, also will not work. Graham --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
apache+mod_wsgi+django problem with objects which stay in memory
[Fri Dec 12 13:27:07 2008] [error] Model read finished. Duration 1.2693259716 [Fri Dec 12 13:27:07 2008] [error] Model validity check skipped [Fri Dec 12 13:27:09 2008] [error] Model read finished. Duration 1.23547005653 [Fri Dec 12 13:27:09 2008] [error] Model validity check skipped [Fri Dec 12 13:27:18 2008] [error] Model read finished. Duration 1.28153181076 [Fri Dec 12 13:27:18 2008] [error] Model validity check skipped here we have one object, every time that object is recreated, and here is a reason why we lost a data. program working with scheme of my program is samething like that: step1->step2->step3->result and in every step I update the data, and from this data I get the info wich is necassary for future, but when apache became the request from server, then the object, in which I save data, are recreated and my data is lost:/ my object is dictonarie. my english is broken, sorry =] Thanks for help! Vytautas --~--~-~--~~~---~--~~ 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: custom distinct() method
Russell, > Song.objects.values('artist').distinct(). I'm nothing less than extremely thankful for a great support! Wish that all would go well for You! best regards, james --~--~-~--~~~---~--~~ 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: Multiple sites - same code, different templates
On 12 déc, 13:14, will0 wrote: > Hi all > > I can't figure out how to change TEMPLATE_DIRS according to the URL > used. > > My purpose is to view two versions of the same site, e.g. mysite/v1/ > and mysite/v2/, but keep the same codebase. This is just for > development so people in several countries can view the site and put > in their opinion. The simplest solution would be to use 2 different settings files - IIRC, you can specify the setting file to use in the apache config. (snip) > Perhaps there's a way to pick up the HTTP request parameters in > settings? Nope, definitively. --~--~-~--~~~---~--~~ 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: How can I set column headers in AdminSite?
Hi, Thanks a lot, of course this helped. I just missed that code example somehow. Regards, Piotr --~--~-~--~~~---~--~~ 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: Multiple sites - same code, different templates
On 12 déc, 13:33, "Ramdas S" wrote: > just a suggestion > > if it is just the templates you can write a loop inside in settings.py > based on site_id > (snip) > Pardon me if I didn't understand your question. Nope. The OP is talking of using different templates for the same site. --~--~-~--~~~---~--~~ 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: How can I set column headers in AdminSite?
On Fri, Dec 12, 2008 at 4:41 PM, 3lancer.eu wrote: > > Hi, > > Django-newbie needs your help, sorry for the lame question, but I > couldn't find the answer in docs. > > I have such a class: > > class GalleryAdmin(admin.ModelAdmin): >list_display = ('randomPhoto', '__unicode__', 'photoCount', > 'public') >list_display_links = ('randomPhoto', '__unicode__') > > in list_display: > - randomPhoto is a callable > - photoCount is a callable > - public is a regular field > > I want to change the column headers on the list page for the > callables, to, say 'Example photo' and 'Number of photos'. Use the short_description attribute of the callable (be it a method or a function) as shown in the examples in the relevant section of the documentation: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display (Strangely enough the attribute is only described in the code examples and is mentioned in part 2 of the tutorial. Maybe it's a good time to submit patch for the documentation to remediate this.) HTH, -- Ramiro Morales --~--~-~--~~~---~--~~ 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: "Legal" way to have foreign key field in the custom form
Thank you very much for the help. It have finally solved the problem. BTW, one issue was left - the plus icon redirected to the creation page instead of opening popup. I've solved it by including the directly in my template, but it's strange since my template extends the "admin/change_form.html". On Dec 12, 9:05 pm, Jeff FW wrote: > You're passing your queryset in, but you're never using it in your > widget. In my code, see how I have: > > widgets.CategorySelect( > categories=models.Category.objects.order_by('parent', > 'list_order') > ), > > I don't have the code on hand for my CategorySelect widget, but I > remember that it takes "categories", and turns it into a list of > choices, which then get passed to Select.__init__() as "choices". > Since you're just using a Select() directly, you'd want to pass the > choices in there. Here's a simple list comprehension that you may > have to adapt a little to do that: > > [(t.id, unicode(t)) for t in queryset.all()] > > That assumes that you add "queryset" as an argument to __init__(), > which you should probably do. > > -Jeff > > On Dec 12, 1:06 pm, Eugene Mirotin wrote: > > > I was busy for several days and could give it a try only now. Thank > > you for the answer, but I still can't make it work. > > I have the model called Tournament and the model called > > TournamentResult which has foreign keys Team and Tournament. > > > What I'm doing is a page for bulk upload of the results for the > > specific tournament that should be selected from the drop-down > > > At the moment my code looks like this: > > > class TournamentChoiceField(forms.ModelChoiceField): > > def __init__(self, *args, **kwargs): > > super(TournamentChoiceField, self).__init__(*args, **kwargs) > > self.widget = admin_widgets.RelatedFieldWidgetWrapper( > > forms.Select(), > > TournamentResult._meta.get_field('tournament').rel, > > admin.site, > > ) > > > class UploadFormInitial(forms.Form): > > tournament = TournamentChoiceField(Tournament.objects.all()) > > > But I don't see any values in the drop-down list. > > > On Dec 9, 3:55 pm, Jeff FW wrote: > > > > To get the plus icon back, you need to wrap the field in a > > > RelatedFieldWidgetWrapper. Here's an example from my code--obviously, > > > you'll have to adapt it to fit your situation. > > > > class CategoryChoiceField(forms.ModelChoiceField): > > > > def __init__(self, *args, **kwargs): > > > super(CategoryChoiceField, self).__init__(*args, **kwargs) > > > self.widget = widgets.RelatedFieldWidgetWrapper( > > > widgets.c( > > > categories=models.Category.objects.order_by('parent', > > > 'list_order')), > > > models.Category._meta.get_field('parent').rel, > > > admin.site, > > > ) > > > > -Jeff > > > > On Dec 9, 6:50 am, Eugene Mirotin wrote: > > > > > Well, looks that the ModelChoiceField solves the problem except of the > > > > plus icon > > > > > On Dec 9, 12:34 pm, Eugene Mirotin wrote: > > > > > > Hello. I'm working on the custom admin page that will serve batch > > > > > items creation based on the uploaded file. > > > > > All these items should be linked to the single foreign key item. > > > > > This item should be selected on the form. > > > > > Of course, I can investigate the inner structure of the rendered admin > > > > > pages and mimic it my template, but it doesn't look DRY. > > > > > So I want to {% include %} the fieldset.html and pass the variable to > > > > > it that will make it to render the standard ForeignKey control (with > > > > > "+" icon). > > > > > Is there a legal way 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 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: "Legal" way to have foreign key field in the custom form
You're passing your queryset in, but you're never using it in your widget. In my code, see how I have: widgets.CategorySelect( categories=models.Category.objects.order_by('parent', 'list_order') ), I don't have the code on hand for my CategorySelect widget, but I remember that it takes "categories", and turns it into a list of choices, which then get passed to Select.__init__() as "choices". Since you're just using a Select() directly, you'd want to pass the choices in there. Here's a simple list comprehension that you may have to adapt a little to do that: [(t.id, unicode(t)) for t in queryset.all()] That assumes that you add "queryset" as an argument to __init__(), which you should probably do. -Jeff On Dec 12, 1:06 pm, Eugene Mirotin wrote: > I was busy for several days and could give it a try only now. Thank > you for the answer, but I still can't make it work. > I have the model called Tournament and the model called > TournamentResult which has foreign keys Team and Tournament. > > What I'm doing is a page for bulk upload of the results for the > specific tournament that should be selected from the drop-down > > At the moment my code looks like this: > > class TournamentChoiceField(forms.ModelChoiceField): > def __init__(self, *args, **kwargs): > super(TournamentChoiceField, self).__init__(*args, **kwargs) > self.widget = admin_widgets.RelatedFieldWidgetWrapper( > forms.Select(), > TournamentResult._meta.get_field('tournament').rel, > admin.site, > ) > > class UploadFormInitial(forms.Form): > tournament = TournamentChoiceField(Tournament.objects.all()) > > But I don't see any values in the drop-down list. > > On Dec 9, 3:55 pm, Jeff FW wrote: > > > To get the plus icon back, you need to wrap the field in a > > RelatedFieldWidgetWrapper. Here's an example from my code--obviously, > > you'll have to adapt it to fit your situation. > > > class CategoryChoiceField(forms.ModelChoiceField): > > > def __init__(self, *args, **kwargs): > > super(CategoryChoiceField, self).__init__(*args, **kwargs) > > self.widget = widgets.RelatedFieldWidgetWrapper( > > widgets.c( > > categories=models.Category.objects.order_by('parent', > > 'list_order')), > > models.Category._meta.get_field('parent').rel, > > admin.site, > > ) > > > -Jeff > > > On Dec 9, 6:50 am, Eugene Mirotin wrote: > > > > Well, looks that the ModelChoiceField solves the problem except of the > > > plus icon > > > > On Dec 9, 12:34 pm, Eugene Mirotin wrote: > > > > > Hello. I'm working on the custom admin page that will serve batch > > > > items creation based on the uploaded file. > > > > All these items should be linked to the single foreign key item. > > > > This item should be selected on the form. > > > > Of course, I can investigate the inner structure of the rendered admin > > > > pages and mimic it my template, but it doesn't look DRY. > > > > So I want to {% include %} the fieldset.html and pass the variable to > > > > it that will make it to render the standard ForeignKey control (with > > > > "+" icon). > > > > Is there a legal way 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 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: Amazon EC2 and Django experience
> > I would like to know if someone may explain his experience with Amazon > EC2 and Django: > * About architecture choice mod_wsgi, apache, nginx, postgresql, cmemcache > > * OS choice ubuntu 8.04 -> alestic.com > * How many instances to begin to be able scale easily Only a single instance for now. > * Tool used to manage it elastic fox (plugin for firefox) + putty.exe or good old ssh on *nix. > * Cost to experiment with this techno before to use it with a real web > site ~ 70 USD per month, so, ~2 dollars for 20 hours of playing. > * Problem or management django with EC2... Some ubuntu-django problems and some ubuntu-ec2 problems but not django-ec2 problems ;) > > I would like to use EC2 with a personal web site, and I am afraid > about cost of it (probably not a rational reason !) There are surely cheaper alternatives. YMMV Ariel. --~--~-~--~~~---~--~~ 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: SOAPpy and pyxml installation/usage
Does anyone know of a better/newer module for creating SOAP services and not just a client? BTW, nice find with Suds - this is most helpful! regards, /p 2008/12/12 Steve : > > Hello Jarek, > > That did the trick! I'm still curious to get ZSI working but suds was > simpler. Here's my first functioning webservice call. > > from suds.client import Client > > url = 'http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl' > client = Client(url) > result = client.service.GetCityWeatherByZIP('94552') > print result.Temperature > > Thanks! > > On Dec 12, 12:24 am, Jarek Zgoda wrote: >> Wiadomość napisana w dniu 2008-12-11, o godz. 09:31, przez Steve: >> >> > This may be a more of a generic Python question, but I'm working with >> > Django so thought that I'd see if there's a Django specific solution >> > to it. >> >> > I'm trying to work with SOAP. I'm new to it and a Jr. programmer as >> > well. From Dive into Python it has this great example about how to >> > handle SOAP calls. >> >http://www.diveintopython.org/soap_web_services/index.html >> >> Drop SOAPpy and ZSI, they are not documented and nearly dead. Try suds. >> >> -- >> We read Knuth so you don't have to. - Tim Peters >> >> Jarek Zgoda, R&D, Redefine >> jarek.zg...@redefine.pl > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
database sqlite3
C:\Users\Benjamin\Desktop\mysite\sqlite3 SQLite3 version 3.6.6.2 Enter".help" for instructions... C:\Users\Benjamin\Desktop\mysite\python manage.py dbshell Error: You appear not to have the 'sqlite3'program installed or on your path I have the latest version of django (SVNsubversion) and I thought SQLite3 was automatically installed with this version. I installed SQLite3 within the mysite directory but it appears it does'nt work (the command "python manage.py dbshell"). I can't make changes to my database schema (chapter 5). In SQLite3, when I execute an ALTER TABLE statement to add a new column, I have an SQL error: no such table: books_book (book is a class of my model). Do I have to add a path to another directory? Do I have to reinstall SQLite3? or to change of db? How do I do? Thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How can I set column headers in AdminSite?
Hi, Django-newbie needs your help, sorry for the lame question, but I couldn't find the answer in docs. I have such a class: class GalleryAdmin(admin.ModelAdmin): list_display = ('randomPhoto', '__unicode__', 'photoCount', 'public') list_display_links = ('randomPhoto', '__unicode__') in list_display: - randomPhoto is a callable - photoCount is a callable - public is a regular field I want to change the column headers on the list page for the callables, to, say 'Example photo' and 'Number of photos'. Thanks in advance for suggestions. Regards, Piotr --~--~-~--~~~---~--~~ 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: Reducing the number of my view's database queries
Thanks for all of the responses. Just wanted to share where I'm at at this point: self.profilekeyword_set.select_related().all().extra(select={ 'rank_url': 'SELECT url FROM rankreport_keywordrank WHERE rankreport_keywordrank.keyword_id = rankreport_profilekeyword.keyword_id AND rankreport_keywordrank.site_id = rankreport_profile.site_id ORDER BY `created` DESC LIMIT 0,1','competition': 'SELECT competition FROM rankreport_keywordrank WHERE rankreport_keywordrank.keyword_id = rankreport_profilekeyword.keyword_id AND rankreport_keywordrank.site_id = rankreport_profile.sit e_id ORDER BY `created` DESC LIMIT 0,1', 'rank': 'SELECT rank FROM rankreport_keywordrank WHERE rankreport_keywordrank.keyword_id = rankreport_profilekeyword.keyword_id AND rankreport_keywordrank.site_id = rankreport_profile.site_id ORDER BY `created` DESC LIMIT 0,1', 'start_rank': 'SELECT rank FROM rankreport_keywordrank WHERE rankreport_keywordrank.keyword_id = rankreport_profilekeyword.keyword_id AND rankreport_keywordrank.site_id = rankreport_profile.site_id ORD ER BY `created` ASC LIMIT 0,1', 'avg': 'SELECT search_volume_avg FROM rankreport_keywordmetrics WHERE rankreport_keywordmetrics.keyword_id = rankreport_profilekeyword.keyword_id ORDER BY `created` DESC LIMIT 0,1', 'cpc': 'SELECT cpc FROM rankreport_keywordmetrics WHERE rankreport_keywordmetrics.keyword_id = rankreport_profilekeyword.keyword_id ORDER BY `created` DESC LIMIT 0,1', 'zz': 'start_rank - rank', }).select_related() This seems to work. If you know of any performance tweaks I'd love to hear about them (however it is incredibly fast compared to my original solution). The only problem is that "zz" throws a database error. (OperationalError: (1054, "Unknown column 'start_rank' in 'field list'")) - ant ideas how I can get "zz" working? Thanks again for the assistance! Erik On Dec 8, 4:49 pm, Malcolm Tredinnick wrote: > On Mon, 2008-12-08 at 07:43 -0800, DavidA wrote: > > If I undestand the problem correctly, in MySQL you could do this in > > one query as: > > > select > > m.*, > > (select min(created) from model2 where id = m.model2_id) as > > first_created, > > (select max(created) from model2 where id = m.model2_id) as > > last_created > > from model1 m > > ; > > That will give the correct answer, however it's a bit inefficient, since > the inner queries are run once for each model id (and in the original > post model2 and model3 were used, so it's worse than it looks here). > Since that means 6000 rows, based on Eric's original numbers, it's worth > looking deeper. Let me cut-and-paste the original description for > reference: > > (behold the power of a fully-functional, non top-posting email client!) > > > > > objects = Model1.objects.filter(user=3).select_related() #about 6,000 > > > > objects > > > > > data = {} > > > > for o in objects: > > > > data[o.name] = [o.field1, o.field2] > > > > data[o.name].append(o.field3.model2_set.all().latest('created')) > > > > #get latest row from related model2 > > > > data[o.name].append(o.model3_set.all().order_by('created')[0]) > > > > #get earliest row from related model3 > > Ideally, there would be a way to run one inner query that does something > like > > select max(created) from ... where model1.user_id = 3 group by > model1.id > > except that isn't quite right because if the outer query only selected > results with those created dates, it will get a superset of the right > answer (some model2.id could have a created date that matches some other > maximum but isn't the maximum for that particular model2.id, so you need > to tie the maximum date to the model id). > > If something along those lines can be made to work, that inner query > only has to run once (sure it's a big query, with a sort, but it's only > one query and it's in the sweet spot of what databases can do). It's the > difference between a correlated inner query (which you have -- so it > runs once for each outer row) and an uncorrelated query like the above. > > Still, using the above query and then filtering out the dupes at the > Python level might well be a good alternate solution. So you end up > with: > > select model2.*, model1.id, ... from ... > where model2.created in (select max(model2.created) from > where model1.user_id=3 group by model1.id) order by > model2.created asc > > Then you process these results, storing them in a dictionary keyed from > model1.id. When you get duplicate results for the same model1.id (the > above superset situation), the 'latest' result will be after the earlier > ones and will overwrite them. > > The above is the query to select all the model2 fields. There's another > query to select all the model3 fields. So that reduces the original > 12001 queries to 3 and in the two with nested inner queries, the nested > queries only run once each (or once per user id, which seemed to b
Amazon EC2 and Django experience
Hi all, I would like to know if someone may explain his experience with Amazon EC2 and Django: * About architecture choice * OS choice * How many instances to begin to be able scale easily * Tool used to manage it * Cost to experiment with this techno before to use it with a real web site * Problem or management django with EC2... I would like to use EC2 with a personal web site, and I am afraid about cost of it (probably not a rational reason !) Thanks -- Didier Rano didier.r...@gmail.com --~--~-~--~~~---~--~~ 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: "Legal" way to have foreign key field in the custom form
I was busy for several days and could give it a try only now. Thank you for the answer, but I still can't make it work. I have the model called Tournament and the model called TournamentResult which has foreign keys Team and Tournament. What I'm doing is a page for bulk upload of the results for the specific tournament that should be selected from the drop-down At the moment my code looks like this: class TournamentChoiceField(forms.ModelChoiceField): def __init__(self, *args, **kwargs): super(TournamentChoiceField, self).__init__(*args, **kwargs) self.widget = admin_widgets.RelatedFieldWidgetWrapper( forms.Select(), TournamentResult._meta.get_field('tournament').rel, admin.site, ) class UploadFormInitial(forms.Form): tournament = TournamentChoiceField(Tournament.objects.all()) But I don't see any values in the drop-down list. On Dec 9, 3:55 pm, Jeff FW wrote: > To get the plus icon back, you need to wrap the field in a > RelatedFieldWidgetWrapper. Here's an example from my code--obviously, > you'll have to adapt it to fit your situation. > > class CategoryChoiceField(forms.ModelChoiceField): > > def __init__(self, *args, **kwargs): > super(CategoryChoiceField, self).__init__(*args, **kwargs) > self.widget = widgets.RelatedFieldWidgetWrapper( > widgets.c( > categories=models.Category.objects.order_by('parent', > 'list_order')), > models.Category._meta.get_field('parent').rel, > admin.site, > ) > > -Jeff > > On Dec 9, 6:50 am, Eugene Mirotin wrote: > > > Well, looks that the ModelChoiceField solves the problem except of the > > plus icon > > > On Dec 9, 12:34 pm, Eugene Mirotin wrote: > > > > Hello. I'm working on the custom admin page that will serve batch > > > items creation based on the uploaded file. > > > All these items should be linked to the single foreign key item. > > > This item should be selected on the form. > > > Of course, I can investigate the inner structure of the rendered admin > > > pages and mimic it my template, but it doesn't look DRY. > > > So I want to {% include %} the fieldset.html and pass the variable to > > > it that will make it to render the standard ForeignKey control (with > > > "+" icon). > > > Is there a legal way 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 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: RHEL 5.2 + mysql + Django 1.0 => Django 0.95.4
It should work if you install the egg. J 2008/12/12 Rachel Willmer : > > I'm installing Django on a customer's machine which is running Red Hat > Enterprise Linux Server release 5.2. > > Django 1.0 complains about the version of mysql-python available, > which is 1.2.1-1, where it needs 1.2.1p2. > > Trying to install the latest tarball from sourceforge gives me lots of > other file versioning problems, so as a short-term solution, I've had > to downgrade back to Django 0.95.4. > > Is this a known problem? How do people handle it? Is there an RPM > available somewhere? (I'm limited to how much change I can make on > this server, so can't just update everything) > > Any pointers would be very gratefully received! > Rachel > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
RHEL 5.2 + mysql + Django 1.0 => Django 0.95.4
I'm installing Django on a customer's machine which is running Red Hat Enterprise Linux Server release 5.2. Django 1.0 complains about the version of mysql-python available, which is 1.2.1-1, where it needs 1.2.1p2. Trying to install the latest tarball from sourceforge gives me lots of other file versioning problems, so as a short-term solution, I've had to downgrade back to Django 0.95.4. Is this a known problem? How do people handle it? Is there an RPM available somewhere? (I'm limited to how much change I can make on this server, so can't just update everything) Any pointers would be very gratefully received! Rachel --~--~-~--~~~---~--~~ 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: Getting Form Field Values in a template
Found answer here: http://groups.google.com/group/django-users/browse_thread/thread/99f6fa5ce32dd824/460a1c563a3a851b?lnk=gst&q=template+form+values#460a1c563a3a851b form.data.fieldname (this is pre-cleaned bound data) ---> Did not work form.cleaned_data.fieldname (post clean if valid) ---> Didn't apply so I didn't try it form.initial.fieldname (values set for initial) ---> WORKED!!! Thank you Doug B On Dec 12, 12:47 pm, Paul Childs wrote: > I am converting from .96 to 1.0. > > In a template using 0.96, if I wanted to get the value that a > particular field was holding I would use: > {{ form.data.field_name }} > > This doesn't work anymore and is breaking my code. > > I have tried a number of other ways (guessing mostly), consulted the > docs and browsed the Django source and still can't figure it out. > > Can anyone help me out here? > > Thanks. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Getting Form Field Values in a template
I am converting from .96 to 1.0. In a template using 0.96, if I wanted to get the value that a particular field was holding I would use: {{ form.data.field_name }} This doesn't work anymore and is breaking my code. I have tried a number of other ways (guessing mostly), consulted the docs and browsed the Django source and still can't figure it out. Can anyone help me out here? Thanks. --~--~-~--~~~---~--~~ 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: One to Many insert into Postgres
Thank you both for the suggestions. There is a problem with the sequence number in the primary keys. When I created a new table without data the insert worked fine.I will try to recreate the sequences and hope I don't have to re-enter the data. Thanks, Anna On Dec 12, 3:26 am, tofer...@gmail.com wrote: > On 11.12-07:45, Ana wrote: > > [ ... ] > > > I am converting from PHP to Django. In my Postgres database I have > > three tables: > [ ... ] > > duplicate key value violates unique constraint > > "fsafety_pathpubcombo_pkey" > > > Can anyone please help? This is the first python code I've written. > > i would guess that you need to reset your postgres autoindex to > something that matches your dataset. for example if you have 10,000 > records then the primary keys for 1-10,000 are already duplicate, > however, with your a database the index key will be set to something > low, thereby inducing the collisions you're talking about. > > you'll need to do this via 'psql' or another postgres tool. i'm > afraid i can't remember the way do to this. maybe it's to delete > the underlying sequence and then recreate it with > CREATE SEQUENCE START ; > or something. i don't think you can set it directly ... if i > remember correctly i backed up a db to sql and figured it out that > way. --~--~-~--~~~---~--~~ 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: generating an image?
oh awesome! this should be an interesting little project for myself thanks for the links On Dec 12, 11:08 am, Jeff Anderson wrote: > garagefan wrote: > > Is it possible to generate an image, to save it on my server, of a web > > page by passing through the url only? > > > say perhaps I want to link to a few sites from mine, and i'd like to > > include a thumbnail of the site... and instead of taking a screen > > capture, and uploading it, i pass through the url of the page, and the > > image of the homepage is generated from that. > > I found a few utilities by googling for: web screenshot automated > > The first result talks about a couple utilities that'll do what you want. > > http://iecapt.sourceforge.net/- Windows only, uses IE for > renderinghttp://cutycapt.sourceforge.net/- cross platform, uses the same > rendering engine as konquerer/google chrome/safari. > > Jeff Anderson > > signature.asc > < 1KViewDownload --~--~-~--~~~---~--~~ 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: To-Go django based solutions for Google AppEngine?
If you are going to make an effort like this, you should probably base it on Pinax ... http://pinaxproject.com/ ... porting pinax to GAE should not be terribly difficult, and I would not be surprised if someone is already working on it. Jeff On Fri, Dec 12, 2008 at 1:33 AM, jago wrote: > > Hi, > > As some of you may know Google AppEngine currently only supports Python > and uses mainly django. > > I wondered if people were interested to found a project which offers > ready-to-deploy django based solutions for Google Appengine. Hosting > there is free and it would be great if normal users (not developers) > could set up django based solutions such as: > > - blogs > - websites > - simple cms > - photo-galleries > - etc. > > One could offer such packages for download and 5-min deployment to > Google AppEngine. I think many people would love this. > > What do you think? > > Cheers, > jago > > > > --~--~-~--~~~---~--~~ 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: generating an image?
garagefan wrote: > Is it possible to generate an image, to save it on my server, of a web > page by passing through the url only? > > say perhaps I want to link to a few sites from mine, and i'd like to > include a thumbnail of the site... and instead of taking a screen > capture, and uploading it, i pass through the url of the page, and the > image of the homepage is generated from that. > I found a few utilities by googling for: web screenshot automated The first result talks about a couple utilities that'll do what you want. http://iecapt.sourceforge.net/ - Windows only, uses IE for rendering http://cutycapt.sourceforge.net/ - cross platform, uses the same rendering engine as konquerer/google chrome/safari. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: setting language in a cron job
Thanks, it works!!! Well, again a low-level function %-/, but I hope I won't use too much of these magic low-level hacks. On Dec 12, 4:07 pm, Rajesh Dhawan wrote: > On Dec 12, 8:33 am, pihentagy wrote: > > Hi all! > > > I started to write a cron job, which sends reminders to users, but run > > into the following: > > > I do not know how to set the current language in this situation. > > Setting settings.LANGUAGE_CODE has no effect. > > > Note, that not only the text in the mail should be different, but it > > contains model data, and the model is aware of the current language > > (uses get_language() to figure it out). > > > According to the docs > > here:http://docs.djangoproject.com/en/dev/topics/i18n/#id2 > > > as I have no session, no request, no cookies, no http headers (it's a > > cron job), the only chance is to look up the LANGUAGE_CODE for django. > > Perhaps try setting it through a low-level call to > django.utils.translation.activate(): > > from django.utils.translation import activate > activate("en-US") # Replace "en-US" with the language code you want to > activate. > > -Rajesh D --~--~-~--~~~---~--~~ 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: setting language in a cron job
On Dec 12, 8:33 am, pihentagy wrote: > Hi all! > > I started to write a cron job, which sends reminders to users, but run > into the following: > > I do not know how to set the current language in this situation. > Setting settings.LANGUAGE_CODE has no effect. > > Note, that not only the text in the mail should be different, but it > contains model data, and the model is aware of the current language > (uses get_language() to figure it out). > > According to the docs > here:http://docs.djangoproject.com/en/dev/topics/i18n/#id2 > > as I have no session, no request, no cookies, no http headers (it's a > cron job), the only chance is to look up the LANGUAGE_CODE for django. Perhaps try setting it through a low-level call to django.utils.translation.activate(): from django.utils.translation import activate activate("en-US") # Replace "en-US" with the language code you want to activate. -Rajesh D --~--~-~--~~~---~--~~ 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: problem with make-messages.py russian language
On Fri, Dec 12, 2008 at 8:24 AM, Dafidov wrote: > > Hello. > I didn't found in Internet any comments in this subject thats why I'm > writing. I don't know why but after moving to django 1.0.2 I have a > problem with creating po files in Russian language. The German and > Polish work fine but when I'm trying do it on Russian the process > suspends and don't react. > {{{ > make-messages.py -l ru > }}} > {{{ > make-messages.py -a > }}} > Both are not suspending reaching Russian language. > Before update all worked fine. > Does anyone have idea why it doesn't work - had any one same problem ? > Any suggestions, solutions :) ? > (You don't say what level "before update" was. That might have been useful information.) You shouldn't be using make-messages.py with Django 1.0.2, as that function was moved to a django-admin.py command (see http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Translationtoolsnowpartofdjango-admin.py). If you were using the 1.0.2 version of make-messages.py you'd just get an error message since the 1.0.2 version of that script just prints out that you should be using the other command. There's another change listed on that page that you should be aware of: http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#POfilesmustbeUTF-8encoded I do not know that either of these could cause makemessages to hang; if you switch to using the correct command and verify that the 2nd change I noted isn't a problem and still have an issue with the command hanging for Russian please re-post and inslude the OS you are using and the gettext utilities version you have installed (output of xgettext --version). Karen --~--~-~--~~~---~--~~ 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: exclude on ModelForm doesn't work
On Dec 12, 8:45 am, Dennis Schmidt wrote: > Hi, > > actually that is how I do it. I'm subclassing from admin.ModelAdmin > and then set the form-field to the custom form I made. But maybe this > really only works for forms in applications. No, it does work in the admin too. Setting the form attribute in your ModelAdmin makes Django use your custom form. However, in your case, you will need to also exclude your 'template' field using the exclude attribute on your ModelAdmin class: http://docs.djangoproject.com/en/dev//ref/contrib/admin/#exclude This will ensure that the 'template' field is not displayed in the admin's add/change forms. -Rajesh D --~--~-~--~~~---~--~~ 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: model string reprentations
On Fri, Dec 12, 2008 at 7:33 AM, ben852 wrote: > > Hi, > I am new to django and programming. > I have a problem with the method _str_( ). > Following the tutorial, I edited my models.py file in mysite/books and > wrote: > [snip] The fact that you are using __str__ instead of __unicode__ indicates you are using a very old release of Django. If you are just starting out you should really start with the latest 1.0.2 release, it is a much better base to learn and build on, with many significant feature additions, countless bugs fixed, and API stability. Karen --~--~-~--~~~---~--~~ 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: model string reprentations
> Sure do: it should be __str__() with two underscores on either side, > not one. And for the use-case the OP gave... >> from books.models import Publisher >> publisher_list = Publisher.objects.all ( ) >> publisher_list >> >> [, ] # Python calls the __repr__ for the display at the command-line, not the __str__ (the str is used for prints: >>> print publisher_list # use the __str__ method [output] >>> publisher_list # uses the __repr__ method [output] which is the same as >>> print repr(publisher_list) -tim --~--~-~--~~~---~--~~ 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: model string reprentations
thanks a lot On Dec 12, 3:06 pm, Jeff FW wrote: > Sure do: it should be __str__() with two underscores on either side, > not one. > > -Jeff > > On Dec 12, 7:33 am, ben852 wrote: > > > Hi, > > I am new to django and programming. > > I have a problem with the method _str_( ). > > Following the tutorial, I edited my models.py file in mysite/books and > > wrote: > > > class Publisher(models.Model): > > name = models.Charfield(max_length=30) > > address = models.Charfield(max_length=30) > > website = models.URLField() > > > def _str_(self): > >return self.name > > > then python manage.py shell > > > from books.models import Publisher > > publisher_list = Publisher.objects.all ( ) > > publisher_list > > > [, ] # > > p1.save ( ) and p2.save ( ) > > > The _str_ method doesn't work. > > Do you have an idea? --~--~-~--~~~---~--~~ 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: Creating a custom sql query
On Fri, Dec 12, 2008 at 4:32 AM, Kottiyath Nair wrote: > oops!! Unknowingly send the mail before finishing it. > > As I was mentioning in the earlier mail: > What I want is: >dbmodel.objects.filter(__first_filter).sum(), should be able to sum > across the filtered data. > > If somebody could help me out on this, I would be very thankful. > I don't know of any way to do what you are looking for here without aggregate support in the ORM. The good news is that's on the 1.1 must-have features list. The ticket to watch is http://code.djangoproject.com/ticket/3566. Russell's got the current code publicly available in a git clone of Django's svn so it's possible to try it out (if you already use git or are willing to learn it). > > P.S-> Also, is it safe to use the backends.quote_name for getting the name > of the table in the DB? Is there any other mechanism to get the original > name of the table? > > Don't know the answer to this one. Karen --~--~-~--~~~---~--~~ 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: model string reprentations
Sure do: it should be __str__() with two underscores on either side, not one. -Jeff On Dec 12, 7:33 am, ben852 wrote: > Hi, > I am new to django and programming. > I have a problem with the method _str_( ). > Following the tutorial, I edited my models.py file in mysite/books and > wrote: > > class Publisher(models.Model): > name = models.Charfield(max_length=30) > address = models.Charfield(max_length=30) > website = models.URLField() > > def _str_(self): > return self.name > > then python manage.py shell > > from books.models import Publisher > publisher_list = Publisher.objects.all ( ) > publisher_list > > [, ] # > p1.save ( ) and p2.save ( ) > > The _str_ method doesn't work. > Do you have an idea? --~--~-~--~~~---~--~~ 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: Question about field/widget relationship
Hello, The widget kw can be either a class or an instance. You can do xField(widget=xWidget(choices=mychoices)) Or you can create your xField with your xWidget as default widget and let the field to accept the choices kw. Matias. On Fri, Dec 12, 2008 at 8:44 AM, commander_coder < commander_co...@hotmail.com> wrote: > > How does a field pass attributes to a widget? I have approximately > this > > class fooForm(forms.Form): > x_choice=myForms.xField(widget=myWidgets.xWidget) > > where myWidgets.xWidget is a subclass of RadioSelect so it has a > required argument like "choices=[('a','1'), ('b','a')]" (this is > generated dynamically so I can't build it in to xWidget). Where in > the Django code base does that information get passed? > > The examples I've studied don't seem to me to show xField being > written to pass it explicitly but they do make a super() call, so I > expect it is done there. I see in the render code for the widget > references to the variable self.choices, so it is getting remembered > by the widget in that way. However, I've struggled with the Django > source and I can't make out how it is passed. I'd be very grateful if > someone could help me find it. > > Jim > > > -- :wq --~--~-~--~~~---~--~~ 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: exclude on ModelForm doesn't work
Hi, actually that is how I do it. I'm subclassing from admin.ModelAdmin and then set the form-field to the custom form I made. But maybe this really only works for forms in applications. I'll try that out. Thx On 12 Dez., 14:31, Matias wrote: > Hi, > > How do you register the model in the admin site? > You should register your model using a ModelAdmin subclass. > > Here is some docs that may help > youhttp://docs.djangoproject.com/en/dev/ref/contrib/admin/ > > The ModelForms are ment to be used in your applications rather than the > admin site. > > Hope that helps > > Matias. > > On Fri, Dec 12, 2008 at 10:22 AM, Dennis Schmidt > > > > wrote: > > > Hello, > > > I have a problem with ModelForms in the django admin site. I want to > > exclude some fields so they won't be displayed when I edit the model > > in the admin site. This is my code: > > > class CommonInvoiceForm(forms.ModelForm): > > price_factor = forms.ChoiceField(choices=COST_FACTOR_CHOICES) > > > class Meta: > > from voipgo.accounting.invoices.models import CommonInvoice > > model = CommonInvoice > > exclude = ('template',) > > > So as you can see I add a new field to the form - which works as > > expected. But the 'template' field I don't want to have in there is > > still displayed. 'template' is a normal ForeignKey field in the model > > declaration. What am I doing wrong here? > > -- > :wq --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
problem with make-messages.py russian language
Hello. I didn't found in Internet any comments in this subject thats why I'm writing. I don't know why but after moving to django 1.0.2 I have a problem with creating po files in Russian language. The German and Polish work fine but when I'm trying do it on Russian the process suspends and don't react. {{{ make-messages.py -l ru }}} {{{ make-messages.py -a }}} Both are not suspending reaching Russian language. Before update all worked fine. Does anyone have idea why it doesn't work - had any one same problem ? Any suggestions, solutions :) ? Best regards --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
model string reprentations
Hi, I am new to django and programming. I have a problem with the method _str_( ). Following the tutorial, I edited my models.py file in mysite/books and wrote: class Publisher(models.Model): name = models.Charfield(max_length=30) address = models.Charfield(max_length=30) website = models.URLField() def _str_(self): return self.name then python manage.py shell from books.models import Publisher publisher_list = Publisher.objects.all ( ) publisher_list [, ] # p1.save ( ) and p2.save ( ) The _str_ method doesn't work. Do you have an idea? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
setting language in a cron job
Hi all! I started to write a cron job, which sends reminders to users, but run into the following: I do not know how to set the current language in this situation. Setting settings.LANGUAGE_CODE has no effect. Note, that not only the text in the mail should be different, but it contains model data, and the model is aware of the current language (uses get_language() to figure it out). According to the docs here: http://docs.djangoproject.com/en/dev/topics/i18n/#id2 as I have no session, no request, no cookies, no http headers (it's a cron job), the only chance is to look up the LANGUAGE_CODE for django. thanks Gergo --~--~-~--~~~---~--~~ 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: exclude on ModelForm doesn't work
Hi, How do you register the model in the admin site? You should register your model using a ModelAdmin subclass. Here is some docs that may help you http://docs.djangoproject.com/en/dev/ref/contrib/admin/ The ModelForms are ment to be used in your applications rather than the admin site. Hope that helps Matias. On Fri, Dec 12, 2008 at 10:22 AM, Dennis Schmidt wrote: > > Hello, > > I have a problem with ModelForms in the django admin site. I want to > exclude some fields so they won't be displayed when I edit the model > in the admin site. This is my code: > > > class CommonInvoiceForm(forms.ModelForm): >price_factor = forms.ChoiceField(choices=COST_FACTOR_CHOICES) > >class Meta: >from voipgo.accounting.invoices.models import CommonInvoice >model = CommonInvoice >exclude = ('template',) > > > So as you can see I add a new field to the form - which works as > expected. But the 'template' field I don't want to have in there is > still displayed. 'template' is a normal ForeignKey field in the model > declaration. What am I doing wrong here? > > > -- :wq --~--~-~--~~~---~--~~ 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: django template script variable usage and declaration
On 12 déc, 11:57, Daniel Roseman wrote: > On Dec 12, 7:04 am, "Haroon idrees" wrote: > > > > > Hello > > I am new to python world . any one can help to guide how we > > declare variables in python template script and use in if else block > > and vary it > > > for example > > //need to declare variable here > > //for example x=0 > > {% for message in message %} > > //need to put if condition here > > //ifequal x 0 > > > > //x=1 > > //need to put else condition here > > > > x=0 > > > href="/restmessage/mzubair.ahmed?format=xml">mzubair.ahmed > > > > > test > > > > 2008-12-12 05:13:45.788901 > > > > > {%endfor%} > > No, you can't do that, by design. > > But a quick reading of the documentation for the for tag would show > you how it should be done: use forloop.counter0. > Seehttp://groups.google.com/group/django-users/browse_thread/thread/3edf... Or if it's just to alternate between odd and even rows, use the builtin {% cycle %} tag: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#cycle --~--~-~--~~~---~--~~ 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: Multiple sites - same code, different templates
just a suggestion if it is just the templates you can write a loop inside in settings.py based on site_id like if SITE_ID==1: TEMPLATE_DIRS =="/// elif SITE_ID==2: TEMPLATE_DIRS =="somethingelse" Pardon me if I didn't understand your question. Ramdas On Fri, Dec 12, 2008 at 5:44 PM, will0 wrote: > > Hi all > > I can't figure out how to change TEMPLATE_DIRS according to the URL > used. > > My purpose is to view two versions of the same site, e.g. mysite/v1/ > and mysite/v2/, but keep the same codebase. This is just for > development so people in several countries can view the site and put > in their opinion. > > I've tried a few methods, e.g. setting an environment variable in > apache and picking that up in settings. This unfortunately requires > many page refreshes to work, for some reason. I've set > MaxRequestsPerChild to 1. > > > ... >SetEnv MAP_SITE_VERSION v1 > ... > > > Is there another way? I could pick up the version in the view from the > URL however this would require significant changes to the code. > > Perhaps there's a way to pick up the HTTP request parameters in > settings? > > Thanks > > Will > > > > -- Ramdas S +91 9342 583 065 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
exclude on ModelForm doesn't work
Hello, I have a problem with ModelForms in the django admin site. I want to exclude some fields so they won't be displayed when I edit the model in the admin site. This is my code: class CommonInvoiceForm(forms.ModelForm): price_factor = forms.ChoiceField(choices=COST_FACTOR_CHOICES) class Meta: from voipgo.accounting.invoices.models import CommonInvoice model = CommonInvoice exclude = ('template',) So as you can see I add a new field to the form - which works as expected. But the 'template' field I don't want to have in there is still displayed. 'template' is a normal ForeignKey field in the model declaration. What am I doing wrong here? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Multiple sites - same code, different templates
Hi all I can't figure out how to change TEMPLATE_DIRS according to the URL used. My purpose is to view two versions of the same site, e.g. mysite/v1/ and mysite/v2/, but keep the same codebase. This is just for development so people in several countries can view the site and put in their opinion. I've tried a few methods, e.g. setting an environment variable in apache and picking that up in settings. This unfortunately requires many page refreshes to work, for some reason. I've set MaxRequestsPerChild to 1. ... SetEnv MAP_SITE_VERSION v1 ... Is there another way? I could pick up the version in the view from the URL however this would require significant changes to the code. Perhaps there's a way to pick up the HTTP request parameters in settings? Thanks Will --~--~-~--~~~---~--~~ 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: One to Many insert into Postgres
On 11.12-07:45, Ana wrote: [ ... ] > I am converting from PHP to Django. In my Postgres database I have > three tables: [ ... ] > duplicate key value violates unique constraint > "fsafety_pathpubcombo_pkey" > > Can anyone please help? This is the first python code I've written. i would guess that you need to reset your postgres autoindex to something that matches your dataset. for example if you have 10,000 records then the primary keys for 1-10,000 are already duplicate, however, with your a database the index key will be set to something low, thereby inducing the collisions you're talking about. you'll need to do this via 'psql' or another postgres tool. i'm afraid i can't remember the way do to this. maybe it's to delete the underlying sequence and then recreate it with CREATE SEQUENCE START ; or something. i don't think you can set it directly ... if i remember correctly i backed up a db to sql and figured it out that way. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Transactions, nested functions and logging
Hi, I'm a little confused how I should handle transactions in a particular situation. I've got some code that boils down to this: def myview(request): result = important_money_stuff(request) widget = Widget.objects.get(request.get(something)) thingy = Thingy.objects.get(request.get(something)) thingy, widget = modify(thingy, widget) thingy.save() widget.save() return render_to_response(...) def important_money_stuff(request): bank_reply = something_involving_credit_cards() log_to_db(bank_reply) return bank_reply Now - I want to use transactions to ensure that widget and thingy only get saved on a complete success. I don't want their states to become out of sync. However - I want the logging to take place *whatever happens* i.e. assuming the money stuff happens then I want it logged. I was going to use commit_on_success to do this. How does commit_on_success handle being nested? Will it understand to commit the logging transaction when it finishes important_money_stuff but to roll back the widget and thingy transaction separately? cheers, Andy --~--~-~--~~~---~--~~ 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: TypeError at admin: unpack non-sequence
Of course. urls.py below: Underneath that is the relevant directives from my vhosts.conf file. Many thanks, -M --- urls.py --- from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Example: # (r'^djangotest/', include('djangotest.foo.urls')), # Uncomment the admin/doc line below and add 'django.contrib.admindocs' # to INSTALLED_APPS to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: (r'^admin/(.*)', admin.site.root), ) --- end of file --- --- Segment from vhosts.conf --- # Options +Includes SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE djangotest.settings SetEnv PYTHON_EGG_CACHE /var/tmp/egg PythonOption django.root / PythonDebug On PythonPath "[''] + sys.path" --- end of file segment --- On Dec 12, 10:45 am, Daniel Roseman wrote: > On Dec 12, 9:41 am, Bluemilkshake > wrote:> You're right DR, apologies. I did think it may be a syntax issue but > > it appears not to be. > > Would it matter at what position the admin reference appears in > > INSTALLED_APPS? > > > Below is the settings.py file being used. Hope this is of more help. > > > Many thanks, > > -M > > That looks OK - could you post your urls.py, the problem may be there? > -- > DR. --~--~-~--~~~---~--~~ 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: django template script variable usage and declaration
On Dec 12, 7:04 am, "Haroon idrees" wrote: > Hello > I am new to python world . any one can help to guide how we > declare variables in python template script and use in if else block > and vary it > > for example > //need to declare variable here > //for example x=0 > {% for message in message %} > //need to put if condition here > //ifequal x 0 > > //x=1 > //need to put else condition here > > x=0 > href="/restmessage/mzubair.ahmed?format=xml">mzubair.ahmed > > > test > > 2008-12-12 05:13:45.788901 > > > {%endfor%} > No, you can't do that, by design. But a quick reading of the documentation for the for tag would show you how it should be done: use forloop.counter0. See http://groups.google.com/group/django-users/browse_thread/thread/3edfafff2f28506 -- DR. --~--~-~--~~~---~--~~ 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: TypeError at admin: unpack non-sequence
On Dec 12, 9:41 am, Bluemilkshake wrote: > You're right DR, apologies. I did think it may be a syntax issue but > it appears not to be. > Would it matter at what position the admin reference appears in > INSTALLED_APPS? > > Below is the settings.py file being used. Hope this is of more help. > > Many thanks, > -M > That looks OK - could you post your urls.py, the problem may be there? -- DR. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Question about field/widget relationship
How does a field pass attributes to a widget? I have approximately this class fooForm(forms.Form): x_choice=myForms.xField(widget=myWidgets.xWidget) where myWidgets.xWidget is a subclass of RadioSelect so it has a required argument like "choices=[('a','1'), ('b','a')]" (this is generated dynamically so I can't build it in to xWidget). Where in the Django code base does that information get passed? The examples I've studied don't seem to me to show xField being written to pass it explicitly but they do make a super() call, so I expect it is done there. I see in the render code for the widget references to the variable self.choices, so it is getting remembered by the widget in that way. However, I've struggled with the Django source and I can't make out how it is passed. I'd be very grateful if someone could help me find it. Jim --~--~-~--~~~---~--~~ 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: Django Training
Steve, I think that the book by Forcier, Bissex and Chun called "Python Web Development with Django" is worth looking at with regards to ideas for a lesson plan. To me it seems that it would be an excellent workbook for a very full week of classes. Their chapter 1 on python and the first few pages of chapter 3 on dynamic web site concepts can be viewed as either a good set of prerequirements or else as required pre- reading for the class. Also note that the book is based on Django 1.0 which makes it unique in this regards at this time. I like their idea of jumping in right away and building a simple project as they do in Chapter 2 and then doubling back and going over the core concepts starting with Part II of Chapter 3 and then Chapters 4, 5 and 6. I think this material could be covered in 2 days worth of classes. After that the book presents a bunch of example projects and advanced concept chapters and appendices that can be used to round out the class. Mix in some hands on exercises and you have a very full week of learning while the book itself makes for a nice take away for the students, Just my thoughts. In case you are wondering, I am not being paid by Addison Wesley to make these comments nor do I know any of the authors. I simply read the book and then decided that if I decided to put together a Django training class that I would probably use the book as the basis for such an offering. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Django templates and new lines
Hi all! I ran into the problem mentioned here: http://groups.google.com/group/django-users/browse_frm/thread/c9e569f7370c9c80/3b645501e9b67aa8 Does anybody know whether anything happened after that thread? thanks Gergo --~--~-~--~~~---~--~~ 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: SOAPpy and pyxml installation/usage
Hello Jarek, That did the trick! I'm still curious to get ZSI working but suds was simpler. Here's my first functioning webservice call. from suds.client import Client url = 'http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl' client = Client(url) result = client.service.GetCityWeatherByZIP('94552') print result.Temperature Thanks! On Dec 12, 12:24 am, Jarek Zgoda wrote: > Wiadomość napisana w dniu 2008-12-11, o godz. 09:31, przez Steve: > > > This may be a more of a generic Python question, but I'm working with > > Django so thought that I'd see if there's a Django specific solution > > to it. > > > I'm trying to work with SOAP. I'm new to it and a Jr. programmer as > > well. From Dive into Python it has this great example about how to > > handle SOAP calls. > >http://www.diveintopython.org/soap_web_services/index.html > > Drop SOAPpy and ZSI, they are not documented and nearly dead. Try suds. > > -- > We read Knuth so you don't have to. - Tim Peters > > Jarek Zgoda, R&D, Redefine > jarek.zg...@redefine.pl --~--~-~--~~~---~--~~ 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: TypeError at admin: unpack non-sequence
You're right DR, apologies. I did think it may be a syntax issue but it appears not to be. Would it matter at what position the admin reference appears in INSTALLED_APPS? Below is the settings.py file being used. Hope this is of more help. Many thanks, -M # Django settings for djangotest project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_em...@domain.com'), ) MANAGERS = ADMINS DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. DATABASE_NAME = 'djangotest' # Or path to database file if using sqlite3. DATABASE_USER = 'djangotest' # Not used with sqlite3. DATABASE_PASSWORD = '**' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # If running in a Windows environment this must be set to the same as your # system time zone. TIME_ZONE = 'America/Chicago' # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'en-us' SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = '' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). # Examples: "http://media.lawrence.com";, "http://example.com/media/"; MEDIA_URL = '' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/";, "/media/". ADMIN_MEDIA_PREFIX = '/media/' # Make this unique, and don't share it with anybody. SECRET_KEY = 'p31u!n(kbd6!dqoabpe9jajj8y29-tq^n6khs1-j60goc8#z41' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', # 'django.template.loaders.eggs.load_template_source', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ) ROOT_URLCONF = 'djangotest.urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/ django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', ) On Dec 11, 4:47 pm, Daniel Roseman wrote: > On Dec 11, 3:35 pm, Bluemilkshake > wrote: > > > > > > > Hi! Apologies for what is in no doubt a complete noob question. > > > Just installed CentOS 5 with Python 2.4, Apache2 and the latest SVN > > release of Django. Also copied the mysql-python stuff, mod_python etc. > > > I've setup my first Django project to test, and when I request the > > root URL I get no problems, however after adding the admin app to my > > INSTALLED_APPS setting and running syncdb, I get the following: > > > TypeError at admin > > unpack non-sequenceRequest Method: GET > > Request URL:http://djangotest.bluemilkshake.co.ukadmin > > Exception Type: TypeError > > Exception Value: unpack non-sequence > > Exception Location: /usr/lib/python2.4/site-packages/django/core/ > > handlers/base.py in get_response, line 76 > > Python Executable: /usr/bin/python > > Python Version: 2.4.3 > > Python Path: ['/home/Bluemilkshake/djangotest.bluemilkshake.co.uk/user/ > > django', '/usr/lib/python2.4/site-packages/setuptools-0.6c5- > > py2.4.egg', '/usr/lib/python2.4/site-packages/MySQL_python-1.2.2-py2.4- > > linux-i686.egg', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/ > > lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/ > > python2.4/lib-dynload', '/usr/lib/python2.4/site-packages', '/usr/lib/ > > python2.4/site-packages/Numeric', '/usr/lib/python2.4/site-packages/ > > gtk-2.0'] > > Server time: Thu, 11 Dec 2008 09:28:30 -0600 > > > Have had a look round this group and the Web but have found no > > details. Also checked the mod_python docs on the Django Website and am > > sure I've configured everything to the letter (apart from specifying > > the PYTHON_EGG_CACHE in my httpd.conf (via SetEnv) instead of in a > > separate .py file.) > > > Would really appreciate any pointers. I'm usually a Windows guy so > > don't assume I kn
To-Go django based solutions for Google AppEngine?
Hi, As some of you may know Google AppEngine currently only supports Python and uses mainly django. I wondered if people were interested to found a project which offers ready-to-deploy django based solutions for Google Appengine. Hosting there is free and it would be great if normal users (not developers) could set up django based solutions such as: - blogs - websites - simple cms - photo-galleries - etc. One could offer such packages for download and 5-min deployment to Google AppEngine. I think many people would love this. What do you think? Cheers, jago --~--~-~--~~~---~--~~ 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: Creating a custom sql query
oops!! Unknowingly send the mail before finishing it. As I was mentioning in the earlier mail: What I want is: dbmodel.objects.filter(__first_filter).sum(), should be able to sum across the filtered data. If somebody could help me out on this, I would be very thankful. P.S-> Also, is it safe to use the backends.quote_name for getting the name of the table in the DB? Is there any other mechanism to get the original name of the table? Regards, K > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
django template script variable usage and declaration
Hello I am new to python world . any one can help to guide how we declare variables in python template script and use in if else block and vary it for example //need to declare variable here //for example x=0 {% for message in message %} //need to put if condition here //ifequal x 0 //x=1 //need to put else condition here x=0 mzubair.ahmed test 2008-12-12 05:13:45.788901 {%endfor%} -- Regards Haroon Idrees Sr.Software Engineer cell:92321-2066747 msn:haroon.idr...@hotmail.com http://www.linkedin.com/in/haroonob --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Creating a custom sql query
Hi, I am sorry if this question was asked earlier. I searched in google, but couldnt find much help on this. I found that I have to create a custom sql query for aggregation of results. My question is - is it possible to integrate it with other filters? i.e. is it possible to get only the queryset updated and not hit the database? http://www.pointy-stick.com/blog/2006/06/14/custom-sql-django/ mentions that it is not possible, but it is a 2 yr old document, so I wanted to be doubly sure. For example: What I want is: dbmodel. --~--~-~--~~~---~--~~ 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: SOAPpy and pyxml installation/usage
Wiadomość napisana w dniu 2008-12-11, o godz. 09:31, przez Steve: > This may be a more of a generic Python question, but I'm working with > Django so thought that I'd see if there's a Django specific solution > to it. > > I'm trying to work with SOAP. I'm new to it and a Jr. programmer as > well. From Dive into Python it has this great example about how to > handle SOAP calls. > http://www.diveintopython.org/soap_web_services/index.html Drop SOAPpy and ZSI, they are not documented and nearly dead. Try suds. -- We read Knuth so you don't have to. - Tim Peters Jarek Zgoda, R&D, Redefine jarek.zg...@redefine.pl --~--~-~--~~~---~--~~ 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: SOAPpy and pyxml installation/usage
Hello Paul, Thanks for pointing me in the right direction. I had already downloaded and installed ZSI 2.0 but failed to gain any utility from it. Now I know where to apply my efforts. I'm still trying to get a basic call response working with ZSI. :\ I'll post for posterity when I figure out how to convert the above code to ZSI. -Steve On Dec 11, 5:57 am, "Paul Nendick" wrote: > Hello Steve, > SOAPy appears to be moribund. I was once using it within a Python SOA > I'd worked with and chose to abandon it when we moved that system to > Python 2.5. It wasn't an issue for us as SOAP was going nowhere (for > us anyway). > Good news for you (possibly) is the SOAP infrastructure generally > discussed by the Twisted Matrix community: ZSI. > > Relevant code:http://tinyurl.com/betterthansoapy > > Full project:http://pywebsvcs.sourceforge.net/ > > What I feel is the best XML library for > Python:http://uche.ogbuji.net/tech/4suite/amara/ > > regards, > > /p > > 2008/12/11 Steve > > > > > This may be a more of a generic Python question, but I'm working with > > Django so thought that I'd see if there's a Django specific solution > > to it. > > > I'm trying to work with SOAP. I'm new to it and a Jr. programmer as > > well. From Dive into Python it has this great example about how to > > handle SOAP calls. > >http://www.diveintopython.org/soap_web_services/index.html > > > The problem is that I'm trying to install the SOAPpy module and it > > requires pyxml, which appears to be no longer available or supported. > >http://pyxml.sourceforge.net/ > > > My main goal is to configuremy system to get this code, from the dive > > into python link above, to run. Or to find an equivalent set of > > packages that work instead. I'm working on windows with python 2.5.1, > > with Django .96. I deploy on ubuntu linux. Any thoughts? > > > ... > > from SOAPpy import WSDL > > > # you'll need to configure these two values; > > # seehttp://www.google.com/apis/ > > WSDLFILE = '/path/to/copy/of/GoogleSearch.wsdl' > > APIKEY = 'YOUR_GOOGLE_API_KEY' > > > _server = WSDL.Proxy(WSDLFILE) > > def search(q): > > """Search Google and return list of {title, link, description}""" > > results = _server.doGoogleSearch( > > APIKEY, q, 0, 10, False, "", False, "", "utf-8", "utf-8") > > return [{"title": r.title.encode("utf-8"), > > "link": r.URL.encode("utf-8"), > > "description": r.snippet.encode("utf-8")} > > for r in results.resultElements] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---