creating a composite primary key, for a field that isn't in the database...
Hi all, We have a situation where; 1. we have a database that has several tables that use composite primary keys 2. the database *cannot* be munged to add an auto increment integer field (sadly, otherwise this would be a very short post) 3. we don't need to write back to the database 4. we don't need these tables to be represented in the admin application 5. we would lookup records in the table via one or more of the (primary keyed, therefore indexed) composites of the primary key 6. we need a 'primary key' so we can iterate over the objects that are returned from queries so, with that in mind, can anyone suggest a way of 'creating' the key we need for #6 above? I had thought of something like this; # this field does not exist in the database fake_pk = FakePrimaryKeyField(primary_key = True, composites = ['field1' ,'field2', 'field3']) # the following fields do exist in the database field1 = models.CharField(max_length = 10) field2 = models.CharField(max_length = 5) field3 = models.IntegerField() with our 'FakePrimaryKeyField' doing something like; pk = '%s%s%s' % (field1, field2, field3) But I can't figure out how to 'tie in' the fields to tell the _meta part of the model that fake_pk is supposed to be the primary key. Note that 'fake_pk' is *not* in the database at all. Does anyone have any pointers; I've looked at http://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys and http://docs.djangoproject.com/en/dev/howto/custom-model-fields/ and examples of 'custom fields' and nothing I've seen seems to add the vital "I'm the primary key" juice into the mix. Any pointers will be gratefully accepted! Cheers, Tone --~--~-~--~~~---~--~~ 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: Newcastle, UK Django positions (was "Some django-based jobs available")
Thanks for the rewrite of the subject line Tim, I should have put more location information into the post. I've also added it to django-gigs to get a wider audience. And thanks for being understanding regarding those 'abominably long target URLs' - it's an outsourced operation over which we have no control. They've obviously not heard of SEO! Regarding the jobs: I don't think we can go for telecommuting at the moment, but it's something we're willing to consider in the future. thanks again for your help, Tone On Apr 16, 1:55 pm, Tim Chase <django.us...@tim.thechases.com> wrote: > tonemcd wrote: > > I hope I'm not breaching etiquette here. > > Not particularly...however you may also want to post > onhttp://djangogigs.comto reach the broadest audience. > > One other tip -- though your email CC's Newcastle, UK addresses > and the below redirectors point to the Newcastle pages, it's > helpful to include location information right up front (as well > as any telecommuting option if available) in the body/subject of > the email. This helps folks filter out chaff or spot positions > of interest. I've changed the subject line to reflect it, but > for others on the list that may be considering posting positions, > it helps. > > > The URLs are; > > > Infrastructure Development Officer:http://is.gd/sJW9 > > and > > Web Development Officer:http://is.gd/sJWu > > In some circles (more so on mailing lists & blogs, less so on > twitter), this is more a breech of etiquette -- using shortened > URLs that point randomly into the internet. However, in the case > of those abominably long target URLs, I think shortening is > acceptable in this case :) > > -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 -~--~~~~--~~--~--~---
Some django-based jobs available
I hope I'm not breaching etiquette here. We have two jobs going at the moment, where a large proportion of the work will be in Django. To apply, you *must* go through our University online system. Sorry about that. The URLs are; Infrastructure Development Officer: http://is.gd/sJW9 and Web Development Officer: http://is.gd/sJWu All further details (including contact details of people who can give more information) are available at the URLs. Thanks, Tone --~--~-~--~~~---~--~~ 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: _clone method in list_detail (generic views) loses information?
I should have spent the extra 10 minutes trying out the 'property' solution (rather than the several hours I've spent on the generic view/ pagination code). Adding this code to the model works perfectly well. def _link(self): from settings import ACCESS_PATH if self.mimetype == 'url': return '%sredirect?location=%s' % (ACCESS_PATH, self.uuid) else: return '%sdownload/%s/%s' % (ACCESS_PATH, self.uuid, self.filename) link = property(_link) I wouldn't mind, except I've used properties extensively before and it never occurred to me to use them this time sigh. Cheers, Tone On Mar 30, 12:38 pm, tonemcd <tony.mcdon...@gmail.com> wrote: > Hi, > I'm used to doing things like this; > > resources = Resource.objects.all() > for resource in resources: > if resource.thetype == 'url': > resource.link = '/access/redirect?location=%s' % resource.uuid > else: > resource.link = '/access/download/%s/%s' % (resource.uuid, > resource.filename) > > It means that more logic is shunted from the template to the view. > > This helps some browsers to determine what they should do with a link > (we use file-disposition and mimetype etc - but we still need to do > this) > > I've just wired this up to generic views and find that this line (46) > in django/views/generic/list_detail.py causes the 'link' attribute to > disappear. (I put 'queryset[0].__dict__' before and after the line and > 'link' had dissappeared) > > 46: queryset = queryset._clone() > > Is this expected behaviour? If so, should I be doing things in a > different way (property on the model perhaps)? > > Any thoughts appreciated > Cheers, > Tone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
_clone method in list_detail (generic views) loses information?
Hi, I'm used to doing things like this; resources = Resource.objects.all() for resource in resources: if resource.thetype == 'url': resource.link = '/access/redirect?location=%s' % resource.uuid else: resource.link = '/access/download/%s/%s' % (resource.uuid, resource.filename) It means that more logic is shunted from the template to the view. This helps some browsers to determine what they should do with a link (we use file-disposition and mimetype etc - but we still need to do this) I've just wired this up to generic views and find that this line (46) in django/views/generic/list_detail.py causes the 'link' attribute to disappear. (I put 'queryset[0].__dict__' before and after the line and 'link' had dissappeared) 46:queryset = queryset._clone() Is this expected behaviour? If so, should I be doing things in a different way (property on the model perhaps)? Any thoughts appreciated Cheers, Tone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Any django training available in the UK?
Hi all, Is anyone doing any django training in the UK? I need F2F and possibly remote *as backup to F2F* for my team. They are very familiar with Zope, and we are a linux-based shop. We have facilities on-site for training. We are based in the North East of England. Please get in contact and I'll provide as many details as you need. Cheers, Tone --~--~-~--~~~---~--~~ 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: Django new comments framework error
...and of course, I find that http://code.djangoproject.com/ticket/8221 is now fixed! That should help clear up an awful lot of confusion. As of r8672, it's in the trunk. Cheers, Tone On Aug 29, 7:40 am, tonemcd <[EMAIL PROTECTED]> wrote: > Also > seehttp://groups.google.com/group/django-users/browse_thread/thread/1f4b... > > Short summary: maybe your named url regexes aren't matching the > variables passed to them in the {% url ... %} tag. > > Apply the patch fromhttp://code.djangoproject.com/ticket/8221and > you'll know for certain if that's it. > > Zapping old .pyc files can't hurt too! > > Cheers, > Tone > > On Aug 29, 4:29 am, hotani <[EMAIL PROTECTED]> wrote: > > > > > Did you delete the .pyc files from the django source? Another approach > > would be to go into /django/contrib/ and delete the comments > > directory, then do an 'svn up' to restore it. Then you'll be sure to > > get a fresh copy. > > > That is what worked for me. But if you haven't used the comment system > > before then there shouldn't even be any pyc files in there, so I don't > > know what is going on. > > > On Aug 28, 2:57 am, Mark <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > Updated to 8613 with the release of Django 1.0 Beta 2 and saw the > > > addition of commenting framework - tried to add it and am getting a > > > similar error to above. > > > > On Aug 27, 3:54 pm, Slavus <[EMAIL PROTECTED]> wrote: > > > > > Here is the solution: > > > > You'll get this if you still have stale pyc files left over from the > > > > old comment system. Delete 'em and your code will work. > > > > I tried this (even though I did not use the old commenting system). > > > > Here is the exception information... > > > --- > > > - > > > Environment: > > > > Request Method: GET > > > Request URL:http://localhost/apps/buildboard/builddetails/80/ > > > Django Version: 1.0-beta_1-SVN-unknown > > > Python Version: 2.5.1 > > > Installed Applications: > > > ['django.contrib.auth', > > > 'django.contrib.contenttypes', > > > 'django.contrib.sessions', > > > 'django.contrib.sites', > > > 'django.contrib.admin', > > > 'django_apps.buildboard', > > > 'django_xmlrpc', > > > 'django.contrib.comments'] > > > Installed Middleware: > > > ('django.middleware.common.CommonMiddleware', > > > 'django.contrib.sessions.middleware.SessionMiddleware', > > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > > 'django.middleware.doc.XViewMiddleware') > > > > Template error: > > > In template c:\_tools\python251\lib\site-packages\django\contrib > > > \comments\templates\comments\form.html, error at line 2 > > > Caught an exception while rendering: Reverse for ' > > post_comment at 0x0158BEF0>' not found. > > > 1 : {% load comments %} > > > > 2 : > > > > 3 : {% for field in form %} > > > > 4 : {% if field.is_hidden %} > > > > 5 : {{ field }} > > > > 6 : {% else %} > > > > 7 : > > > 8 : {% if field.errors %} class="error"{% endif %} > > > > 9 : {% ifequal field.name "honeypot" %} > > > style="display:none;"{% endifequal %}> > > > > 10 : {% if field.errors %}{{ field.errors }}{% endif %} > > > > 11 : {{ field.label_tag }} {{ field }} > > > > 12 : > > > > Traceback: > > > File "c:\_tools\python251\lib\site-packages\django\core\handlers > > > \base.py" in get_response > > > 86. response = callback(request, *callback_args, > > > **callback_kwargs) > > > File "c:\_tools\python251\lib\site-packages\django\contrib\auth > > > \decorators.py" in __call__ > > > 67. return self.view_func(request, *args, **kwargs) > > > File "c:\_projects\django_apps\..\django_apps\buildboard\views.py" in > > > build_details > > > 309. print t.render(c) > > > File "c:\_tools\python251\lib\site-packages\django\template > > > \__init__.py" in render > > > 176. return self.nodelist.render(context) > > > File "c:\_tools\python251\lib\site-packages\django\template > > > \__init__.py" in
Re: Photologue Error: NoReverseMatch -- Reverse for 'pl-gallery' not found.
The link would help :rolls eyes: http://groups.google.com/group/django-users/browse_thread/thread/eb5db61766a5dc07/a32ec2de4bd9ff0f?lnk=gst=noReverseMatch#a32ec2de4bd9ff0f On Aug 30, 3:12 pm, tonemcd <[EMAIL PROTECTED]> wrote: > Check out this link, apply the patch and I think you'll see the > problem (basically, whatever is being passed to {% url ... %} does not > match the regex in urls.py). > > Cheers, > Tone > > On Aug 30, 12:25 am, Jacolyte <[EMAIL PROTECTED]> wrote: > > > > > Here's a pastebin of the traceback:http://pastebin.com/m43fb0960 > > > Photologue is version 2.0-rc1 > > > Django is version 1.0-beta_1 > > > I did everything the photologue readme said. Put photologue in my > > installed apps, ran syncdb, plinit, etc. everything went fine. > > > I added a photo and made a gallery, and then in the admin interface > > for my gallery I clicked on "View on site" and it gives me this error. > > > The traceback is saying my code is trying to use a named URL pattern > > that doesn't exist, right? Well, shouldn't creating a photologue > > gallery create that URL that the URL pattern references? --~--~-~--~~~---~--~~ 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: Photologue Error: NoReverseMatch -- Reverse for 'pl-gallery' not found.
Check out this link, apply the patch and I think you'll see the problem (basically, whatever is being passed to {% url ... %} does not match the regex in urls.py). Cheers, Tone On Aug 30, 12:25 am, Jacolyte <[EMAIL PROTECTED]> wrote: > Here's a pastebin of the traceback:http://pastebin.com/m43fb0960 > > Photologue is version 2.0-rc1 > > Django is version 1.0-beta_1 > > I did everything the photologue readme said. Put photologue in my > installed apps, ran syncdb, plinit, etc. everything went fine. > > I added a photo and made a gallery, and then in the admin interface > for my gallery I clicked on "View on site" and it gives me this error. > > The traceback is saying my code is trying to use a named URL pattern > that doesn't exist, right? Well, shouldn't creating a photologue > gallery create that URL that the URL pattern references? --~--~-~--~~~---~--~~ 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: Django new comments framework error
Also see http://groups.google.com/group/django-users/browse_thread/thread/1f4bb991f9f0f7b5/62005ad4330c4884?lnk=gst=noReverseMatch#62005ad4330c4884 Short summary: maybe your named url regexes aren't matching the variables passed to them in the {% url ... %} tag. Apply the patch from http://code.djangoproject.com/ticket/8221 and you'll know for certain if that's it. Zapping old .pyc files can't hurt too! Cheers, Tone On Aug 29, 4:29 am, hotani <[EMAIL PROTECTED]> wrote: > Did you delete the .pyc files from the django source? Another approach > would be to go into /django/contrib/ and delete the comments > directory, then do an 'svn up' to restore it. Then you'll be sure to > get a fresh copy. > > That is what worked for me. But if you haven't used the comment system > before then there shouldn't even be any pyc files in there, so I don't > know what is going on. > > On Aug 28, 2:57 am, Mark <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > Updated to 8613 with the release of Django 1.0 Beta 2 and saw the > > addition of commenting framework - tried to add it and am getting a > > similar error to above. > > > On Aug 27, 3:54 pm, Slavus <[EMAIL PROTECTED]> wrote: > > > > Here is the solution: > > > You'll get this if you still have stale pyc files left over from the > > > old comment system. Delete 'em and your code will work. > > > I tried this (even though I did not use the old commenting system). > > > Here is the exception information... > > --- > > - > > Environment: > > > Request Method: GET > > Request URL:http://localhost/apps/buildboard/builddetails/80/ > > Django Version: 1.0-beta_1-SVN-unknown > > Python Version: 2.5.1 > > Installed Applications: > > ['django.contrib.auth', > > 'django.contrib.contenttypes', > > 'django.contrib.sessions', > > 'django.contrib.sites', > > 'django.contrib.admin', > > 'django_apps.buildboard', > > 'django_xmlrpc', > > 'django.contrib.comments'] > > Installed Middleware: > > ('django.middleware.common.CommonMiddleware', > > 'django.contrib.sessions.middleware.SessionMiddleware', > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > 'django.middleware.doc.XViewMiddleware') > > > Template error: > > In template c:\_tools\python251\lib\site-packages\django\contrib > > \comments\templates\comments\form.html, error at line 2 > > Caught an exception while rendering: Reverse for ' > post_comment at 0x0158BEF0>' not found. > > 1 : {% load comments %} > > > 2 : > > > 3 : {% for field in form %} > > > 4 : {% if field.is_hidden %} > > > 5 : {{ field }} > > > 6 : {% else %} > > > 7 : > > 8 : {% if field.errors %} class="error"{% endif %} > > > 9 : {% ifequal field.name "honeypot" %} > > style="display:none;"{% endifequal %}> > > > 10 : {% if field.errors %}{{ field.errors }}{% endif %} > > > 11 : {{ field.label_tag }} {{ field }} > > > 12 : > > > Traceback: > > File "c:\_tools\python251\lib\site-packages\django\core\handlers > > \base.py" in get_response > > 86. response = callback(request, *callback_args, > > **callback_kwargs) > > File "c:\_tools\python251\lib\site-packages\django\contrib\auth > > \decorators.py" in __call__ > > 67. return self.view_func(request, *args, **kwargs) > > File "c:\_projects\django_apps\..\django_apps\buildboard\views.py" in > > build_details > > 309. print t.render(c) > > File "c:\_tools\python251\lib\site-packages\django\template > > \__init__.py" in render > > 176. return self.nodelist.render(context) > > File "c:\_tools\python251\lib\site-packages\django\template > > \__init__.py" in render > > 756. bits.append(self.render_node(node, context)) > > File "c:\_tools\python251\lib\site-packages\django\template\debug.py" > > in render_node > > 71. result = node.render(context) > > File "c:\_tools\python251\lib\site-packages\django\contrib\comments > > \templatetags\comments.py" in render > > 158. formstr = render_to_string(template_search_list, > > {"form" : self.get_form(context)}, context) > > File "c:\_tools\python251\lib\site-packages\django\template\loader.py" > > in render_to_string > > 107. return t.render(context_instance) > > File "c:\_tools\python251\lib\site-packages\django\template > > \__init__.py" in render > > 176. return self.nodelist.render(context) > > File "c:\_tools\python251\lib\site-packages\django\template > > \__init__.py" in render > > 756. bits.append(self.render_node(node, context)) > > File "c:\_tools\python251\lib\site-packages\django\template\debug.py" > > in render_node > > 81. raise wrapped > > > Exception Type: TemplateSyntaxError at /apps/buildboard/builddetails/ > > 80/ > > Exception Value: Caught an exception while rendering: Reverse for > > '' not found. >
Re: Random NoReverseMatch
I've just come across this ticket, http://code.djangoproject.com/ticket/8221, which has a patch attached. I've just applied the patch and crippled my url regex again to re-create the error. This is what was reported this time; NoReverseMatch: Reverse for 'MBBS.agenda_today_group' with arguments '(u'st4gp4&5',)' and keyword arguments '{}' not found. Now *that* would have saved a heap of time earlier on today ;) Ticket 8221 is down for the 1.0 release, so hopefully, we'll have that in trunk ready for the big release of V1.0. HTH Tone On Aug 28, 6:20 pm, tonemcd <[EMAIL PROTECTED]> wrote: > Well, this bit me a while back when I svn-up'ed from trunk and I got > fed up of changing my django.pth to point to trunk_r7971, so I was > determined to get it sorted out. > > The first thing is that the NoReverseMatch error seems to be a catch- > all for a variety of exceptions, so if you can, check out your imports > as Koen outlines below. > > However, I think that in this case it is far more likely that you have > some data that is triggering the NoReverseMatch exception, as you say > it happens randomly, and I think what is happening is your arguments > to {% url ... %} are not compatible with what your named url is > expecting to see. > > This is what happened to me; my urls are of the form; > > today//agenda > > where is letters (upper and lowercase), numbers and '-', so > these are valid stgp01, st2gp2-18 etc. > > I used this match to begin with; > url(r'^today/(?P[\w,-]+)/agenda$ > > fromhttp://python.about.com/od/regularexpressions/a/regexprimer.htm > you can see that \w handles alphanumerics and _. > > This is what killed it; > > /today/st4gp8&9/agenda > > With r7971 this would not have been a problem (well actually it would > have been a problem because the URL wouldn't work), but at least it > wouldn't give you an error. Now it does (it was changed in r8211, > seehttp://code.djangoproject.com/wiki/BackwardsIncompatibleChangesfor > more details). > > The solution for me was to include & and friends into the regex, so I > added \W as well (the above URL has details). > > My final URL pattern is url(r'^today/(?P[\w,\W-]+)/agenda$ and > this works just fine. > > I don't know what you're matching, but I'd hazard a guess that what > you're pumping out is not compatible with what your URL regex is > expecting to see. > > This seems like a prime example of something that needs a slightly > more descriptive error message, but whether that's possible or not, I > don't know (I did dig around in urlresolvers.py, but it went rapidly > over my django-fu). > > Hope this helps, > Tone > > On Aug 25, 8:40 pm, koenb <[EMAIL PROTECTED]> wrote: > > > > > I guess you are seeing the bug reported in #6379. You probably have an > > import error somewhere, but it is being hidden by theNoReverseMatch > > exception that is raised for anything that goes wrong. > > > Koen > > > On 25 aug, 16:13, Robin <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > i have the same exception and exactly as Julien explained in the dev > > > server works fine ... and also works fine with fast_cgi, but I am > > > using apache + mod_wsgi and it didn't work with the same problem: > > >NoReverseMatch > > > > Has any of you any clue to this error ? > > > > thanks in advance, > > > r > > > > On Aug 16, 8:16 pm, Alberto Piai <[EMAIL PROTECTED]> wrote: > > > > > On Aug 16, 12:01 am, Julien Phalip <[EMAIL PROTECTED]> wrote: > > > > > > Hi, > > > > > > It's likely that there is a typo somewhere in your templates, either > > > > > you didn't write the view name properly, or you didn't provide the > > > > > right parameters. > > > > > In the error message, there should be the name of the view. Look up > > > > > every occurrence et double check that you haven't made any typo. > > > > > I'm checking everything again. But actually I don't think the > > > > problem's there, as everything works fine when run from django's dev > > > > server, and now it's been working fine for some hours even on lighttpd > > > > +fcgi. When the problem appears again I'll send the traceback. > > > > > Thanks for you help, > > > > > Alberto --~--~-~--~~~---~--~~ 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: site using Django/mod_python/apache2 randomly showing "It worked!" page
Does Apache have mod_wsgi? If so, you can get them to make a change to your .conf file as detailed at http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode This means you only need to 'touch' the .wsgi file specified by the WSGIScriptAlias to get your Apache process to restart. Works a treat! I moved away from mod_python for the very reason you've outlined. The wealth of information on mod_wsgi is immense! Cheers, Tone On Aug 28, 6:25 pm, Gremmie <[EMAIL PROTECTED]> wrote: > On Aug 27, 8:18 pm, Richard Simões <[EMAIL PROTECTED]> wrote:> I have > non-root access to a server with apache2 and mod_python. I > > installed django with svn to a location in my home directory and > > created a test project. When I go to a URL defined with urls.py and > > views.py, 9/10 times the expected page is shown. The remaining 1/10 > > times the "It worked!" page pops up. Searching for this problem seems > > a bit difficult. Any idea on what could be happening? > > It sounds like some of the apache processes are running your new code, > but some of the other processes are still running the typical > mod_python test program you use to see if mod_python is configured > correctly. You will need to restart apache after every code change. --~--~-~--~~~---~--~~ 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: Random NoReverseMatch
Well, this bit me a while back when I svn-up'ed from trunk and I got fed up of changing my django.pth to point to trunk_r7971, so I was determined to get it sorted out. The first thing is that the NoReverseMatch error seems to be a catch- all for a variety of exceptions, so if you can, check out your imports as Koen outlines below. However, I think that in this case it is far more likely that you have some data that is triggering the NoReverseMatch exception, as you say it happens randomly, and I think what is happening is your arguments to {% url ... %} are not compatible with what your named url is expecting to see. This is what happened to me; my urls are of the form; today//agenda where is letters (upper and lowercase), numbers and '-', so these are valid stgp01, st2gp2-18 etc. I used this match to begin with; url(r'^today/(?P[\w,-]+)/agenda$ from http://python.about.com/od/regularexpressions/a/regexprimer.htm you can see that \w handles alphanumerics and _. This is what killed it; /today/st4gp8&9/agenda With r7971 this would not have been a problem (well actually it would have been a problem because the URL wouldn't work), but at least it wouldn't give you an error. Now it does (it was changed in r8211, see http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges for more details). The solution for me was to include & and friends into the regex, so I added \W as well (the above URL has details). My final URL pattern is url(r'^today/(?P[\w,\W-]+)/agenda$ and this works just fine. I don't know what you're matching, but I'd hazard a guess that what you're pumping out is not compatible with what your URL regex is expecting to see. This seems like a prime example of something that needs a slightly more descriptive error message, but whether that's possible or not, I don't know (I did dig around in urlresolvers.py, but it went rapidly over my django-fu). Hope this helps, Tone On Aug 25, 8:40 pm, koenb <[EMAIL PROTECTED]> wrote: > I guess you are seeing the bug reported in #6379. You probably have an > import error somewhere, but it is being hidden by theNoReverseMatch > exception that is raised for anything that goes wrong. > > Koen > > On 25 aug, 16:13, Robin <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > i have the same exception and exactly as Julien explained in the dev > > server works fine ... and also works fine with fast_cgi, but I am > > using apache + mod_wsgi and it didn't work with the same problem: > >NoReverseMatch > > > Has any of you any clue to this error ? > > > thanks in advance, > > r > > > On Aug 16, 8:16 pm, Alberto Piai <[EMAIL PROTECTED]> wrote: > > > > On Aug 16, 12:01 am, Julien Phalip <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > It's likely that there is a typo somewhere in your templates, either > > > > you didn't write the view name properly, or you didn't provide the > > > > right parameters. > > > > In the error message, there should be the name of the view. Look up > > > > every occurrence et double check that you haven't made any typo. > > > > I'm checking everything again. But actually I don't think the > > > problem's there, as everything works fine when run from django's dev > > > server, and now it's been working fine for some hours even on lighttpd > > > +fcgi. When the problem appears again I'll send the traceback. > > > > Thanks for you help, > > > > Alberto --~--~-~--~~~---~--~~ 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: Having trouble with per-view caching
Hugo, check this out:- http://groups.google.com/group/django-users/msg/581a32c198e6ae07 Not sure cache decorators have arguments... Cheers, Tone On Nov 4, 11:13 pm, "Hugh Bien" <[EMAIL PROTECTED]> wrote: > Hi, > I've emailed a few questions to this mailing list already and I've gotten > great responses, so thanks everyone for helping out people who are new to > Django. > > Okay, on to my question. I'm trying to get caching working with my weblog > but I keep running into an AttributeError. All I am doing is importing the > 'cache_page' function and decorating my view: > > @cache_page(60 * 15) > def my_view: ># do stuff and return render_to_response ... > > I get this error when I go to any view: > > Exception Type:AttributeErrorException Value:'function' object has no > attribute 'method'Exception > Location:/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/si > te-packages/django/middleware/cache.py > in process_request, line 47 > > which occurs at this line in cache.py: > > if not request.method in ('GET', 'HEAD') or request.GET: > > I really have no idea what went wrong, has anyone else run into this error? > > Thanks, > - Hugh --~--~-~--~~~---~--~~ 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: ADMIN_MEDIA_PREFIX setting weirdness
This may not be relevant, but I've had no end of confusion with ADMIN_MEDIA_PREFIX. What I've found is this; If you're running the development server, the value of ADMIN_MEDIA_PREFIX is effectively ignored. Look at the code in django/ core/servers/basehttp.py, in AdminMediaHandler and you'll see it serves the media up from the location that django is installed from. However, once you use something like fastcgi or mod_python to serve your content, the value of ADMIN_MEDIA_PREFIX is used, and you need to make sure it's pointing to something (of course, Apache/lighttpd etc rewrite rules can be used to tidy things up). This is all based on the description of what ADMIN_MEDIA_PREFIX does by Malcolm Tredinnick:- http://groups.google.com/group/django-users/msg/df0605a05a747e57 hope this helps, tone On Sep 28, 6:35 pm, omat <[EMAIL PROTECTED]> wrote: > Hi, > > This looks like a bug to me. > > When I set ADMIN_MEDIA_PREFIX = '/media/', some weird things happen, > such as: > - I get different 404 messages for non existing files > - the served files does not appear in the development server console > - the files under \site-packages\django\contrib\admin\media\ are > served, instead of the /media/ folder in under my MEDIA_ROOT > > But when I set ADMIN_MEDIA_PREFIX = 'http://localhost:8000/media/' > everything works as expected, that is: > - standard 404 messages > - served files appear in the console > - files under MEDIA_ROOT/media/ are served > > Any idea why this difference exists? --~--~-~--~~~---~--~~ 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: can´t do django update: propfind request failed
Check your ~/.subversion/servers file. Any proxy requirements (such as would be in the environment variable 'http_proxy') need to be replicated there. ie ... ... [global] # http-proxy-exceptions = *.exception.com, www.internal-site.org http-proxy-host = yourcache.yoursite.com http-proxy-port = 8080 ... ... hth Cheers, Tone On Sep 23, 10:35 am, patrickk <[EMAIL PROTECTED]> wrote: > we have a server with about 15 customers (vhosts) - every setup is > exactly the same and usually django-updates work fine. > but, when I don´t do an update for about 6 months, it doesn´t work > anymore (it´s the third this happens now). > > our system-administrator didn´t find anything. > > thanks, > patrick > > On Sep 21, 5:53 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > > > On 9/21/07, patrickk <[EMAIL PROTECTED]> wrote: > > > > when I do "svn update" within the django_src directory, I´m getting > > > this error: > > > svn: PROPFIND request failed on '/' > > > svn: PROPFIND of '/': 200 OK (http://code.djangoproject.com) > > > It's working fine for me. Double-check that things are working on your > > end of the network (especially that your administrator has not > > deployed any firewall or proxy rules which would block SVN). > > > -- > > "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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Need Customized Forms which look very much like Django admin interface ...
See here: http://groups.google.com/group/django-users/browse_frm/thread/3328829f1ed7f788/a980f983c5fc1bad Cheers, Tone On Jan 25, 8:01 am, "Praveen Swaminathan" <[EMAIL PROTECTED]> wrote: > I am trying to write a form which has multiple elements. One of them is a > Date field. How do I do it so that it looks like an admin interface > > -- > Thanks and Regards > Praveen --~--~-~--~~~---~--~~ 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: How to create a simple PDF
I was going to suggest looking at a Java-based system called Jasper reports, which we got into because we found ourselves spending too much time writing ReportLab scripts to generate PDFs (Jasper has a wysiwyg interface and connects to databases directly). However, seeing Chris' email reminded me of RML, which was designed by the ReportLab guys and *much* easier to use than ReportLab itself. We looked into that and were very interested, but the licencing fee was too high for us (the RL guys do a lot of work for finance houses, and they have plenty of cash). I don't think TinyRML is as powerful as RML, but you can't beat the price! Conrad, I think you should definitely look at Chris' solution - we've done a *lot* of work in ReportLab and as Kenneth says, it's not trivial, whereas Chris has made it all look easy ;) I particularly like the fact that the PDF templates (in RML format) are django templates - it reinforces the idea that django can do stuff other than HTML. Cheers, Tone --~--~-~--~~~---~--~~ 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: ViewDoesNotExist at /admin/
Two things; 1) you don't have anything setup in TEMPLATE_DIRS - may be important... 2) what does this give you; % ls -l /home/miiandu/django_src/django/contrib you want admin to look something like this; ... drwxr-xr-x 7 miiandyou 4096 Dec 4 18:19 admin ... and; % ls -l /home/miiandu/django_src/django/contrib/admin ... drwxr-xr-x 3 herbert 4096 Dec 12 00:52 views ... If they don't look like that, Margaret's suggestion of chown and chmod is probably the thing you need to do. hth tone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
gotapi.com - python there, no django (yet)
http://www.gotapi.com/ - very neat, lots of APIs to go through (HTML, Javascript etc) and now including python. No django as yet. :( However, you can't download copies of XML formats to see how others have done it (eg python). Cheers, Tone --~--~-~--~~~---~--~~ 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: Simple CAS 1.0 authentication
Brian, Just a quick note to say *thankyou very much* for making this available. I installed it into one of my development sites over the weekend and it works like a charm. I only tried the middleware version (which is probably more appropriate for an authentication backend) and found it to work just fine. In the end, all I had to do to get CAS authentication operational on my site was to change one line in settings.py and two in urls.py (once I'd installed cas into django.contrib). If that doesn't show the power of middleware then I don't know what does ;) Again, thanks heaps for making this available - it's done the business for me! Cheers, Tone --~--~-~--~~~---~--~~ 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: Database optmization guru needed...
Perhaps something from here will help? http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/59883 Where your list is an xrange(min...max) of id's from your database table. That is, do it in python, not with your database... Or maybe this, http://www.petefreitag.com/item/466.cfm - which *does* use the database ;) Cheers, Tone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
advice needed - how to manage 100+ django sites in a scaleable, manageable setup
Hi all, We're about to put our first django site online on Monday, which is a major departure for us. We currently host 100+ Zope instances, almost all of which are load balanced over more than one physical server using pound. Our databases are MySQL and increasingly, PostgreSQL, and these are also load balanced using pound. At the moment, the django site is running using mod_python and Apache 2.0, but this is not the way that our other systems run - we use pound and Zope clustering software (ZEO) to enable us to clone and slot in another Zope instance into the cluster as needed. This system has grown organically over several years, for example, for quite some time, we did no load balancing at all, even for our most heavily used systems. What I'd really like to know is how we could replicate this level of functionality with a django setup. Any ideas? I can provide more details if people would like to know, but really at the moment, I'm just trying to get a handle on what's possible. many thanks in advance, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Having problems getting started with Zyons
Quick update, Ian has updated the source in svn to fix the glitch. I've svn-uped and it everything is hunky-dory... Thanks very much Ian, from a reported glitch at 10:16 through to resolution by 12:31. Nice one! Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Having problems getting started with Zyons
I've posted a ticket at http://zyons.python-hosting.com/ticket/3 with a description of the problem and a possible solution based on the SQL alias. Funny, I would have thought there were more MySQL 4.0-4.1 people around than that (which would have shown the glitch earlier), guess I really do need to look at MySQL 5!! Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Having problems getting started with Zyons
Thanks Ian, Malcolm, this works!; mysql> select content_type_id, object_id, sum( unique_views) as sum_uv from counter_objecthourcounter where site_id=1 and effective_date >= '2006-07-18 09:50:07' and content_type_id in (30) group by content_type_id, object_id order by sum_uv desc LIMIT 40; Empty set (0.00 sec) IMHO, The initial error message from MySQL (Invalid use of group function) is a little bit misleading...as look what happens if the 'group by' part of the query is removed; mysql> select content_type_id, object_id, sum( unique_views) as sum_uv from counter_objecthourcounter where site_id=1 and effective_date >= '2006-07-18 09:50:07' and content_type_id in (30) order by sum(unique_views) LIMIT 40; ERROR (HY000): Invalid use of group function Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Having problems getting started with Zyons
I dug around a little, http://archives.neohapsis.com/archives/mysql/2005-q2/1966.html;>this helped a lot - and I found that this works (4.1.18-standard); mysql> select content_type_id, object_id, sum( unique_views) from counter_objecthourcounter where site_id=1 and effective_date >= '2006-07-18 09:50:07' and content_type_id in (30) group by content_type_id, object_id LIMIT 40; Empty set (0.00 sec) But of course the 'order by sum (unique_views) desc' has gone. Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Having problems getting started with Zyons
Ian, I think that's it - it definitely causes an SQL error on MySQL 4.1.18-standard. Drat. Our main systems (where I intend to run django 'for real') are stuck on the 4.1 series for the time being (hence why my machine is still running 4.1.18-standard). However, as I make the final decisions on what server versions we use, this could change ... ;) Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Having problems getting started with Zyons
Sorry Ian, I didn't mean to diss your application in the main discusssion forum! I just thought it might be a stupid user problem (I couldn't find it in the zyons.com forum). I've been watching the development of zyons for a while with a view to using it for the first stage of our Zope migration project and thought that I'd have a go at the latest release. Stupidly, I have posted the wrong SQL, it should be; select content_type_id, object_id, sum( unique_views) from counter_objecthourcounter where site_id=1 and effective_date >= '2006-07-18 09:50:07' and content_type_id in (30) group by content_type_id, object_id order by sum( unique_views ) desc LIMIT 40 I'll post the trackback in the 'bugs' forum at zyons.com Thanks for what looks like a really useful application by the way! Cheers, Tone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Having problems getting started with Zyons
Hi all, I'm trying to get the Zyons community/bulletin board system up and running - we think it could be extremely useful for a large part of our education community, and will assist us in migrating from Zope to Django. Trouble is, I can't get it to work on my machine (MacBook Pro, Python 2.4.3/MySL 4.1.18-standard) I get this error on pointing at the root; ProgrammingError at / (, 'Invalid use of group function') Template error (at line 38) In template /Users/bingobob/Sites/zilbo/common/forum/templates/forum/main_page.html, error at line 38 Caught an exception while rendering. 28 {% latest_conversations conv 10 %} 29 30 {% for c in conv %} 31 {{ c.forum.name }} {{ c.name }} 32 {% endfor %} 33 34 35 36 37 Most Popular 38 {% popular_objects Conversation c_o 40 %} 39 40 {% for a in c_o %} 41 {{ a.0.name }} 42 {% endfor %} 43 44 45 46 47 48 {% endblock %} The actual SQL generated is; select content_type_id, object_id, sum( unique_views) from counter_objecthourcounter where site_id=1 and effective_date >= '2006-07-18 09:12:08' and content_type_id in (30) order by sum( unique_views ) desc LIMIT 40 Is this a simple thing that I can fix (ie I've done something stupid), or do I need to include more traceback information? Cheers for any help, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Wiki or Blogs done with django
Possibly the quickest blog to get up and running is by Ross Poulton - http://www.rossp.org/ - his code has not had the magic removed yet though... Paul Bissex - http://e-scribe.com/news/171 - has done a *very* small Wiki implementation. Cheers, Tone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Feedjack - A Django+Python Powered Feed Aggregator (Planet)
Now this looks like a really cool django application. http://tabo.aurealsys.com/software/feedjack/ Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Limiting selection in admin pages [NEWBIE]
Good question - short answer is it's not anything I tried to do, so I don't know... Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Limiting selection in admin pages [NEWBIE]
Sorry Q, I forgot to add the WorkGroup definition; class WorkGroup(models.Model): groupName = models.CharField(maxlength=50) def __str__(self): return "%s" % self.groupName That's where the 'groupName' is coming from in my lookup. I'm using rev 2900 (ie the merged MR trunk) so I don't think there's any other magic going on. I'm guessing your definition of WorkGroup (or whatever your foreign key is) has a field 'name'. It may be that the lookup mechanism is checking for the 'name' property, but without digging into the source, it's just a guess on my part. Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Limiting selection in admin pages [NEWBIE]
This works (it's the pa - personal assistant - bit you want); class Person(models.Model): firstName = models.CharField(maxlength=50) lastName = models.CharField(maxlength=50) organization = models.ManyToManyField(Organization, related_name = 'organization') emailAddress = models.EmailField() title = models.CharField(maxlength=20, blank=True) phone = models.CharField(maxlength=20, blank=True) mobile = models.CharField(maxlength=20, blank=True) # extraneous stuff not included groups = models.ManyToManyField(WorkGroup, related_name = 'groups', blank=True) coordinator = models.ManyToManyField(WorkGroup, related_name = 'coordinator', blank=True) photos = models.ForeignKey(Photo, blank=True, null=True) pa = models.ForeignKey("self", blank=True, null=True, limit_choices_to = {'groups__groupName__exact' : 'Administration'}) # PA for this person Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: ANN: magic-removal branch merged to trunk
Ditto to that - I've been watching the activity on code.djangoproject.com, and there's been a huge amount of work done recently. Thanks again guys, this is a great framework! Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: FileField fieldRequired error
Take it easy You'll not make friends if people think you're shouting... This works for me with an ImageFile field. FileField should work the same... Template snippet: Title: {{ form.title }} Post date: {{ form.postdate_date }} Post time: {{ form.postdate_time }} Tags: {{ form.assoc_tags }} Image: {{ form.image_file }} {{form.image}} Body: {{ form.body }} And this view; Post is the name of my model, be careful to not confuse it with POST. def upload(request): # get all the content # for now, just assume a file is uploaded files = request.FILES for uploaded in files.keys(): # key is from , ie image_file filedata = files[uploaded] filename = filedata['filename'] content_type = filedata['content-type'] content = filedata['content'] body = request.POST.get('body', '') assoc_tags = request.POST.getlist('assoc_tags') title = request.POST.get('title', '') manipulator = Post.AddManipulator() # Post is my model name new_data = request.POST.copy() new_data.update(request.FILES)# definitely needed new_data['poster_id'] = str(request.user.id) # following needed to make sure manipulator.save passes off without a hitch new_data['poster'] = request.user.id new_data['slug'] = slugify(title) new_data['totalscore'] = 0 new_data['image'] = filename# this doesn't look like it should work, does it? new_data['uuid'] = 'no data entered' manipulator.do_html2python(new_data) new_post = manipulator.save(new_data) return HttpResponseRedirect('/electives/') Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Google SoC: Call for student applications
There's some seriously cool projects in that list! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Passing variables to include?
And enlightenment descends ;) Cheers for the pointer Ivan! Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Passing variables to include?
I don't understand why a more generic form of this tag isn't available; {% datatofillinthetemplate "templates/macrosnippet.html" %} Is there a philosophical reason why this doesn't exist? Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django vs Rails
That's a really good screencast - the Java-based frameworks come out particularly badly (but the author is looking more at the rapid applications development model, where multiple XML configs and compiling certainly doesn't help matters) I was surprised at how well Zope (Plone actually) comes out of it. I guess he was using Archetypes to do the heavy lifting - I've found plone to have a *very* steep learning curve. Django comes out well, with the caveat that Simon mentions re: i18N. Recommended - it's 37" long though and 300+ megabytes... Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Feed rss and xml
Err, before running off into XSL land, you might want to try a few things beforehand. Why not add some CSS to your XML feed, many newer browsers will render the XML using the CSS to give a human-readable output. I'd definitely do that before getting involved with XSL transforms (you'll likely have to call an XSLT processor programme from within your view methods - not a trivial thing to do). Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Query for "missing" information
Dunno about the ORM, but the DB API exposes raw 'selects' as well; http://www.djangoproject.com/documentation/db_api/ (under 'Other Lookup Options') Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Modify pulldown contents in admin interface
If you're using magic removal, this thread outlines a nice solution; http://groups.google.com/group/django-users/browse_frm/thread/f8dace4668c0c2b1/d9ad4190912c0bd1?q=limit_choices_to=3#d9ad4190912c0bd1 Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Advice on 'voting' system that excludes previous voters
Ok, really last post... There's a problem with my code, voter.id is not right, voter.voter_id is correct. def alreadyvoted(post, voterid): voters = post.vote_set.all() print "len(voters)", len(voters) for voter in voters: print "voter:", post, voter.id, voterid if voter.voter_id == voterid: return True return False Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Advice on 'voting' system that excludes previous voters
Replying to your own posts is so uncool ;) Here's something that works, I have no idea whether it's efficient or not - any ideas?. This code is in my views.py Essentially what's happening is that I'm adding another attribute called 'alreadyvoted' to each one of the 'posts'. This is then available in the template as post.alreadyvoted in this format, {% for post in posts %} {{post.alreadyvoted}} {% endfor %} def index(request): # get Tags and Posts tags = Tag.objects.all() posts = Post.objects.all() def alreadyvoted(post, voterid): voters = post.vote_set.all() for voter in voters: if voter.id == voterid: return True return False for post in posts: post.alreadyvoted = alreadyvoted(post, request.user.id) # as we're using a RequestContext, pretty sure that user variable is predefined. context = Context(request, {'debugMe': True, 'tags': tags, 'posts': posts, 'tagcloud':makeTagCloud(), 'request': request, 'user': request.user}) return render_to_response('electives/index', context_instance=context) Hope this helps someone, and if there's a smarter way of doing this, I'd really like to know ;) Cheers, Tone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Advice on 'voting' system that excludes previous voters
Hi all, I am working on a voting system based on a model with three classes, Post (the thing people will be voting on), Vote (the vote itself) and Person (the voter and the poster). I've put simplified version at the end of this post. To get all the posts, I use posts = Post.objects.all() in my views.py and this is passed into the template. In the template I'm basically doing this {% for post in posts %} {{post.title}} Posters:{% for poster in post.vote_set.all %} {{poster.voter}}, {{user}} {% ifequal poster.voter user %} already voted {% endifequal %} {% endfor %} {% endfor %} Which doesn't work (in that the 'already voted' text is never shown, even when I know that {{user}} has voted for a particular post). I have the feeling that I'm not doing this right from the get-go, perhaps I should be loading up the posts variable in my views.py. Does anyone have any pointers on how to do this? I've been banging my head against a wall trying to get this sorted (this was relatively easy to do in Zope). Cheers, Tone The models are here: class Person (models.Model): student = models.ForeignKey(User) nickname = models.CharField(maxlength = 20) def __repr__(self): return "%s" % self.student.__repr__() class Post(models.Model): slug = models.SlugField( 'Slug', prepopulate_from=('title',), help_text='Automatically built from the title.', primary_key='True' ) assoc_tags = models.ManyToManyField(Tag) title = models.CharField('Title', maxlength=30) postdate = models.DateTimeField('Date') image = models.ImageField( 'Attach Image', upload_to='postimgs', blank=True ) uuid = models.CharField(blank=True, maxlength=36, help_text = 'This is a unique identifier for the image for this post') # This is the uuid of the image. body = models.TextField('Body Text') poster = models.ForeignKey(Person) def __repr__(self): return self.title class Vote(models.Model): VOTE_CHOICES = ( (-1, 'down'), (0, 'neutral'), (1, 'up'), ) post = models.ForeignKey(Post) voter = models.ForeignKey(Person) value = models.IntegerField(choices = VOTE_CHOICES) votedate = models.DateTimeField('Vote date') def _post_title(self): post_title = self.post if post_title is None: return "No post title" else: post_title = post_title.title return "%s %s" % (post_title, self.value) post_title = property(_post_title) def __repr__(self): return "%s" % self.post_title --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Relationship with self with relationship data in app.py
I wish I'd known about the forward reference method a bit earlier, would have saved a lot of hair-pulling. It seems that most of my hiccups with django seem to be related to data models and accessing that data using the ORM (I'm a Zope guy, and you don't do it that way there...) Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Brain fried - need help with M2M and MR
Yes, of course - it all makes sense now after some sleep. Thanks for the hint on ipython Luke, I've had it installed for ages wth django, and it is *extremely* helpful, but I just couldn't see the wood for the trees. For the record for anyone else doing this, here's how I did it with generic views and magic removal urls.py info_dict = {'queryset': Tag.objects.select_related(), 'slug_field': 'slug', 'template_name':'electives/tag_list'} ... (r'^electives/tag/(?P[0-9A-Za-z-]+)', 'django.views.generic.list_detail.object_detail', info_dict), and electives/tag_list is (essentially); {% for post in object.post_set.all %} {{ post.title }} {% if post.image %} {% endif %} {{ post.description|truncatewords:80 }} Posted on {{ post.postdate|date:"F j, Y" }} Tags: {% for tag in post.tag_set.all %}{% if not forloop.first %}, {% endif %}{{ tag.title }}{% endfor %} {% endfor %} Thanks a lot for the help, it's much appreciated, Tone. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Brain fried - need help with M2M and MR
<2001> It's all so much clearer to me now... My headache has cleared up now, and I can see exactly what you mean Derek. It works fine now, thanks! Here's a snippet for others; urls.py (r'^electives/tag/(?P[0-9A-Za-z-]+)', 'site1.elective.views.tag'), site1.electives.views.tag def tag(request, tag): # get all posts that mention this tag thetag = Tag.objects.get(slug=tag) posts = thetag.post_set.all() context = Context(request, {'debugMe': True, 'posts': posts, 'tagcloud':makeTagCloud(), 'request': request, 'user': request.user}) return render_to_response('electives/taglist', context_instance=context) Cheers for your help, Tone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Brain fried - need help with M2M and MR
My head hurts (really, it does, I think I've given myself a headache trying to figure this out) I'm using magic-removal and have a 'simple' model for a tag-based posting system (which will turn into a voting and image uploading system). Here's the model (slightly cut down to save space); class Tag(models.Model): slug = models.SlugField( 'Slug', prepopulate_from=("title",), help_text='Automatically built from the title.', ) title = models.CharField('Title', maxlength=30) description = models.TextField( 'Description', blank = True, help_text='Short summary of this tag' ) def __repr__(self): return self.title and class Post(models.Model): slug = models.SlugField( 'Slug', prepopulate_from=('title',), help_text='Automatically built from the title.', primary_key='True' ) assoc_tags = models.ManyToManyField(Tag) title = models.CharField('Title', maxlength=30) What I want to do is get a list of posts that are related to a tag. I know it can be done because Ross Poulton has done it at http://www.rossp.org/blog/2006/feb/17/building-blog-django-3/ His setup is slightly different though, in that he's using the trunk and generic_views. I'm trying to keep using MR as "it's the future" ;) Trouble is, I just cannot get my head around the proper incantation in MR to do this... I've not done generic_views in MR yet, so if there's a HowTo or something around (example would be great), then I'll leap into that. If that's not possible, I'd just appreciate some pointers to any code that might help? Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Anyone using RazorLogix for hosting?
Hmm, I've had Zope instances that grow to 2 gigs of memory (but are mainly around the 200-300 Meg region). Most of our Apache instances have been about 2-8 Megs (php and gd installed), but I've not done work with mod_python yet, so I have no numbers there. Thanks for the info. Tone. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: mini-wiki advice
Here's something I'm using in an application - it uses the 'Textile' engine so that the person entering the markup doesn't have to worry about HTML. Works well! It's in a model, and this is all MR by the way; class Person(models.Model): ... expectations = models.TextField('Expectations body', blank=True) expectations_markup = models.TextField('Expectations body as HTML', blank=True, null=True) ... def save(self): import textile ... self.expectations_markup = textile.textile(self.expectations) ... super(Person, self).save() Also check out http://e-scribe.com/news/171 from Paul Bissex - a Wiki in 15-20 lines of python (and Django!) ;) Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: A model which is recursively referring to itself in Magic Removal
Try replacing 'Item' with 'self' - that works for me. Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: How to exclude in limit_choices_to (magic removal)
I tried __ne and (somewhat naively) __exclude and neither works. The Wiki documentation at http://code.djangoproject.com/wiki/RemovingTheMagic#Changedtemplatenamesingenericviews says that 'ne is no longer a valid lookup type' I had a look around and in the MR version of the file db/backends/mysql/base.py we have this; OPERATOR_MAPPING = { 'exact': '= %s', 'iexact': 'LIKE %s', 'contains': 'LIKE BINARY %s', 'icontains': 'LIKE %s', 'gt': '> %s', 'gte': '>= %s', 'lt': '< %s', 'lte': '<= %s', 'startswith': 'LIKE BINARY %s', 'endswith': 'LIKE BINARY %s', 'istartswith': 'LIKE %s', 'iendswith': 'LIKE %s', } Whereas in the 0.91 release (at the location core/db/backends/mysql.py) we have this; OPERATOR_MAPPING = { 'exact': '= %s', 'iexact': 'LIKE %s', 'contains': 'LIKE BINARY %s', 'icontains': 'LIKE %s', 'ne': '!= %s', 'gt': '> %s', 'gte': '>= %s', 'lt': '< %s', 'lte': '<= %s', 'startswith': 'LIKE BINARY %s', 'endswith': 'LIKE BINARY %s', 'istartswith': 'LIKE %s', 'iendswith': 'LIKE %s', } I guess you could add the line into your own MR installation, but there might be some side-effects (I did it as a test and got repeated entries - I've since edited it out) Anyone know the proper way of doing this? Cheers, Tone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Anyone using RazorLogix for hosting?
Hi all, Razorlogix, http://www.razorlogix.net/?do=features, looks quite a neat hosting service (mod_python, one slick installs for django, trac, svn, MySQL and PostGres etc.) Does anyone have any opinions on them? Thanks a lot in advance, Tone. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: limit_choices_to
Well Luke (the author) might have a better idea than me, but I'll have a go ;) Put it anywhere in your applications folder structure, Luke chose cciw/middleware because his app is called 'cciw' - but it doesn't matter because in his model file, he has the following... .. ... import cciw.middleware.threadlocals class ApplicationAdminOptions(AdminOptions): .. Now,I haven't used this mind, so no gaurantees it will work, but as Luke is one of the core django developers, there's a better than evens chance that it will ;) Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Assigning default value for field in admin
This looks like it might help, http://lukeplant.me.uk/blog.php?id=1107301634 although it's not exactly what you're after... Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Showing admin-style forms on regular user forms?
Check this out - http://groups.google.com/group/django-users/browse_frm/thread/3328829f1ed7f788/a980f983c5fc1bad It's very rushed, as I was on the way to the airport and just wanted to get the post made before I forgot it, but it does work... Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: limit_choices_to
I think that this http://lukeplant.me.uk/blog.php?id=1107301634 might be helpful. There's also been some traffic on limit_choices_to in the group recently (although not strictly relevent to your problem I think) Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Advice on developing with django for a team of 10+
Ah, that explains things, thanks for that Fredrik. I guess I'm showing my Zope roots - not too much is done on the command line with Zope ;) Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SQL Debugging and limit_choices_to in MR Branch
Way-Hay!, this works pa = models.ForeignKey("self", blank=True, null=True, limit_choices_to = {'groups__groupName__exact' : 'Administration'}) # PA for this person Now the only people who are in the popup are those who are in the group 'Administration'. Very neat ;) Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Advice on developing with django for a team of 10+
I'm still finding my feet with svn Eric ;) I don't want my .pyc files being put into the repository, and I thought a recursive svn property ignore would do the trick. I used the info from http://www.nedbatchelder.com/text/quicksvn.html, specifically; $ svn propset -R svn:ignore . -F ignore.txt where ignore.txt consists of *.pyc I must have done something wrong though ;) Your svnstatus looks quite handy, so I'll use something like that. Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django API doc
Daniel, this is terrific work!, I definitely agree with John that you should file this into trac. I can see it saving people a mountain of time! Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SQL Debugging and limit_choices_to in MR Branch
Thanks for the patch ChaosKCW, I still can't get this to work though, pa = models.ForeignKey("self", blank=True, null=True, limit_choices_to = {'groups__exact' : 'Administration'}) # PA for this person I'm now getting mesages about an m2m table not existing. What I'd like to do is something like limit_choices_to = {'WorkGroups.groupName__exact' : 'Administrator'} but that returns "Cannot resolve keyword 'WorkGroup.groupName' into field". thanks for any help, Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Help getting admin and non-admin app running in Apache
I've found that it's better to have __repr__ return a string whether our not the field is a string or not; def __repr__(self): return "%s" % self.modelField hth Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Advice on developing with django for a team of 10+
Oooh, now that's neat. My own tinkering with svn to ignore .pyc files hasn't worked out so well... % svn proplist Properties on '.': svn:ignore % svn st M magic/site1/modeltest/models.pyc hmmm... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SQL Debugging and limit_choices_to in MR Branch
I have a similar problem with limit_choices_to and MR. Within the admin interface I'd like to limit the choices for a persons 'personalAssistant' to come from a group called 'Administration'. At the moment, it doesn't work, all 'Persons' are shown in the 'personalAssistant' popup, and I know I have some that have the WorkGroup 'Administration'. Here's my model: class WorkGroup(models.Model): groupName = models.CharField(maxlength=50) def __repr__(self): return "%s" % self.groupName class Person(models.Model): firstName = models.CharField(maxlength=50) lastName = models.CharField(maxlength=50) title = models.CharField(maxlength=20, blank=True) null=True) groups = models.ManyToManyField(WorkGroup, related_name = 'groups', blank=True) coordinator = models.ManyToManyField(WorkGroup, related_name = 'coordinator', blank=True) personalAssistant = models.ForeignKey("self", blank=True, null=True, limit_choices_to = {'groups_groupName' : 'Administration'}) # PA for this person But the limit_to_choices isn't limiting choices at all. Does anyone have any pointers? Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Recursive ForeignKey with blank=True
This works for me David, class Staff(models.Model): name = models.CharField(maxlength=50) reportsTo = models.ForeignKey("self", blank=True, null=True) def __repr__(self): return "%s" % self.name class Admin: list_display = ('name',) This is with the magic-removal branch, rev 2530. Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: django for sysadmin
Come on Kenneth, you can't post something like that without providing *something* like a screenshot or more details? ;) Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Advice on developing with django for a team of 10+
Our developers get involved in a lot of projects Tom - so it's almost a combinatorial explosion situation! I've been using subversion to get the latest django updates and have found it pretty approachable, so that's a big plus. We've not decided on django yet ;) there's still Zope3, TurboGears and RoR to consider, but I've been very impressed with django and to be honest, the learning curve WRT Zope3 just seems *waay* too high. RoR is a different language altogether - so that's going to be a high hurdle. Thanks for your comments! Tone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Advice on developing with django for a team of 10+
Hi, Hopefully, by this time next week we will have a dedicated server (Sunfire 4100) running django and support stuff. I'd then like to start developing new applications as soon as possible after that. I've been playing around with django on my AlPB for about 6 months now and have learnt a fair bit, but I really need some pointers for how a group would develop with django. Our background is in Zope, and virtually all the development on that platform takes place using a browser, with a relatively small amount of python scripting taking place on the server. We have quite a sophisticated Zope setup, running circa. 150 services with development servers and clustering of deployment servers, so we're no babes in the woods when it comes to web development ;) With people working with browsers, it means that people do not have the source of the site on their local machines (they may have some python scripts lying around, but the bulk of the site is held on the server). This has been handy in the past, as no one person can screw up the application (well, they can, but they have to try a bit!) We use a variety of machines to develop on, I and several others use a Mac, most people use PCs and we have some people using RH linux as their desktop. This has not mattered in the past when we've been using browsers, but with something like django, things may be different - I don't know. I see the following scenarios, and would really appreciate a heads-up if I'm way off base. 1. People ssh into the box and edit the source code directly. This is going to mean a lot of hassle re: unix permissions and over-writing of other peoples work. The editors and other tools on the server are probably going to scare some of my people off as they use GUIs - browsers - to develop with at the moment. Telling them that emacs is the one true editor (tm) is not going to cut it I'm afraid ;) This does have the advantage that the server is the only place where the source code lives. 2. People use editors on their desktop machines and sftp to the box. Same problems as #1 wrt permissions, but at least they get an editor they're happy with. Source is now distributed. 3. People run their own local django installations, and commit changes to a development server for testing before those changes are sent to the deployment server. This means each individual user machine has to have access to the databases and keeps a copy of the source on their machine. It also means a lot of django trunk duplication on each machine (I guess we could do an 'svn up' where the target is our own django installation on the server - nice thought!). We have very little experience of using svn etc however. Our people would normally work on several projects, and with option #3, we would have to have all those projects on their local machines. I don't want to ramble on here, as I'd like to know if I'm missing something really obvious already! So, if anyone is doing something like this, I'm all ears! Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: magic-removal: from django.parts.media.photos import get_thumbnail_url
Jeremy, You might want to raise a ticket on this so the development team will know about it. Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Changing filenames on an upload...
Ahhh... Should have said I was using magic-removal, and that this is within the admin interface. The reason for the uuid filename is because I'm thinking of having a lot of files uploaded and I could end up with dozens of files called 'TEST.DOC' and this is one way of guaranteeing that the filename will be unique within that directory. It's based on some Zope code that works very well. We basically add the filename onto the end of the uuid and get something like cetl/3C644E61-E4EF-451E-BF03-804D9A7692D5/presentation.ppt. The file is actually stored in the filesystem using the uuid - we squirt it out as a binary stream having first set it's mimetype. Having the filename tacked on the end helps browsers to figure out what the file is and act accordingly. If Django is always going to save the file using the uploaded file name, I might have to skip uploading files using the admin interface. I should say that I do have an application where all this uuid stuff is working just fine with standard file uploads (although I've not ported that to magic removal...) Thanks for the help though Malcolm, you've saved me quite a bit of effort in digging around! Cheers, Tone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Changing filenames on an upload...
Hi all, I have this model class Photo(models.Model): name = models.CharField(maxlength=20) image = models.ImageField(upload_to="cetl/") def save(self): import commands self.image = 'cetl/%s' % commands.getoutput("uuidgen") super(Photo, self).save() def __repr__(self): return '' % self.image class Admin: list_display = ('name', 'image',) As I want the filename to be unique within the directory. Thing is the save() method is not doing what I thought it would! What gets saved into the directory is this; cetl/image1.jpg What gets saved into the database is this; | id | name | image | ++--+---+ | 11 | database | cetl/3C644E61-E4EF-451E-BF03-804D9A7692D5 | ++--+---+ So where am I going wrong? ;) Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: table needs all fields filled in?
Hi, blank=True should allow you to submit a partially-filled form, but you have a lot of core=True fields in there as well, perhaps you have too many? From the Model Reference documentation http://www.djangoproject.com/documentation/model_api/; core For objects that are edited inline to a related object. In the Django admin, if all "core" fields in an inline-edited object are cleared, the object will be deleted. It is an error to have an inline-editable relation without at least one core=True field. Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django filter hack
This is very nice - very helpful! Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: weird learning thingie
I see a lot of thumbnails on the page (looks like a terrific place too!), click on one of them and get a full sized image. I'm using Safari 2.0.3 - ok (also works in Shiira 1.2.1) however Firefox 1.5.0.1 and Camino 1.0 - behaviour you describe Hmm, could be a browser problem? hth Cheers, Tone --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: caching questions
Have you seen this Fredrik? http://djangoutils.python-hosting.com/wiki/Utils --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: date time errors: please explain?
I'm pretty sure that fields defined as DateTimeField in your model are converted to python datetime objects when read from the database. That means you can use all the datetime methods on it, like datetime.timedelta for example. Check out http://groups.google.com/group/django-users/browse_frm/thread/8d10d2ca33e18e00/9c747b0894d22fda?q=timedelta=1#9c747b0894d22fda for more details. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Request for ideas
Authentication. There's some documentation, and it's pretty good. Having more won't hurt though and will definitely help the people considering migrating to django with their decisions. I'd suggest external (ie different to the settings.py 'django' database) MySQL/Postgres databases, LDAP and (if you feel up to it!) Shibboleth. Cheers, Tone
Re: Paginator Documentation
I got to a similar state, but I couldn't figure out what the template should look like! (dumb, I know). Do you have an example you can post? I'm trying to implement parts of the admin system into my own apps, and the paginator is a core part of that (looking at migrating from Zope, and the 'batch' stuff there is quite neat), so this would be a real help! Cheers, Tone
Re: You want some of that 'adminy' goodness in your own apps?
Hadn't thought of that Brian, I'll have a go at putting something a bit more sensible into the Wiki (I was in a hurry to go to a meeting and wanted to get the content online somewhere before it left me completely!). Come to think of it, I may try diffing against the original docs and submitting it as a ticket (first attempt at that though...) Cheers, Tone
You want some of that 'adminy' goodness in your own apps?
Here's what I've found... Start with the very useful tutorial at http://www.djangoproject.com/documentation/forms/ - in general it's very helpful, but there are some small gaps in the documentation, which would certainly have helped me #1: I'd emphasize that this document (http://www.djangoproject.com/documentation/forms/), will help djangonauts get a lot of the adminy goodness into their own apps. Big win to the django team. #2: The date and time javascript widgets are what I wanted most of all. It would be handy if the example model included a DateTime field. Here's what I have; startdate = meta.DateTimeField(db_column='start_date') # there were too many underscores, I wanted to keep it simple!! This is represented in the form template like this; Start Date: {{ form.startdate_date }} {{ form.startdate_time }} {% if form.startdate.errors %}*** {{ form.startdate.errors|join:", " }}{% endif %} The big thing here is that the field 'startdate' is expanded out in the form, _date and _time are made available (this may have been where I went wrong, my initial attempt had {{ form.start_date }}, but I never saw any content in the form). #3: There seems to be an error in the code for loading up an edit_form. The example document has this; if request.POST: new_data = request.POST.copy() errors = manipulator.get_validation_errors(new_data) if not errors: manipulator.do_html2python(new_data) manipulator.save(new_data) # Do a post-after-redirect so that reload works, etc. return HttpResponseRedirect("/places/edit/%i/" % place.id) else: errors = {} # This makes sure the form accurate represents the fields of the place. new_data = place.__dict__ *no way* could I get this to work, I had to do this instead if request.POST: new_data = request.POST.copy() errors = manipulator.get_validation_errors(new_data) if not errors: manipulator.do_html2python(new_data) manipulator.save(new_data) # Do a post-after-redirect so that reload works, etc. return HttpResponseRedirect("/resources/edit/%i/" % resource.id) else: errors = {} # This makes sure the form accurate represents the fields of the place. #new_data = resource.__dict__ new_data = manipulator.flatten_data() Note that new_data = resource.__dict__ is replaced with new_data = manipulator.flatten_data() Ok, nearly there, but could I get the clock and calendar widgets? Nope - I used Xylescope to check on the CSS, I used alerts in the Javascript etc. etc. and then I found it was stopping on gettext... Some additional digging provided this jewel; i18n.txt in the docs. Add this; (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', {'packages': 'django.conf'}), to your urls.py for your application, make sure that your header HTML looks *something* like this; And Bob's your Uncle, Fannys your Aunt (ie the javascript widgets work). Hope this helps ;) Cheers, Tone
Re: FileField :: mx file size
Cheers Adrian, that's very handy to know.. Tone
Re: assign or rename a variable in templates
Bryan, If you can handle Zope PageTemplates, the plugin from Stefan might be useful: http://www.zope.org/Members/shh/DjangoPageTemplates That allows for variable creation, but of course you don't get the django templates... Cheers, Tone
Re: FileField :: mx file size
Amit, I think that's more a progress 'barber pole' widget than something which will detect the length of a file and drop the connection if it's over a certain size (although it's hard to tell...) Cheers, Tone
Re: image field update impossible.
Ah I see. Sorry, but I've not used ImageFields yet, so I don't think I can help in that instance... Cheers, Tone
Re: effbot using django...
and he's looking for some help re: templates > (Update: The sample pages are now generated by a django application, directly > from > moinmoin output) > > (Update: I've fixed sidebar handling in the renderer. if anyone wants to work > on a nice > template/style to replace the current undesign, drop me a line) Cheers, Tone
Re: FileField :: mx file size
So does this happen *before* the file is uploaded - I mean when the submit button is pressed? It seems that Django will be getting information from the browser about the length of the data to be uploaded - and that's something I've always thought HTTP could not do... If so, this is *very* interesting (it's interesting anyhow, because of the validator!). Cheers, Tone
Re: image field update impossible.
I guess a validator would sort things out in this situation. However, this is a general problem - uploading files that have the same name (test.doc, figures.xls, etc.) - how do you know that its ok to overwrite the file with the same name? If it's just you uploading files, you're probably ok, but if this is to be a shared system, you'll need to be more watchful. If you're not careful, you'll end up writing a content management system. Cheers, Tone
Re: FileField :: mx file size
I didn't think you could do that - find out the size of an file to upload *before* it's uploaded, and act upon it. I've wanted to do that in CGI, Perl, PHP and Zope, and never figured out how to do it (it would have saved a few embarrasing incidents in the past; the 170 Mbyte powerpoint, the CD!! that was uploaded, etc. etc.) I'd like to see the validator you come up with Arthur! Cheers, Tone
Re: How do I get POST variables in my template
* thud! * - the sound of a rather large penny dropping. Many many thanks Adrian, it's making a *lot* more sense now (how on earth did I miss that page in the docs!) I *think* that the reason why my request.POST was coming though as empty (even when I clicked submit) is that I had no name for my submit button, ie . If I made no selections on my form (just checking), and clicked submit, I expected POST to have *something* in it, but it didn't..., and as I was doing a test of the form if request.POST: blah() then blah() wasn't being called. A real d'oh! moment. thanks again (and to the.ech0, Eric and Amit) - now onto the next hurdle! :) (I just hope I've understood the situation clearly enough) Cheers, Tone
Re: How do I get POST variables in my template
Hello again Amit, I'm trying to get the Zen of Django, by using methods I used to use in Zope ;) Essentially, I used to have statements like this sprinkled around my pages to check that form-based variables where being passed through correctly. Zope put into a namespace called 'form', but also made them available in the main namespace. The request namespace was populated with all POST and GET variables. Django presents POST as POST:, so I don't know what variables are in the POST namespace. In Zope, what I'd do is this; ... then in 'dostuff', I'd do; or more likely and get the whole namespace - actually I'd use PageTemplates, but they're more verbose than dtml ; With Django I need to know what's in the REQUEST variable and display it explicitly, eg {{ request.FILES.file.filename }} Simply doing a {{ request }} doesn't show the variables that are passed through from a form - something I used to rely on heavily in Zope-land. I guess my Django Zen level isn't high enough (yet). Cheers, Tone
Re: How do I get POST variables in my template
Thanks for the info 'the.ech0' - it seems that's what I have to do. I guess what I was after was functionality like in Zope, where the entire HTTP Request object is dumped, along with environment and other variables. GET and POST are all expanded out too. With the Zope PageTemplate code that Stefan contributed, I can get that functionality back, but only by using PageTemplates ;) It does seem to me that for something as 'busy' as POST and GET, there ought to be some functionality for inspecting what's in the object... Still on the learning curve for Django - thanks for the advice though. Cheers, Tone
Re: Upgrading models...
That's a very interesting thought Todd. I don't know enough about Ruby to follow the code properly, but the idea is pretty neat...
Re: Dreamhost - problem with Django installation
Their (DreamHost) prices are ridiculous (ie low), and to keep them low, they can only spend time on things that have an identified market (they say this in their FAQs or KnowledgeBase or whatever its called). It's the main reason they don't provide PostGres. I guess FCGI for Django hasn't hit the big time for them... I've looked at Dreamhost (cheap, ridiculous storage and bandwidth, very much mass-market driven), TextDrive (not as cheap as DreamHost, but still good, ok storage and bandwidth, PostGres and other nice bits of software - but weird usage 'no webdevelopment'), A2 (from www.43folders.com) (cheap, low storage and bandwidth, PostGres or MySQL), Zettai (more expensive, unlimited domains, PostGreSQL and/or MySQL, Zope and Plone) and Gypsy hosting (same price as Zettai - $24.95/month, full Django, Postgres, Apache2, ok storage and bandwidth - currently not taking any more signups) I've not plonked down money for any of them yet. So you pays your money and you takes your choice... ;) Cheers, Tone
Re: Retrieving choices from model->field->choices
How about creating a method in the model (untested!) def mychoices(self): return self.choices then its >>> a = Person.get_list() >>> a[0].choices() (I think) Cheers, Tone
Re: Storing News articles - retaining some HTML tags
If your articles have HTML in them, you'll need to be careful that no 'dangerous' HTML is included (javascript is the most common). A good library is stripogram - http://www.zope.org/Members/chrisw/StripOGram/readme I think you are right in that the only filter you need to worry about after that is the linebreak filter (no '()'). Cheers, Tone
Do I use @login_required to extend authentication?
I guess the title says it all - I want to use authentication methods that I'm used to from my Zope applications. This is mainly MySQL authentication, using a table consisting of; username, password, roles and domain. The authentication database is external and used by many other applications. However, I very much want to use additional authentication methods such as Shibboleth and LDAP (particularly Shibboleth). Should I use the login_required decorator from django.views.decorators.auth to do this? and if so, has anyone else done this - and have some code they can contribute? ;) Cheers, Tone