Re: render_to_response fails with TemplateSyntaxError: too many values to unpack
On Wed, Aug 19, 2009 at 8:30 AM, Janne Peltolawrote: > > Template rendering fails when both form data and a tuple are passed to > render_to_response. > > Python: 2.6.2; Django: 1.1; Environment: Windows + built-in dev server > > I use the standard django.contrib.auth.models.User and .Group models. > > View: > > class FuksiForm(forms.Form): >ryhmat = forms.ModelChoiceField(queryset=Group.objects.none(), > empty_label = "Ei saapunut") > >def __init__ (self, qset): >super(FuksiForm, self).__init__(qset) >self.fields["ryhmat"].queryset = qset Janne, I was able to recreate your error with a test app, and made it go away by *not* passing qset to the super call to __init__ (which is not expecting a qset argument). > > > def fuksit(request, ohjelma_id): >if request.method == 'POST': # If the form has been submitted... >form = FuksiForm(request.POST) # A form bound to the POST > data >if form.is_valid(): # All validation rules pass >msg = 'meh' >return HttpResponse(msg) > >else: >users = > User.objects.filter(ryhma__nimi__startswith=ohjelma_id) > >groups = Group.objects.filter(name__startswith=ohjelma_id) > >form = FuksiForm(qset = groups) >d = {'form': form, 'pf': users} > > > Template: > > > {% for u in pf %} > >{{ u.first_name }} {{ u.last_name }} >{{ u.username }} >{{ form.ryhmat.errors }} for="id_ryhmat">Ryhma > {{ form.ryhmat }} > > {% endfor %} > I would also expect that instantiating a single form and then repeating it for each user in users may cause you difficulties when you start submitting those forms, but I'm not sure about that... Hope that helps, Eric > > > This produces: http://users.tkk.fi/jjpelto3/exception.html > > When either form or pf are removed from the dictionary, the program > works fine. However, everything seems to be fine until > render_to_response when I do debugging in the shell. > > I suspect a bug in the rendering handler, since people on #django were > unable to help either. There are no documented similar cases. > > I am utterly perplexed. Please help. :) > > > > --~--~-~--~~~---~--~~ 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 much memory does a django instance need was Does Hostmonster support Django?
> did all this - I am still getting around 35 MB per instance. And it > is not the fault of webfaction. The same site on my local machine > gives the same figure. This on the latest svn in both cases. The last > time I looked at these figures, it was around 12-15mb an instance. > Any other clues? I remember someone there saying that right after you restart Apache the RAM usage is low, but after it's served a few requests the usage jumps, and then stays high -- ie, it's normal. Had you kept it at 12-15 for a long time previously? Is it possible that the last time you checked usage was just following an Apache restart? Otherwise, my solution to these problems is to host unpopular websites that no one looks at. Yrs, E --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: url tag difficulties
> No. This one's a case or pilot error. If you want to use this form, you > must write it as: > > url(r'^$', 'index', name="blog-index") > > url() is a function call, so you can pass it named arguments. The (...) > form (without a leading "url") is a Python tuple and you can't use > 'name=value' style arguments and it must have four arguments. Best to > stick to the url() form. > > By the way, you can test whether things are working at the interactive > prompt using reverse(), which is how the url template tag is > implemented: Thanks you two, I hadn't caught on that it was going from a tuple to an actual function. reverse('index') gets me NoReverseMatch, which isn't surprising given that my urls aren't working. I'm going to do some tidying and make sure nothing's escaped me. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: url tag difficulties
> hello, > > I am learning a lot from the B-List blog > Here is an entry, which could be interesting for > you:http://www.b-list.org/weblog/2007/nov/06/urlconf/ > (specially the named URL patterns) Thanks Bernd, I'd seen that before, and decided I wouldn't mess with it if I couldn't get the basics to work. But I just tried it, and turning (r'^$', 'index'), into (r'^$', 'index', name="blog-index"), gave me a syntax error on that line. I'm running r6659, only one short of head. Is it because I'm not using generic views? I wonder if this is another indication of whatever it is I've borked... E --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
url tag difficulties
I really hope this isn't embarrassingly obvious but... My {% url %} tags aren't producing anything -- no error and no url. My current setup is so bare-bones I can't imagine what's gone wrong. Here are the basics: ROOT_URLCONF = Project.urls In Project.urls: (r'^$', 'app1.views.index'), (r'^(?Pauthors|books|publishers)/$', 'app2.views.browse'), The app2.views.browse view uses a render_to_response, with a RequestContext. I've got no TEMPLATE_CONTEXT_PROCESSORS set, so I'm using default. app2.views.browse renders the app2/browse.html template, with no context variables passed in except what the RequestContext puts in there. I thought the problem was that ROOT_URLCONF wasn't available in the template, but I imported that specifically and passed it in, with the same result. In app2/browse.html template: Home (I've also tried Project.app1.views.index, and other variations, with the same result) All I want is a link to the homepage, but nothing is output. This is the simplest case but the I get the same result in all my views and templates. I'm using the development version of Django, and the development server. Can anyone see where I've got wrong? I tried setting the TEMPLATE_STRING_IF_INVALID variable to '%s', but I guess this doesn't actually count as an invalid template tag. I'd be very grateful for any help! Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: webhostingbuzz, anyone tried
I'm also on webfaction, and like it. The most basic plan is pretty skimpy on server RAM (simply enabling debug on my site put it over the limit, and I was the only one accessing it), but you'll be fine if you take a bit of care with the setup. Django works straight out of the box, and their support is great. E On Nov 8, 10:27 pm, Joe <[EMAIL PROTECTED]> wrote: > I use webfaction and I've found them to be great. > > J > > On Nov 8, 2:19 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > Hi guys. > > These guys seem to have very tempting packages. They say they support > > django. What I'd like to know is what kind of support? Do I have to > > install it on my home folder, or is it preinstalled on their servers? > > Second thing I wanted to ask about, is the speed. My current account > > goes really slow, and it has only one flatpage to handle. How good it > > webhostingbuzz on that issue? > > Thanks in advance > > Yair --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Anyone running mod_python for Python 2.5 on Mac OS X?
Whoops, sorry, ignore that last... On Nov 1, 10:16 am, [EMAIL PROTECTED] wrote: > Ulf, did you ever figure this out? I don't use pgsql/psycopg, but I've > had the same issues with mod_python and competing framework/MacPort > installations of Python. And I didn't even know there was a > $PYTHONHOME variable. > > I've done everything I can to change paths and reroute framework- > Python to Macport-Python using symbolic links, but still mod_python > tracebacks show that, at some point during the trace, it is trying to > get at the framework installation of Python. > > Bumping hopefully... > > E --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: the old django-in-a-subdirectory problem
> for what its worth, here is part of the httpd.conf file (smedia is > where the uploaded media is put, if you want to serve it from the > main apache, you *must* put it in ./webapps/ directory): One last question then I'll let this drop: Kenneth you mention putting things directly into your webapps directory: I don't have write permission in my webapps directory, how did you manage that? E --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: the old django-in-a-subdirectory problem
Thanks, Kenneth and Karen... > Wrong order, you won't need the 500.html (nearly as much) once all the bugs > are worked out, many of which you will find while getting the front page to > work! :) Ha! Understood. > So, I think you can fix it by including the trailing slash in all your links > in your templates. It might also be worthwhile figuring out why the > re-writer is removing the django part, but I have no idea how you'd figure > that out. I'd get a trailing slash in links produced by the url tag by including the slash in the urls.py file, is that right? And I'm baffled by the re-write as well - most like the apache config file that's doing it is somewhere where I can't get to it. On Oct 31, 12:33 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 31-Oct-07, at 9:06 AM, Malcolm Tredinnick wrote: > i use webfaction - my site is athttp://mysite.info/web/and admin is > athttp://mysite.info/web/admin/and both these are controlled by my > apache.conf which is identical to my apache.conf in non webfaction > accounts. My app is hosted at ./webapps/django/myapp - I use latest > svn trunk and handle everything from the shell and not the control > panel. If you didn't use the control panel to mount the django installation at /web, did you have to do anything else special to get it to work properly, besides adding a ^web/ prefix to your url files? I'd hate to think it's been simple as that all along, and I've just been tripped up by using webfaction's control panel... Thanks again, Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: the old django-in-a-subdirectory problem
http://taojian.webfactional.com/django/InnerWorks/ works fine from here, try once more? > I get back a 500 status code (and you really need to create a 500.html > template, btw). I'm saving all that for after I've got the front page working properly :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: the old django-in-a-subdirectory problem
> You haven't really provided enough details for me, at least, to know > what you're doing here. Thanks very much for taking the time to look at this, the whole thing has been very frustrating... Part of the problem may come from the fact I'm hosting this on WebFaction, and in their control panel the django installation is rooted at /django. I'm guessing (though few of my guesses have panned out so far) that that setup sends information which screws up the use of ^django/ in the urls. You're right it is probably an HTTP redirect going on, as it happens in the browser address bar. Here's my setup so far (it's simple since I haven't been able to get past this stage): My project urls: urlpatterns = patterns('', (r'^admin/', include('django.contrib.admin.urls')), (r'^InnerWorks/', include('InnerWorks.classsched.urls')), ) 'classsched' app urls: urlpatterns = patterns('InnerWorks.classsched.views', (r'^$', 'index'), (r'^teachers', 'teachers'), ) classsched index and teachers views: def index(request): courseTypes = CourseType.objects.all() return render_to_response('classsched/index.html', {'courses':courseTypes,},) def teachers(request): teachers = Teacher.objects.all() return render_to_response('classsched/teachers.html', {'teachers': teachers,}) You can see the page yourself here: http://taojian.webfactional.com/django/InnerWorks/ That's the index view and it comes up fine. Right now the only actual template code on the whole page (besides filling in blocks) is the "Teacher Biographies" link at the bottom right, under "Community". That link is output like so: Teacher Biographies, which produces http://taojian.webfactional.com/django/InnerWorks/teachers/. If you click on the link, or enter the url directly into the address bar, you get the disappearing segment trick. Obviously, this is not the way it should be. I am, indeed, ignorant of the ins and outs of server setups, and so far 'learning django' has actually been 'learning the basics of web hosting configuration'. It's necessary, but I'm anxious to get past that to django itself. Any help you could provide would be greatly appreciated. Yrs, Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: the old django-in-a-subdirectory problem
On Oct 31, 6:20 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Oct 31, 1:15 am, [EMAIL PROTECTED] wrote: > If you use mod_wsgi, it contains instructions for how to mount > application on a sub url rather than at root. To make it all work > requires doing a workaround in the WSGI wrapper around Django to cope > with Django not recognising SCRIPT_NAME variable properly. Also > necessary to ensure urls.py path include prefix as well. See: > > http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango > > This has links to relevant Django tickets where the problem is raised. Great! I am not using mod_wsgi and am not even sure what it is, but I'll find out now. Your link looks like a real solution, rather than the hacks I've read elsewhere, and I particularly like that it's possible to host several django installations on different subdirectories. Thanks a lot for this information! Yours, Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
the old django-in-a-subdirectory problem
This issue has come up for many people in many places, but most of the threads seem old, and none of the solutions proposed has helped. I have a django installation in a subdirectory of a site, like so: www.mysite.com/django. At first I noticed a problem with the admin login, like other people have had (where the /django/ portion of the url is removed when you try to login, leading to a 404), and solved it by copying some of the admin template pages into my own project template directory. It appears that the problem also affects ALL url tags in my templates: using the {% url path/to/view %} tag produces a URL which doesn't include the /django/ section, meaning it's invalid. Trying to cheat like this: href="/django{% url path/to/view %}" produces the correct url in the template page, but when I actually click the link, django removes the /django/ section from the url in the browser address bar, and then tells me it can't find the page. I've tried adding r'^django/' at the front of the urls in my url config, but that just results in none of the urls matching. Does anyone have an explanation or a solution for this? Many thanks in advance, Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: static images with built-in django server
Me too, I can't get this to work and it's driving me crazy. My main problem seems to be that Django is looking inside the Django site package within my Python framework for the media (when I try to load an image directly, for instance, it tells me "Page not found: /Library/ Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ django/contrib/admin/media/img/image.gif") and I don't know how to tell it to look in my site installation instead of python. I'm using Python 2.5, Mac OSX, the svn version of Django, my development server runs at http://127.0.0.1:8000/ In template I've tried: http://127.0.0.1:8000/media/img/image.gif;> and In the site package urls I've got: (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': 'media'}) I also tried writing out document_root as the full absolute path to the media directory on my computer. MEDIA_ROOT = './media/' (relative path from settings.py, I also tried a full absolute path) MEDIA_URL = 'media/' for completeness' sake, the absolute path to my media folder ought to be /Users//Documents/Django//media/ I tried all the above in various configurations. It's voodoo at this point and the gods are not smiling. If anyone can see what my problem is I'd be very grateful for a pointer... Thanks, Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---