Can't do any manipulation on a db object
I'm kinda new to django, and python, so I'm probably gonna make myself look a bit stupid. Here goes anyway: As a simple django (1.0) project, (using python 2.6) I've decided to write a blog application. Here it goes: blog/urls.py -- from django.conf.urls.defaults import * urlpatterns = patterns('myblog.blog', (r'','views.listposts'), ) blog/models.py --- from django.conf.urls.defaults import * urlpatterns = patterns('myblog.blog', (r'','views.listposts'), ) blog/models.py from django.db import models from django.http import HttpResponse from tinymce.widgets import TinyMCE import re class Post(models.Model): title = models.CharField(max_length=200) content = models.TextField() pub_date = models.DateTimeField('date written',auto_now_add=True, null=True) change_date = models.DateTimeField('date changed',auto_now=True, null=True) def __unicode__(self): return self.title def save(self, force_insert=False, force_update=False): ... Here come some long lines of code I think is irrelevant, but ask me if you think they are blog/views.py --- from django.shortcuts import render_to_response as RenderToResponse from myblog.blog.models import Post def listposts(request): a = Post.objects.all() a[0].title = 'hihi' a[0].content = 'haha' print a[0].title print a[0].content return RenderToResponse('blog/showlist.html',{'postlist': a}); blog/showlist.html --- Hello {% for post in postlist.all %} {{ post.title }} {{ post.content|safe }} {% endfor %} As you may have guest, I expected the first post title to be 'hihi' and it's content to be 'haha'. Well... it's not. I still get the same post I have in my database. Yet the "print" lines give me the right post content in the server debug messages. Any ideas? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Reverse error in contrib.comments
Hi everyone, I'm using Django 1.0 and I'm attempting to add comments to a blog, following along in the "Practical Django Projects" book. The error is: Reverse for '' with arguments '()' and keyword arguments '{}' not found. when {% comment_form_target %} is present in the template. 'django.contrib.comments' has been added to settings.py (r'^comments/', include('django.contrib.comments.urls')), has been added to my main urls.py Here is my code, implemented on the entry_detail.html template for a blog, using date-based generic views: {% load comments %} {% get_comment_form for object as form %} {{ form }} I see there is an closed ticket: http://code.djangoproject.com/ticket/8571. I have cleared out all of my .pyc files as suggested, but I'm still getting the template error. Can anyone offer any advice? TIA, Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
S3Storage, Models, and Files...is this obvious?
Hi -- Again, I'm new to Django (and for that matter, Python). I am using the S3Storage module (and currently set default_storage to S3Storage). My model has a FileField which should store the file using S3 (because S3Storage is the default). I am creating an mp3 file using Popen, which is returning some "content," that is the mp3 data. Now, the question I have is how do I save the data to the model? I think I need to pass the model a File object, but I'm not sure how I get the data into a File object to pass to Model.field.save(). I don't want to have to save it twice! (And BTW, when I do an obj.save() on a model, so I have to re-get it or something, in order to retrieve the auto-increment id?) Okay, does anyone have an example of how to do this? It would be a great help!!! Liam --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Timing is everything
Hey, I'm new to Django. Be nice! Is there some simple way to time the whole Django process, request to response? PHP has something like that. I'd like to include that information in the response. Any ideas? Liam --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Error in django.contrib.comments with {% comment_form_target %}
Hi everyone, I'm using Django 1.0 and I'm attempting to add comments to a blog, following along in the "Practical Django Projects" book. The error is: Reverse for '' with arguments '()' and keyword arguments '{}' not found. when {% comment_form_target %} is present in the template. 'django.contrib.comments' has been added to settings.py (r'^comments/', include('django.contrib.comments.urls')), has been added to my main urls.py Here is my code, implemented on the entry_detail.html template for a blog, using date-based generic views: {% load comments %} {% get_comment_form for object as form %} {{ form }} I see there is an closed ticket: http://code.djangoproject.com/ticket/8571. I have cleared out all of my .pyc files as suggested, but I'm still getting the template error. Can anyone offer any advice? TIA, Brandon The form will render if I remove {% comment_form_target % --~--~-~--~~~---~--~~ 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.site.register errors (due to user mistake)
On Tue, 2008-10-21 at 19:51 -0700, [EMAIL PROTECTED] wrote: > If you make a boneheaded move such as creating a ModelAdmin class for > a model that you forgot to include in your admin.py's model import > statement, you get an error. But it's not the error you might expect. > What happens is you get the "model already registered exception", > citing the first model registered using admin.site.register(). That's kind of impressive. And not particularly helpful. Open a ticket so we remember to fix it. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
admin.site.register errors (due to user mistake)
If you make a boneheaded move such as creating a ModelAdmin class for a model that you forgot to include in your admin.py's model import statement, you get an error. But it's not the error you might expect. What happens is you get the "model already registered exception", citing the first model registered using admin.site.register(). I spent awhile looking around my app trying to see if I had indeed registered the model in question more than once via imports, but couldn't find it. When I fixed my error in the import statement, everything was fine. So definitely user error. But the error message Django displayed didn't help guide me to the problem. Worthy of a ticket or no? Derek Willis [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: Import error exception "No module named urls" when running from eclipse
Thanks for your help, It turns out that it was a problem to do with the renaming functionality not working properly in eclipse. I tried renaming my package - and that doesn't work for some reason, and then my hack around caused a problem when I created a new package, which ultimately stuffed up which package eclipse was looking in when launching the app. Is it *normal* for rename to not work properly for the packages in eclipse using pydev? My solution to this was to create a new project, with the package name I wanted, and to import the code I was previously using. If it's just my version, then I should probably find out why my version doesn't support rename. Louis On Oct 22, 2:03 pm, Jeff Anderson <[EMAIL PROTECTED]> wrote: > DragonSlayre wrote: > > Hi, I'm new to django/python, and I'm testing out eclipse for > > development. > > > I'm using pydev, and managed to run my app, but then when I go to the > > web page, I get: > > > ImportError at /time/ > > No module named urls > > You'll need to include the code for the view that is being called, and > possibly your urls.py > Do you have a urls.py in your project? > > Jeff Anderson > > signature.asc > < 1KViewDownload --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: callable upload_to problem
On Tue, Oct 21, 2008 at 7:42 PM, Brot <[EMAIL PROTECTED]> wrote: > > Is there nobody who can help me with my problem? Is this a bug and > should I open a ticket or is it my fault? > > It's either a bug or behavior that needs more explicit documentation. The problem is that upload_to is called when the field is saved (that is when the form data is copied to the new/changed model instance), and the model is saved field-by-field in (apparently, excepting for id which comes first) the order they are declared in the model. So, since your ImageField is declared before desc, desc has not yet been set in the model instance when upload_to is called. If you switch the order of the fields in the model your upload_to will be able to access the desc that has been entered in the form. I tend to think it's a bug and file-type fields should be saved after non-file fields, since the doc here: http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to only mentions the primary id field as one you cannot rely on in upload_to. But even if I'm wrong about that it deserves a ticket since either the code should be fixed or the doc should mention this behavior. Karen > On 20 Okt., 22:05, Brot <[EMAIL PROTECTED]> wrote: > > Hello, > > > > I am using the latest svn-revision 9236 and tried to use a callable in > > the upload_to parameter of the ImageField. > > > > The explanation in the django-docs for the instance-parameter of a > > callable says the following: > > > > > An instance of the model where the FileField is defined. More > specifically, this is the particular > > > instance where the current file is being attached. > > > > If I understand this right, I have access to all the input data of > > this instance. If I have the following models.py > > > - > > 01: from django.db import models > > 02: > > 03: def get_storage_path(instance, filename): > > 04:""" defines the storage path for the photologue app """ > > 05:import os.path > > 06:print "instance: %s" % (instance) > > 07:print "desc: %s" % (instance.desc) > > 08:return os.path.join('uploads', filename) > > 09: > > 10: class ImageModel(models.Model): > > 11:image = models.ImageField('image', upload_to=get_storage_path) > > 12: desc = models.CharField(max_length=100) > > 13: > > 14:def __unicode__(self): > > 15:return u'%s - %s' % (self.image, self.desc) > > > - > > the print statement in line 7 should print all the data I inserted > > into this variable in the admin. Is that right? In my case this is > > always a empty string: > > > > > - > > [20/Oct/2008 21:52:47] "GET /admin/hp/imagemodel/add/ HTTP/1.1" 200 > > 2822 > > [20/Oct/2008 21:52:47] "GET /admin/jsi18n/ HTTP/1.1" 200 1915 > > instance: - > > desc: > > [20/Oct/2008 21:52:54] "POST /admin/hp/imagemodel/add/ HTTP/1.1" 302 0 > > [20/Oct/2008 21:52:54] "GET /admin/hp/imagemodel/ HTTP/1.1" 200 1866 > > > - > > > > Are there any suggestions? > > > > ~Bernd > > > --~--~-~--~~~---~--~~ 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: Import error exception "No module named urls" when running from eclipse
DragonSlayre wrote: > Hi, I'm new to django/python, and I'm testing out eclipse for > development. > > I'm using pydev, and managed to run my app, but then when I go to the > web page, I get: > > ImportError at /time/ > No module named urls > You'll need to include the code for the view that is being called, and possibly your urls.py Do you have a urls.py in your project? Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Django on Apache (mod_python) administration cookie problem
On Oct 22, 10:52 am, "M.Ganesh" <[EMAIL PROTECTED]> wrote: > Hi Daniel, > > I am also facing the same problem. I really can't understand the > technicalities of the solution offered in this thread. Since you seemed > to have solved the problem, can you please give a little more details on > how to do it Disabling the PHP mhash module is only a workaround even if it does work. The proper fix if it is this issue is to refresh your Python 2.4 installation to get fixed version from Debian repository, or even perhaps upgrade to Python 2.5 and newer mod_python version which uses Python 2.5. Alternatively, disable PHP from Apache completely if you do not need it. Which of the three options don't you understand and are wanting more detail for? Graham > Thanks in advance > > Regards Ganesh > > Daniel bodom_lx Graziotin wrote: > > Thank you very much for your replies, Alvaro and Graham! > > Removing php5-mhash solved the problem --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Import error exception "No module named urls" when running from eclipse
Hi, I'm new to django/python, and I'm testing out eclipse for development. I'm using pydev, and managed to run my app, but then when I go to the web page, I get: ImportError at /time/ No module named urls Request Method: GET Request URL:http://localhost:8080/time/ Exception Type: ImportError Exception Value: No module named urls Exception Location: C:\python25\lib\site-packages\django\core \urlresolvers.py in _get_urlconf_module, line 197 Python Executable: C:\Python25\python.exe Python Version: 2.5.2 I'm guessing that I probably need to include a library in eclipse or something like that - any ideas??? --~--~-~--~~~---~--~~ 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: Feature like "acts_as" in Django ORM or contrib ?
Also you may want to look at this one... Seems pretty good as well (haven't used it personally though). http://www.djangosnippets.org/snippets/884/ On Oct 21, 1:20 pm, ro60 <[EMAIL PROTECTED]> wrote: > I've been working on an acts_as_list implementation for Django > recently. I know gasp... I will prob be strung up by my toes for it. > > I work with Rails and Django both and like the way that the acts as > list stuff works in Rails. The code is untested and there are some > gaps that still need to be filled in (It's def not production ready > yet) but this may help as a starting point. I plan to do some testing > over the next couple of days and to flush out the obvious problems. > It's not 100% the same but there are allot of functions in there that > you will find familiar if you've worked with the Rails version. Would > love any contributions or feedback if you have them. > > http://code.google.com/p/django-acts-as-list/ > > Also you may want to check out the positional snippet. I used that as > a starting point for my code. It may suffice for what you want to do > and is def more flushed out. > > http://www.djangosnippets.org/snippets/259/ > > On Oct 21, 3:13 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > On 21 oct, 08:37, Daniel Roseman <[EMAIL PROTECTED]> > > wrote: > > > >acts_asis a Ruby design pattern rather than a Python one. However, > > > for the specific higher/lower functionality, look into > > > django-mptt:http://code.google.com/p/django-mptt/ > > > Very good. > > > Do you know something to do : > > > * ordered list > > * versionning > > > ? --~--~-~--~~~---~--~~ 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 on Apache (mod_python) administration cookie problem
Hi Daniel, I am also facing the same problem. I really can't understand the technicalities of the solution offered in this thread. Since you seemed to have solved the problem, can you please give a little more details on how to do it Thanks in advance Regards Ganesh Daniel bodom_lx Graziotin wrote: > Thank you very much for your replies, Alvaro and Graham! > Removing php5-mhash solved the problem > > > > --~--~-~--~~~---~--~~ 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: callable upload_to problem
Is there nobody who can help me with my problem? Is this a bug and should I open a ticket or is it my fault? ~Bernd On 20 Okt., 22:05, Brot <[EMAIL PROTECTED]> wrote: > Hello, > > I am using the latest svn-revision 9236 and tried to use a callable in > the upload_to parameter of the ImageField. > > The explanation in the django-docs for the instance-parameter of a > callable says the following: > > > An instance of the model where the FileField is defined. More specifically, > > this is the particular > > instance where the current file is being attached. > > If I understand this right, I have access to all the input data of > this instance. If I have the following models.py > - > 01: from django.db import models > 02: > 03: def get_storage_path(instance, filename): > 04: """ defines the storage path for the photologue app """ > 05: import os.path > 06: print "instance: %s" % (instance) > 07: print "desc: %s" % (instance.desc) > 08: return os.path.join('uploads', filename) > 09: > 10: class ImageModel(models.Model): > 11: image = models.ImageField('image', upload_to=get_storage_path) > 12: desc = models.CharField(max_length=100) > 13: > 14: def __unicode__(self): > 15: return u'%s - %s' % (self.image, self.desc) > - > the print statement in line 7 should print all the data I inserted > into this variable in the admin. Is that right? In my case this is > always a empty string: > > - > [20/Oct/2008 21:52:47] "GET /admin/hp/imagemodel/add/ HTTP/1.1" 200 > 2822 > [20/Oct/2008 21:52:47] "GET /admin/jsi18n/ HTTP/1.1" 200 1915 > instance: - > desc: > [20/Oct/2008 21:52:54] "POST /admin/hp/imagemodel/add/ HTTP/1.1" 302 0 > [20/Oct/2008 21:52:54] "GET /admin/hp/imagemodel/ HTTP/1.1" 200 1866 > - > > Are there any suggestions? > > ~Bernd --~--~-~--~~~---~--~~ 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: Python on Windows re-using old .pyc files?
On Oct 21, 10:51 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote: > Ulf Kronman schrieb:> I'm using Django trunk and I have set the > MaxRequestsPerChild 1 > > directive in httpd.conf. I'm running on Windows XP (sp3?). > > Here a guess: > > Apache creates several threads (or worker processes) and after one > request the thread/process gets killed. But the other are still alive and > have the old code loaded. On Windows there is only one Apache worker process containing many threads. Thus, the problem of a request going to another process with older code loaded shouldn't be an issue. Even on UNIX that shouldn't be an issue with MaxRequestsPerChild set to 1 unless specific effort was put into to preload Django code at process startup using PythonImport directive. I did have a think about OP issue, but off the top of my head I couldn't work out why they would see the behaviour they were seeing unless Apache is a bit loose with its counting, or it is an oddity of how a restart of Apache worker process on Windows works. > Maybe you could trymod_wsgi. It is much more flexible. On Windows, unlikely that mod_wsgi would make a difference as it only provides embedded mode on Windows and so behaviour not much different to mod_python. > See "Time to deprecate mod_python": > > http://groups.google.com/group/modwsgi/browse_thread/thread/95c5de2b9... Hmmm, I can see the subject line of that post coming back to haunt me. :-( I wasn't saying mod_python itself should be deprecated, but that the hacks in mod_wsgi to get it to work in same process as mod_python should be dropped. This would've meant that they couldn't be used together, but would free up mod_wsgi to manage better how Python is used and eliminate some shortcomings it has with being forced to do things the mod_python way to cooperate with it. Graham Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Difficulty getting Django working with Apache and mod_python
On Oct 22, 2:23 am, projecktzero <[EMAIL PROTECTED]> wrote: > On Oct 20, 4:17 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > > > > > On Mon, Oct 20, 2008 at 5:15 PM, projecktzero <[EMAIL PROTECTED]>wrote: > > > I'm pretty new to Django. I'm having trouble getting my Django > > > app/web-site to run under Apache2 and Mod_Python. I'm running Django > > > 0.96. I installed Apache2 and Mod_Python and tested both, and they > > > seem to work properly. > > > > In my http.conf, I have the following: > > > > > > > Python Path "['/usr/local/apache2/htdocs/hwsw2','/usr/lib/ > > > python2.3/site-packages/django'] + sys.path" > > > SetHandler python-program > > > PythonHandler django.core.handlers.modpython > > > SetEnv DJANGO_SETTINGS_MODULE hwsw2.settings > > > PythonDebug On > > > > > > > The file permissions appear to be correct.(apache owns the .py files > > > and they are executable, the .html templates are all ready-only for > > > the world.) > > > > Unfortunately, I get the following error: > > > > EnvironmentError: Could not import settings 'hwsw2.settings' (Is it on > > > sys.path? Does it have syntax errors?): No module named hwsw2.settings > > > > Does anyone have any ideas on what I did to mis-configure this? > > > First, you've got a space in the PythonPath setting in your Location > > directive. Every example I've seen has no space there so I don't think a > > space is allowed (though I did not actually verify that a space breaks > > things). > > > Second you've specified 'hwsw2' in both the PythonPath and the SetEnv for > > the settings module, so the file names that will be searched for are > > /usr/local/apache2/htdocs/hwsw2/hwsw2/settings.py, etc. If you are going to > > specify the settings module as hwsw2.settings then > > '/usr/local/apache2/htdocs', without the trailing hwsw2, needs to be on your > > python path. Whether you need both directories on the path depends on how > > you import things in your code. If you always specify hwsw2 in your imports > > than you don't need to have it be specified explicitly in the python path, > > just its parent. > > > Third you don't need to specify anything under site-packages (site-packages > > is automatically searched) in the PythonPath, so you should remove > > '/usr/lib/python2.3/site-packages/django' from the PythonPath setting. > > > Karen > > Thanks Karen > > I had caught the PythonPath issue after sending the post. Here's what > worked: > > > PythonPath "['/usr/local/apache2/htdocs'] + sys.path" > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE hwsw2.settings > PythonDebug On > It is bad practice to put Django source code under Apache document root (htdocs). If you do this and Apache gets misconfigured, you can expose all your source code to the world, including any sensitive information in it like database passwords. Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Getting latest ManyToMany related model
Nevermind, I think I figured it out. On Oct 21, 3:13 pm, Charlie Gunyon <[EMAIL PROTECTED]> wrote: > Hey everyone. Is there a way to get the latest ManyToMany related > model? My models.py looks like this: > > class Conference(models.Model): > name = models.CharField(max_length=30, unique=True) > > class Team(models.Model): > name = models.CharField(max_length=30, unique=True) > conferences = models.ManyToManyField('Conference', > related_name='teams', through='ConferenceMembership') > > def _get_current_conference(self): > return self.conferences.latest() > > conference = property(_get_current_conference) > > class Player(models.Model): > name = models.CharField(max_length=15, unique=True) > teams = models.ManyToManyField('Team', related_name='players', > through='TeamMembership') > > def _get_current_team(self): > return self.teams.latest() > > team = property(_get_current_team) > > class ConferenceMembership(models.Model): > conference = models.ForeignKey('Conference') > team = models.ForeignKey('Team') > date_joined = models.DateField(auto_now_add=True) > > class Meta: > get_latest_by = 'date_joined' > > class TeamMembership(models.Model): > team = models.ForeignKey('Team') > player = models.ForeignKey('Player') > date_joined = models.DateField(auto_now_add=True) > > class Meta: > get_latest_by = 'date_joined' > > This is important because Teams can change Conferences, and Players > can change Teams, but their stats while on those Teams/Conferences > have to remain under those Teams/Conferences. > > When I try and create a Team in the Admin section, the following happy > error comes up: > > Exception Type: TemplateSyntaxError > Exception Value: Caught an exception while rendering: latest() > requires either a field_name parameter or 'get_latest_by' in the model > > So I think, "Oh, I need to move those 'get_latest_by' declarations > into the top-level classes". So I change my models to look like this: > > class Conference(models.Model): > name = models.CharField(max_length=30, unique=True) > > class Meta: > get_latest_by = 'date_joined' > > class Team(models.Model): > name = models.CharField(max_length=30, unique=True) > conferences = models.ManyToManyField('Conference', > related_name='teams', through='ConferenceMembership') > > class Meta: > get_latest_by = 'date_joined' > > def _get_current_conference(self): > return self.conferences.latest() > > conference = property(_get_current_conference) > > class Player(models.Model): > name = models.CharField(max_length=15, unique=True) > teams = models.ManyToManyField('Team', related_name='players', > through='TeamMembership') > > class Meta: > get_latest_by = 'date_joined' > > def _get_current_team(self): > return self.teams.latest() > > team = property(_get_current_team) > > class ConferenceMembership(models.Model): > conference = models.ForeignKey('Conference') > team = models.ForeignKey('Team') > date_joined = models.DateField(auto_now_add=True) > > class TeamMembership(models.Model): > team = models.ForeignKey('Team') > player = models.ForeignKey('Player') > date_joined = models.DateField(auto_now_add=True) > > But when trying to add another team, I get a different error: > > Exception Type: TemplateSyntaxError > Exception Value: Cannot resolve keyword 'date_joined' into field. > Choices are: _order, conferencemembership, conferences, name, teams > > So I then try to access class attributes: > > class Conference(models.Model): > name = models.CharField(max_length=30, unique=True) > > class Meta: > get_latest_by = 'date_joined' > > class Team(models.Model): > name = models.CharField(max_length=30, unique=True) > conferences = models.ManyToManyField('Conference', > related_name='teams', through='ConferenceMembership') > > class Meta: > get_latest_by = 'conferencemembership.date_joined' > > def _get_current_conference(self): > return self.conferences.latest() > > conference = property(_get_current_conference) > > class Player(models.Model): > name = models.CharField(max_length=15, unique=True) > teams = models.ManyToManyField('Team', related_name='players', > through='TeamMembership') > > def _get_current_team(self): > return self.teams.latest() > > team = property(_get_current_team) > > class ConferenceMembership(models.Model): > conference = models.ForeignKey('Conference') > team = models.ForeignKey('Team') > date_joined = models.DateField(auto_now_add=True) > > class TeamMembership(models.Model): > team = models.ForeignKey('Team') > player = models.ForeignKey('Player') > date_joined = models.DateField(auto_now_add=True) > > But I still get an error: > > Exception Type: TemplateSyntaxError > Exception
Re: what is the status of inline unique_together non-fatal error messages?
On Tue, Oct 21, 2008 at 2:35 PM, bobhaugen <[EMAIL PROTECTED]> wrote: > > On Oct 21, 12:34 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > > Well then the next step I would try is testing out the current patch for > > general model validation, which is ticket #6845: > > > > http://code.djangoproject.com/ticket/6845 > > > > Status on this was most recently reported here, I think: > > > > http://groups.google.com/group/django-developers/browse_thread/thread... > > That status message says: > > known Issues > > = > > > > * InlineFormSet.save_as_new is broken > > I do see a change in the last patch > http://code.djangoproject.com/attachment/ticket/6845/6845-against-9226.diff > for BaseGenericInlineFormSet, to preserve the parent foreign key for > validation. > But I don't think that's what Admin uses. > I don't know -- this isn't a case I've looked at, and I haven't tried that patch myself yet. One other ticket I just noticed that you might want to keep an eye on is: http://code.djangoproject.com/ticket/8882 That may be the exact case you are concerned with and it may get fixed sooner than overall model validation gets into the code, but I'm just guessing, since I'm not actually working on either of them myself. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: File upload progress bar for Django?
On Oct 20, 2008, at 12:22 PM, M Godshall wrote: > Is anyone familiar with a django or python tutorial that shows how > to implement > some kind of file upload progress bar? Ideally I'd like to use > jquery, but I'm open to anything at this point. Any links or code > examples would be greatly appreciated. I couldn't find any tutorials, but it's come up on this list before: http://groups.google.com/group/django-users/search?group=django-users=progress+bar And there are a couple of good examples on djangosnippets.org: http://djangosnippets.org/snippets/678 http://djangosnippets.org/snippets/679 Unfortunately they're not accessible at the moment. Since it keeps coming up, I put together a demo app showing how the pieces fit together. It also shows how you could use nginx and its mod_uploadprogress instead, to avoid tying up your Django processes with slow uploads. http://www.fairviewcomputing.com/blog/2008/10/21/ajax-upload-progress-bars-jquery-django-nginx/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Permissions in template tags
Simple question: is it possible to access all user permissions in template tags just as in regular templates through the {{ perms }} context variable or do I need to manually pass the permissions are template tag params? By default the perms map does not seem to work in tags. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Getting latest ManyToMany related model
Hey everyone. Is there a way to get the latest ManyToMany related model? My models.py looks like this: class Conference(models.Model): name = models.CharField(max_length=30, unique=True) class Team(models.Model): name = models.CharField(max_length=30, unique=True) conferences = models.ManyToManyField('Conference', related_name='teams', through='ConferenceMembership') def _get_current_conference(self): return self.conferences.latest() conference = property(_get_current_conference) class Player(models.Model): name = models.CharField(max_length=15, unique=True) teams = models.ManyToManyField('Team', related_name='players', through='TeamMembership') def _get_current_team(self): return self.teams.latest() team = property(_get_current_team) class ConferenceMembership(models.Model): conference = models.ForeignKey('Conference') team = models.ForeignKey('Team') date_joined = models.DateField(auto_now_add=True) class Meta: get_latest_by = 'date_joined' class TeamMembership(models.Model): team = models.ForeignKey('Team') player = models.ForeignKey('Player') date_joined = models.DateField(auto_now_add=True) class Meta: get_latest_by = 'date_joined' This is important because Teams can change Conferences, and Players can change Teams, but their stats while on those Teams/Conferences have to remain under those Teams/Conferences. When I try and create a Team in the Admin section, the following happy error comes up: Exception Type: TemplateSyntaxError Exception Value:Caught an exception while rendering: latest() requires either a field_name parameter or 'get_latest_by' in the model So I think, "Oh, I need to move those 'get_latest_by' declarations into the top-level classes". So I change my models to look like this: class Conference(models.Model): name = models.CharField(max_length=30, unique=True) class Meta: get_latest_by = 'date_joined' class Team(models.Model): name = models.CharField(max_length=30, unique=True) conferences = models.ManyToManyField('Conference', related_name='teams', through='ConferenceMembership') class Meta: get_latest_by = 'date_joined' def _get_current_conference(self): return self.conferences.latest() conference = property(_get_current_conference) class Player(models.Model): name = models.CharField(max_length=15, unique=True) teams = models.ManyToManyField('Team', related_name='players', through='TeamMembership') class Meta: get_latest_by = 'date_joined' def _get_current_team(self): return self.teams.latest() team = property(_get_current_team) class ConferenceMembership(models.Model): conference = models.ForeignKey('Conference') team = models.ForeignKey('Team') date_joined = models.DateField(auto_now_add=True) class TeamMembership(models.Model): team = models.ForeignKey('Team') player = models.ForeignKey('Player') date_joined = models.DateField(auto_now_add=True) But when trying to add another team, I get a different error: Exception Type: TemplateSyntaxError Exception Value:Cannot resolve keyword 'date_joined' into field. Choices are: _order, conferencemembership, conferences, name, teams So I then try to access class attributes: class Conference(models.Model): name = models.CharField(max_length=30, unique=True) class Meta: get_latest_by = 'date_joined' class Team(models.Model): name = models.CharField(max_length=30, unique=True) conferences = models.ManyToManyField('Conference', related_name='teams', through='ConferenceMembership') class Meta: get_latest_by = 'conferencemembership.date_joined' def _get_current_conference(self): return self.conferences.latest() conference = property(_get_current_conference) class Player(models.Model): name = models.CharField(max_length=15, unique=True) teams = models.ManyToManyField('Team', related_name='players', through='TeamMembership') def _get_current_team(self): return self.teams.latest() team = property(_get_current_team) class ConferenceMembership(models.Model): conference = models.ForeignKey('Conference') team = models.ForeignKey('Team') date_joined = models.DateField(auto_now_add=True) class TeamMembership(models.Model): team = models.ForeignKey('Team') player = models.ForeignKey('Player') date_joined = models.DateField(auto_now_add=True) But I still get an error: Exception Type: TemplateSyntaxError Exception Value:Caught an exception while rendering: (1054, "Unknown column 'conferencemembership.date_joined' in 'order clause'") So my problem is that Conferences and Teams don't have dates to order by, but their relationships do (when a Team joined a Conference and when a Player joined a Team). I don't understand how to order those relationships to get
Named URLs for Flatpages?
Hi all, I'm working on a project that uses flatpages pretty heavily. I was wondering if there was a way to use named urls with flatpages so that I can use reverse() in my other views and {% url flat_privacy_policy %} in my templates. I haven't been able to find anything helpful in the docs so far. Any ideas? Thanks! Erik --~--~-~--~~~---~--~~ 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: Creating a system with multiple types of users
Well, django user auth has groups implemented. "It handles user accounts, groups, permissions and cookie-based user sessions." (http://docs.djangoproject.com/en/dev/topics/auth/? from=olddocs) How can you effectively separate their views. Separate your apps based on their nature, not based on who is going to be using them. Once you do that, you can lock down all of your views trivially. Now, one thing, i did'nt understand your problem in great details, BUT, it seems to me that you just want to inherit the User class and add a bunch of fields to it to get what you want done. On Oct 21, 2:39 pm, itsnotvalid <[EMAIL PROTECTED]> wrote: > I am going to help some people making a website that has a few admins, > a crowd of service providers (individuals) and customers. There could > be agents who invites people to become service providers or customers > as well. > > Looking at the user system provided by django, and as a new programmer > to django, I am not sure how can I separate different kinds of user > here. I actually want to make it look like that different people login > in different location, and do not share the same view after they > logged in. > > So I am thinking a model schema like this: > > Users (as usual) > > Providers(link to a specific user, one-to-one) > > Customers(link to a specific user, many-to-one, as one user may find > services for more that one actual person) > > Agents(link to a specific user, one-to-one) > > But how effectively can I separate their views? By defining different > apps? Any other suggestions? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Creating a system with multiple types of users
I am going to help some people making a website that has a few admins, a crowd of service providers (individuals) and customers. There could be agents who invites people to become service providers or customers as well. Looking at the user system provided by django, and as a new programmer to django, I am not sure how can I separate different kinds of user here. I actually want to make it look like that different people login in different location, and do not share the same view after they logged in. So I am thinking a model schema like this: Users (as usual) Providers(link to a specific user, one-to-one) Customers(link to a specific user, many-to-one, as one user may find services for more that one actual person) Agents(link to a specific user, one-to-one) But how effectively can I separate their views? By defining different apps? Any other suggestions? --~--~-~--~~~---~--~~ 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: File upload progress bar for Django?
There are working examples around. Basically get your server to report the upload status to a javascript ui at intervals. Try searching the djangoproject trac server - there is a link from there to a django uploader project on google code that I have used in the past. I think it uses JQuery. I'd search the the link myself to put it into this email but it's been a very long dayneed sleep. J 2008/10/21 jonknee <[EMAIL PROTECTED]> > > On Oct 20, 7:15 pm, Sascha Brossmann <[EMAIL PROTECTED]> > wrote: > > > Is anyone > > > familiar with a django or python tutorial that shows how to implement > > > some kind of file upload progress bar? > > > > Sorry, but the main magic in those uploaders is done via flash, not > > via js or php. AFAIK there is currently no sane (though you may use > > Java ;-)) way to do it otherwise. > > You can do it with some JavaScript and a server-side script written in > most languages besides PHP (though I think there is now a way with an > extension in 5.2). Perl is commonly used in the pre-made solutions as > it's typically available and involves little setup. > > Flash is most likely easier as there are lots of pre-made solutions, > but can have some session and compatibility issues (the recent Flash > 10 update messed up a *lot* of upload forms around the web). > > You could make a Django upload handler to do the progress updates, the > docs even talk about this: > > http://docs.djangoproject.com/en/dev/topics/http/file-uploads/ > > > > --~--~-~--~~~---~--~~ 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: login_required for imported apps
On 21 oct, 16:40, Heather <[EMAIL PROTECTED]> wrote: > I completely agree. Even the middleware solution doesn't seem quite > right as it will check each page/request. Well, that's the whole concept of middlewares, isn't it ?-) > I've been thinking about > this a lot and I wonder if maybe the only part that should be reusable > is the models? Nope. We've been 'reusing' quite a few django apps so far, and while there are indeed a couple spots where reusability could be improved (my own grip is with views returning full responses - often I'd need just the context and the template name), I can testify that I've rarely seen such a level of reusability in a web framework. Also a Django app doesn't have to provide any models (or views or whatever). There are some app that only provides a set of templatetags, filters and context_processors. >I don't know. But since there is no way (that I know > of) to use inheritance for apps, apps seem to be sort of limiting. I wouldn't say so. Getting at the right balance between simplicity and flexibilty is indeed a difficult task. What you can reuse from a given app depends on three factors: Django itself, how the app has been written, and how you want to reuse it. I do think that Django would benefit from a couple more hooks here and there, but this often requires some "collaboration" from the app. Something *you* (and I) can do then is to try and add this part to the apps you want to reuse and contribute it back - chances are the authors will be grateful. Same goes for Django itself FWIW (I mean, actively contributing), but since it has much greater potential impact, we just can hope to have each and any of our patches accepted - and that's mostly a GoodThing(tm), since experience has proven that EverythingButTheKitchenSink is not a sound design principle. --~--~-~--~~~---~--~~ 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: Setting up Django on CentOS5 with flup and fastcgi
I've had great luck with wsgi. http://code.djangoproject.com/wiki/django_apache_and_mod_wsgi http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango This article relates how to reverse proxy that with Nginx if you're interested (for speed, isolation): http://vizualbod.com/articles/nginx-fastcgiwsgi-django-deployment I haven't put any real load on this stuff yet but it sounds like wsgi is a champ and it's certainly been great for me so far. -Adam On Oct 21, 1:55 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > yes i have read that.. > > it seems that the .fcgi file does not read correctly. it just returns > the actual text in the fcgi file. and when i try and run a development > server you just get a timeout. > > On Oct 21, 5:05 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > > > On Tue, Oct 21, 2008 at 11:50 AM, [EMAIL PROTECTED] <[EMAIL > > PROTECTED]>wrote: > > > > Hello, > > > > I am a webhosting provider that is trying to set up django on my > > > server so that my clients can utilise it for their own programs. > > > > Although we do not allow ssh access our only ability to allow them > > > access is to use fastcgi > > > > Although i am having trouble with doing so. Is there any tutorials > > > that anyone knows of that will aid me to successfully setting up > > > django to allow for shared hosting accounts to use it. > > > > I run on CentOS 5 and have python 2.4 with django 1.0 stable. > > > I assume you have read this page: > > >http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/ > > > ? > > > Specifics of the trouble you are running into would help people provide > > guidance, without specifics it's hard to say what might be going wrong. > > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Better attack handling on Apache(wsgi)/Django servers
I'm starting a new project on Django 1.0/Pinax and I'm noticing that these silly IIS attacks that I used to see in my previous logs show up in a much more cluttered way through Apache(wsgi)/Django. Is there a best practices way to handle these types of attacks so that the attack is logged (or not) and it only takes up one line? A couple of solutions I can think of is to use Nginx or something else as a proxy? Otherwise, is there a mod_security template that is available with Django-specific rulesets? Thanks, Adam [Mon Oct 20 19:45:23 2008] [error] [client 200.162.46.91] mod_wsgi (pid=30283): Exception occurred within WSGI script '/var/www/pinax/ projects/complete_project/deploy/pinax.wsgi'. [Mon Oct 20 19:45:23 2008] [error] [client 200.162.46.91] Traceback (most recent call last): [Mon Oct 20 19:45:23 2008] [error] [client 200.162.46.91] File "/usr/ lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 239, in __call__ [Mon Oct 20 19:45:23 2008] [error] [client 200.162.46.91] response = self.get_response(request) [Mon Oct 20 19:45:23 2008] [error] [client 200.162.46.91] File "/usr/ lib/python2.5/site-packages/django/core/handlers/base.py", line 67, in get_response [Mon Oct 20 19:45:23 2008] [error] [client 200.162.46.91] response = middleware_method(request) [Mon Oct 20 19:45:23 2008] [error] [client 200.162.46.91] File "/usr/ lib/python2.5/site-packages/django/middleware/common.py", line 67, in process_request [Mon Oct 20 19:45:23 2008] [error] [client 200.162.46.91] "settings.") % (new_url[0], new_url[1]) [Mon Oct 20 19:45:23 2008] [error] [client 200.162.46.91] RuntimeError: You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 75.101.151.190/_vti_bin/_vti_aut/author.dll/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
problem testing application named "core"
When running manage.py test core, the test seem to run but no test suite is executed. but when using plain manage.py test its okay. Is this problem caused by the naming? thanks rey --~--~-~--~~~---~--~~ 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: GeoDjango - Difficulty placing vector marker from DB
There are many ways to fix the projection issue, this is one (probably not the best) On your view code: sites_list=sites_list.transform(900913) Best, Ariel. On Tue, Oct 21, 2008 at 1:57 PM, Alfonso <[EMAIL PROTECTED]> wrote: > > Hey, > > Having great trouble getting geodjango/openlayers to display vector > markers propery - everything I try positions the sample point off the > coast of Africa (no matter if I change the vector position in > geoadmin). Here's what I'm working with - any help appreciated!: > > var lon = -2.900; > var lat = 54.160; > var zoom = 6; > var map, baselayer; > var wkt_f = new OpenLayers.Format.WKT(); > var v_markers = [{% for site in sites_list > %}wkt_f.read('{{ site.point.wkt }}'){% if not forloop.last %},{% endif > %}{% endfor %}]; > var marker_style = {'strokeColor' : 'green', 'fillColor' : 'green', > 'fillOpacity' : 0.9, 'pointRadius' : 6} > for (var i = 0; i < campsite_markers.length; i++){v_markers[i].style = > marker_style;} > > function init(){ >var options = { >'projection' : new OpenLayers.Projection("EPSG:900913"), >'units': "m", >'maxResolution': 156543.0339, >'maxExtent': new > OpenLayers.Bounds(-20037508,-20037508,20037508,20037508), > 'controls':[new OpenLayers.Control.Navigation(), new > OpenLayers.Control.ZoomPanel()], >'numZoomLevels' : 20, >}; >// base map >map = new OpenLayers.Map('map', options); > >// - MS Virtual Earth Layer > baselayer = new OpenLayers.Layer.VirtualEarth("Virtual Earth", > { 'type': VEMapStyle.Street, "sphericalMercator": true}); >map.addLayer(baselayer); > >// Controls for the map > map.addControl(new OpenLayers.Control.LayerSwitcher()); > map.addControl(new OpenLayers.Control.MousePosition()); > >var layermarkers = new OpenLayers.Layer.Vector("markers"); >layermarkers.addFeatures(v_markers); > >// Vector Layers for the sites >var LonLat = new OpenLayers.LonLat(lon, lat).transform(new > OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); > >map.addLayer(layermarkers); >map.setCenter(LonLat, zoom); > > } > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
GeoDjango - Difficulty placing vector marker from DB
Hey, Having great trouble getting geodjango/openlayers to display vector markers propery - everything I try positions the sample point off the coast of Africa (no matter if I change the vector position in geoadmin). Here's what I'm working with - any help appreciated!: var lon = -2.900; var lat = 54.160; var zoom = 6; var map, baselayer; var wkt_f = new OpenLayers.Format.WKT(); var v_markers = [{% for site in sites_list %}wkt_f.read('{{ site.point.wkt }}'){% if not forloop.last %},{% endif %}{% endfor %}]; var marker_style = {'strokeColor' : 'green', 'fillColor' : 'green', 'fillOpacity' : 0.9, 'pointRadius' : 6} for (var i = 0; i < campsite_markers.length; i++){v_markers[i].style = marker_style;} function init(){ var options = { 'projection' : new OpenLayers.Projection("EPSG:900913"), 'units': "m", 'maxResolution': 156543.0339, 'maxExtent': new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508), 'controls':[new OpenLayers.Control.Navigation(), new OpenLayers.Control.ZoomPanel()], 'numZoomLevels' : 20, }; // base map map = new OpenLayers.Map('map', options); // - MS Virtual Earth Layer baselayer = new OpenLayers.Layer.VirtualEarth("Virtual Earth", { 'type': VEMapStyle.Street, "sphericalMercator": true}); map.addLayer(baselayer); // Controls for the map map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.MousePosition()); var layermarkers = new OpenLayers.Layer.Vector("markers"); layermarkers.addFeatures(v_markers); // Vector Layers for the sites var LonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); map.addLayer(layermarkers); map.setCenter(LonLat, zoom); } --~--~-~--~~~---~--~~ 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: what is the status of inline unique_together non-fatal error messages?
On Oct 21, 12:34 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > Well then the next step I would try is testing out the current patch for > general model validation, which is ticket #6845: > > http://code.djangoproject.com/ticket/6845 > > Status on this was most recently reported here, I think: > > http://groups.google.com/group/django-developers/browse_thread/thread... That status message says: > known Issues > = > > * InlineFormSet.save_as_new is broken I do see a change in the last patch http://code.djangoproject.com/attachment/ticket/6845/6845-against-9226.diff for BaseGenericInlineFormSet, to preserve the parent foreign key for validation. But I don't think that's what Admin uses. --~--~-~--~~~---~--~~ 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: Name of button pressed not in request.POST
I know this is an old thread. However, I found it when searching online when I had the same problem. I did quite a bit of other searching before I finally realized what was happening. Yes, I see the same behavior where the 'submit.x' and 'submit.y' values were in the request.POST dictionary, but there was no 'submit' key. I am not certain if this is expected behavior for either normal HTTP communication or Django, but the 'submit' (or whatever name you gave the submit button) key is not in the dictionary if the associated value in HTML is ''. In my particular case, I was doing something like this: What's relevant is the 'value'. I had forgotten to send the 'cancel_button' variable, and therefore the value was ''. This means the key does not show in the dictionary. Although I don't know expected behavior, I would personally had expected to see the 'submit' entry present in the request.POST, but the value would have been ''. It may be a bug, but without knowing expected behavior for both browsers and Django, I cannot say for certain. On Oct 4, 11:44 am, ydjango <[EMAIL PROTECTED]> wrote: > I do not see the name of submit button in request.POST. it has all > other form fields > > if request.POST.has_key('save'): > does not work too > > Where can I find which button was pressed. > > > various fields... > > other input buttons > --~--~-~--~~~---~--~~ 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: File upload progress bar for Django?
On Oct 20, 7:15 pm, Sascha Brossmann <[EMAIL PROTECTED]> wrote: > > Is anyone > > familiar with a django or python tutorial that shows how to implement > > some kind of file upload progress bar? > > Sorry, but the main magic in those uploaders is done via flash, not > via js or php. AFAIK there is currently no sane (though you may use > Java ;-)) way to do it otherwise. You can do it with some JavaScript and a server-side script written in most languages besides PHP (though I think there is now a way with an extension in 5.2). Perl is commonly used in the pre-made solutions as it's typically available and involves little setup. Flash is most likely easier as there are lots of pre-made solutions, but can have some session and compatibility issues (the recent Flash 10 update messed up a *lot* of upload forms around the web). You could make a Django upload handler to do the progress updates, the docs even talk about this: http://docs.djangoproject.com/en/dev/topics/http/file-uploads/ --~--~-~--~~~---~--~~ 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: Setting up Django on CentOS5 with flup and fastcgi
yes i have read that.. it seems that the .fcgi file does not read correctly. it just returns the actual text in the fcgi file. and when i try and run a development server you just get a timeout. On Oct 21, 5:05 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Tue, Oct 21, 2008 at 11:50 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote: > > > > > Hello, > > > I am a webhosting provider that is trying to set up django on my > > server so that my clients can utilise it for their own programs. > > > Although we do not allow ssh access our only ability to allow them > > access is to use fastcgi > > > Although i am having trouble with doing so. Is there any tutorials > > that anyone knows of that will aid me to successfully setting up > > django to allow for shared hosting accounts to use it. > > > I run on CentOS 5 and have python 2.4 with django 1.0 stable. > > I assume you have read this page: > > http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/ > > ? > > Specifics of the trouble you are running into would help people provide > guidance, without specifics it's hard to say what might be going wrong. > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: what is the status of inline unique_together non-fatal error messages?
On Tue, Oct 21, 2008 at 12:36 PM, bobhaugen <[EMAIL PROTECTED]> wrote: > > On Oct 21, 10:59 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > > Have you tried whatever scenario you are particularly interested in on > 1.0 > > or current code? > > > > Though general model validation did not make it into 1.0, checking of > unique > > and unique_together was added in changeset [8805]. It may not cover the > > inline/missing parent foreign key value case, though -- I haven't tried > > that. > > Karen, thanks for the reply. But no luck. > > Just downloaded revision 9240. > > Tried unique_together constraint in admin both plain and with a form > that overrode clean(). > Parent foreign key value is still None. Can't check unique_together. > Well then the next step I would try is testing out the current patch for general model validation, which is ticket #6845: http://code.djangoproject.com/ticket/6845 Status on this was most recently reported here, I think: http://groups.google.com/group/django-developers/browse_thread/thread/6143408977f7ad/d09c52e1fb561469 ? If the case you are interested in isn't covered by the current patch and is not called out as something that isn't handled yet in the status (which I have not read closely, so I don't know one way or the other) you might want to bring it up as an issue either in the ticket or as a response to that status note. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Updating path and filename of ImageFieldFile
This code should work with Django 1.0 : from django.db import models from PIL import Image class Photo(models.Model): related_entry_id = models.ForeignKey(MyBlogEntryModel) # Use your model object photo = models.ImageField(upload_to="my_upload_path/") # Point to your upload directory (No leading slash will point to a subfolder of your media root) def __str__(self): return "%s" % (self.photo.name) def _save_FIELD_file(self, field, filename, raw_contents, save=True): filename = "%s_%s" % (self.related_entry_id, filename) super(Photo, self)._save_FIELD_file(field, filename, raw_contents, save) def save(self, size=(800, 800)): if not self.id and not self.photo: return super(Photo, self).save() filename = self.photo.path image = Image.open(filename) image.thumbnail(size, Image.ANTIALIAS) image.save(filename) On Oct 3, 5:43 pm, "Juanjo Conti" <[EMAIL PROTECTED]> wrote: > Matt, I'd like to resize an uploaded image, while uploading i think... > before it gets saved to the hard disk. How did you do it? In pre 1.0 > version I redefined _save_FIELD_file from my class. > > Thanks, > > 2008/8/14 mcordes <[EMAIL PROTECTED]>: > > > > > > > Thanks Andy, > > > Using the callable for upload_to is pretty interesting, but I don't > > think it's usable for my purposes because I want the image file's name > > to be XXX.png where XXX is the primary key for the model which, as the > > documentation warns, may not be set when the upload_to callable gets > > called. > > > I was previously doing this in the model's save method, but as I > > mentioned after the filestorage change it's not clear how to modify > > the path of an existing ImageFieldFile > > > As for my image processing it's pretty simple and consists of: > > > 1. resize image > > 2. changing format to png > > 3. applying relatively simple transformations on the image > > 4. then saving it in a different directory with a name based on the > > model's id, something like /path/i/want/.png > > > -Matt > > > On Aug 14, 12:18 am, "Andy Lei" <[EMAIL PROTECTED]> wrote: > >> If the only post processing you need to do is changing the filename, you > >> should pass a callable (like a function) as the upload_to parameter. > >> for example: > > >> def get_upload_path(instance, filename): > >> return '/path/you/want/' + instance.name > > >> class MyModel(models.Model): > > >> image = models.ImageField(upload_to=get_upload_path) > > >> Check out the documentation here: > > >>http://www.djangoproject.com/documentation/model-api/#filefield > > >> If you need to do other post processing, I think you want to take advantage > >> of the pre / post save signals, or override save method on your model. > >> Just > >> do the post processing in place though; i can't see a reason why you'd need > >> to save it twice. > > >> -Andy > > >> On Wed, Aug 13, 2008 at 10:22 PM, mcordes <[EMAIL PROTECTED]> wrote: > > >> > Hello, > > >> > When uploading files, I'd like to upload them to a temporary location > >> > and then after post processing move them to a different directory/ > >> > file. I had this working with the pre-filestorage code, but I'm not > >> > sure what the correct procedure should now be. > > >> > My model looks like this: > > >> > > class MyModel(models.Model): > >> > > image = models.ImageField(upload_to="images/tmp") > > >> > An uploaded file would then get stored here (relative to my media > >> > root): > > >> > > images/tmp/somefile.png > > >> > I'd like to be able to modify the associated MyModel instance so its > >> > image field now has a name of > > >> > > images/processed/XXX.png > > >> > I've tried using FieldFile.save as in > > >> > > myModelInstance.image.save('new/path/new.png', File(file('path to > >> > processed image file'))) > > >> > and this mostly seems to work, but it throws out the 'new/path' part > >> > of the name argument and my image ultimately gets stored here: > > >> > > images/tmp/new.png > > >> > rather than where I want it: 'images/processed/new.png'. > > >> > What am I missing? Am I attacking this all wrong? What are your > >> > suggestions? > > >> > -Matt > > -- > Juanjo Conti --~--~-~--~~~---~--~~ 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: Feature like "acts_as" in Django ORM or contrib ?
I've been working on an acts_as_list implementation for Django recently. I know gasp... I will prob be strung up by my toes for it. I work with Rails and Django both and like the way that the acts as list stuff works in Rails. The code is untested and there are some gaps that still need to be filled in (It's def not production ready yet) but this may help as a starting point. I plan to do some testing over the next couple of days and to flush out the obvious problems. It's not 100% the same but there are allot of functions in there that you will find familiar if you've worked with the Rails version. Would love any contributions or feedback if you have them. http://code.google.com/p/django-acts-as-list/ Also you may want to check out the positional snippet. I used that as a starting point for my code. It may suffice for what you want to do and is def more flushed out. http://www.djangosnippets.org/snippets/259/ On Oct 21, 3:13 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 21 oct, 08:37, Daniel Roseman <[EMAIL PROTECTED]> > wrote: > > > > >acts_asis a Ruby design pattern rather than a Python one. However, > > for the specific higher/lower functionality, look into > > django-mptt:http://code.google.com/p/django-mptt/ > > Very good. > > Do you know something to do : > > * ordered list > * versionning > > ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Disable i18n for certain templates
Hi, I am using internationalization on my project. Recently I found out that output from date filter is not in english. The point is, that I use this to construct pubDate for my rss, like this: {{ post.date|date:"D, d M Y H:i:s" }} GMT and i18n just screws things up here. Is there any proper (not a hack) way of disabling it in this particular template? Thanks for any ideas. --~--~-~--~~~---~--~~ 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: what is the status of inline unique_together non-fatal error messages?
On Oct 21, 10:59 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > Have you tried whatever scenario you are particularly interested in on 1.0 > or current code? > > Though general model validation did not make it into 1.0, checking of unique > and unique_together was added in changeset [8805]. It may not cover the > inline/missing parent foreign key value case, though -- I haven't tried > that. Karen, thanks for the reply. But no luck. Just downloaded revision 9240. Tried unique_together constraint in admin both plain and with a form that overrode clean(). Parent foreign key value is still None. Can't check unique_together. --~--~-~--~~~---~--~~ 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: Python on Windows re-using old .pyc files?
Hi Thomas, > Apache creates several threads (or worker processes) and after one > request the thread/process gets killed. But the other are still alive and > have the old code loaded. > > Maybe you could try mod_wsgi. It is much more flexible. Thanks for the tip. It seems as this could be the cause of this peculiar behaviour. The funny thing is that I have never seen anything like this on my (older) Mac OS X or Linux installations of Apache/mod_python. I'll give mod_wsgi a try. Thanks, Ulf --~--~-~--~~~---~--~~ 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: PIL with python 2.5 on Leopard - [Solution]
Have you tried Macports? If not, you should check it out. On Oct 20, 2:11 pm, Francis <[EMAIL PROTECTED]> wrote: > I had trouble installing PIL on my Mac with 10.5 Leopard. > > I always got an : "Upload a valid image. The file you uploaded was > either not an image > or a corrupted image." > > I searched to groups for answer but it seems that others were also > having this problem. > > For those who are still looking for a solution, I found it while I was > installing erlang on my system. > > You just have to follow these procedures, the only thing I changed, > was that I used the latest labrairies and the rc1 for libpng. > > http://www.libgd.org/DOC_Compiling_GD_on_Mac_OS_X_HOWTO > > Good luck. > > Francis --~--~-~--~~~---~--~~ 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: Setting up Django on CentOS5 with flup and fastcgi
On Tue, Oct 21, 2008 at 11:50 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote: > > Hello, > > I am a webhosting provider that is trying to set up django on my > server so that my clients can utilise it for their own programs. > > Although we do not allow ssh access our only ability to allow them > access is to use fastcgi > > Although i am having trouble with doing so. Is there any tutorials > that anyone knows of that will aid me to successfully setting up > django to allow for shared hosting accounts to use it. > > I run on CentOS 5 and have python 2.4 with django 1.0 stable. > I assume you have read this page: http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/ ? Specifics of the trouble you are running into would help people provide guidance, without specifics it's hard to say what might be going wrong. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Setting up Django on CentOS5 with flup and fastcgi
Hello, I am a webhosting provider that is trying to set up django on my server so that my clients can utilise it for their own programs. Although we do not allow ssh access our only ability to allow them access is to use fastcgi Although i am having trouble with doing so. Is there any tutorials that anyone knows of that will aid me to successfully setting up django to allow for shared hosting accounts to use it. I run on CentOS 5 and have python 2.4 with django 1.0 stable. --~--~-~--~~~---~--~~ 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: what is the status of inline unique_together non-fatal error messages?
On Tue, Oct 21, 2008 at 11:39 AM, bobhaugen <[EMAIL PROTECTED]> wrote: > > I mean the normal displayable and user-correctable form validation > errors, not the fatal database IntegrityError. > > I found > http://groups.google.com/group/django-users/browse_thread/thread/f0e245366b02411b/df6d03f32eb37f93 > and > http://www.djangosnippets.org/snippets/338/ > both more than a year old. > > In the first thread, Malcom Tredinnick says it's waiting for model- > aware validation. > > The problem with overriding clean() in a form to do this is that for > inlines, the parent foreign key value is missing, so you can't check > for an existing record with the unique_together values. > > This thread in django-developers explains the problem in more detail, > but also says "'wait for model-aware validation". It's also a year > old. > > http://groups.google.com/group/django-developers/browse_thread/thread/276fae9d4132225b/90324852d4e95426 > > Any more progress, workarounds or tips? > Have you tried whatever scenario you are particularly interested in on 1.0 or current code? Though general model validation did not make it into 1.0, checking of unique and unique_together was added in changeset [8805]. It may not cover the inline/missing parent foreign key value case, though -- I haven't tried that. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Security Trimming and Roles
awesome! thanks On Oct 21, 6:20 am, "Dj Gilcrease" <[EMAIL PROTECTED]> wrote: > http://docs.djangoproject.com/en/dev/topics/auth/?from=olddocs#id6http://docs.djangoproject.com/en/dev/topics/auth/#the-permission-requ... > > might be a good place to start reading > > Dj Gilcrease > OpenRPG Developer > ~~http://www.openrpg.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: comparing from two models in the same function (view) ?
def comp(request): form = ItemForm() if request.method=="POST": form = ItemForm(request.POST, request.FILES) if form.is_valid(): if item.price >= old.price and item.pub_date <= old.pub_date item = form.save(commit=False) item.seller = request.user item.save() form = ItemForm() else: pass return render_to_response( "add_item.html", {"form": form},context_instance=RequestContext(request)) --~--~-~--~~~---~--~~ 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: MySQL to Oracle db engine
On Oct 21, 3:55 am, mbdtsmh <[EMAIL PROTECTED]> wrote: > Hi All - I'm having trouble going from using a mysql database to an > oracle database. The MySQL db settings work fine and I can validate & > syncdb my tables into the database. However, when I change my > settings.py to point to an oracle database then I get the following > error (I have cx_Oracle installed)... > > python manage.py validate > Traceback (most recent call last): [SNIP] > oracle/introspection.py", line 9, in DatabaseIntrospection > data_types_reverse = { > AttributeError: 'module' object has no attribute 'NCLOB' > > Has anyone seen this before - not much on the web. > > Thanks, > > Martin Hi Martin, What version of cx_Oracle do you have installed? As noted in the installation guide, Django requires at least version 4.3.1. -Ian --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
what is the status of inline unique_together non-fatal error messages?
I mean the normal displayable and user-correctable form validation errors, not the fatal database IntegrityError. I found http://groups.google.com/group/django-users/browse_thread/thread/f0e245366b02411b/df6d03f32eb37f93 and http://www.djangosnippets.org/snippets/338/ both more than a year old. In the first thread, Malcom Tredinnick says it's waiting for model- aware validation. The problem with overriding clean() in a form to do this is that for inlines, the parent foreign key value is missing, so you can't check for an existing record with the unique_together values. This thread in django-developers explains the problem in more detail, but also says "'wait for model-aware validation". It's also a year old. http://groups.google.com/group/django-developers/browse_thread/thread/276fae9d4132225b/90324852d4e95426 Any more progress, workarounds or tips? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
comparing from two models in the same function (view) ?
Hi, I am trying to make a view function to get the posted values and make some comparison (if x.value >= y.value).. where x is the model that I got it's values from the post and y is the other model . so if anyone know how to do that I would be grateful :) regards.. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Difficulty getting Django working with Apache and mod_python
On Oct 20, 4:17 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Mon, Oct 20, 2008 at 5:15 PM, projecktzero <[EMAIL PROTECTED]>wrote: > > I'm pretty new to Django. I'm having trouble getting my Django > > app/web-site to run under Apache2 and Mod_Python. I'm running Django > > 0.96. I installed Apache2 and Mod_Python and tested both, and they > > seem to work properly. > > > In my http.conf, I have the following: > > > > > Python Path "['/usr/local/apache2/htdocs/hwsw2','/usr/lib/ > > python2.3/site-packages/django'] + sys.path" > > SetHandler python-program > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE hwsw2.settings > > PythonDebug On > > > > > The file permissions appear to be correct.(apache owns the .py files > > and they are executable, the .html templates are all ready-only for > > the world.) > > > Unfortunately, I get the following error: > > > EnvironmentError: Could not import settings 'hwsw2.settings' (Is it on > > sys.path? Does it have syntax errors?): No module named hwsw2.settings > > > Does anyone have any ideas on what I did to mis-configure this? > > First, you've got a space in the PythonPath setting in your Location > directive. Every example I've seen has no space there so I don't think a > space is allowed (though I did not actually verify that a space breaks > things). > > Second you've specified 'hwsw2' in both the PythonPath and the SetEnv for > the settings module, so the file names that will be searched for are > /usr/local/apache2/htdocs/hwsw2/hwsw2/settings.py, etc. If you are going to > specify the settings module as hwsw2.settings then > '/usr/local/apache2/htdocs', without the trailing hwsw2, needs to be on your > python path. Whether you need both directories on the path depends on how > you import things in your code. If you always specify hwsw2 in your imports > than you don't need to have it be specified explicitly in the python path, > just its parent. > > Third you don't need to specify anything under site-packages (site-packages > is automatically searched) in the PythonPath, so you should remove > '/usr/lib/python2.3/site-packages/django' from the PythonPath setting. > > Karen Thanks Karen I had caught the PythonPath issue after sending the post. Here's what worked: PythonPath "['/usr/local/apache2/htdocs'] + sys.path" SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE hwsw2.settings PythonDebug On --~--~-~--~~~---~--~~ 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: login_required for imported apps
I completely agree. Even the middleware solution doesn't seem quite right as it will check each page/request. I've been thinking about this a lot and I wonder if maybe the only part that should be reusable is the models? I don't know. But since there is no way (that I know of) to use inheritance for apps, apps seem to be sort of limiting. On Oct 21, 4:53 am, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 20 oct, 01:33, "James Bennett" <[EMAIL PROTECTED]> wrote: > > > On Sun, Oct 19, 2008 at 2:10 PM, bruno desthuilliers > > > <[EMAIL PROTECTED]> wrote: > > > Indeed. But , OTHO, having to copy/paste a whole urls.py just to a add > > > a simple decorator on the view functions is not really DRY. > > > Personally, I don't agree; writing code to do what you want, even if > > it starts with copy/pasting someone else's code, isn't really > > "repetition". Far too often on this list, people confuse "DRY" with > > "never write any code at all". > > I don't think this last remark apply here. Of course, if what the OP > wanted was to customize the third-part app's urls on a per-url basis, > your answer would have been perfectly appropriate (and that's > certainly what I would have answered too). But the use case here is > somewhat different - it's about wrapping *all* the app's views with a > *same* decorator, without doing _any other change_ to the url's > patterns, args etc. I'm really surprised you don't see this as a > repetition... > > "I hereby retrograde you to grade 36" !-) --~--~-~--~~~---~--~~ 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: File upload progress bar for Django?
On Oct 20, 6:15 pm, Sascha Brossmann <[EMAIL PROTECTED]> wrote: > > Is anyone > > familiar with a django or python tutorial that shows how to implement > > some kind of file upload progress bar? > > Sorry, but the main magic in those uploaders is done via flash, not > via js or php. AFAIK there is currently no sane (though you may use > Java ;-)) way to do it otherwise. I also think some JavaScript libraries offer them to, like jQuery, but I have tried any of that. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ordering edit inlines in admin
does anyone know about a clean way to order edit-inlines using the admin-interface? 1. I´ve seen this and other javascript-based snippets: http://simonwillison.net/2008/Sep/13/django/ ... it´s quite simple, but it doesn´t really work. for example, if the formset isn´t valid, the order is lost. every js-solution I´ve came across is not able to deal with errors on the page ... 2. I´ve tried to use a custom formset (see code below). but even if you define can_order for a formset, you won´t get the ordering_field for the form. class OrderedInline(BaseInlineFormSet): def __init__(self, *args, **kwargs): super(OrderedInline, self).__init__(*args, **kwargs) self.can_delete = True self.can_order = True class PhotoGalleryInline(admin.StackedInline): model = PhotoGalleryItem extra = 3 formset = OrderedInline fieldsets = . 3. in my opinion, using order_with_respect_to is the right way to go, but it´s not supported by the admin-interface. if you use order_with_respect_to, can_order is still false. hope that anyone can give me a hint on this one. please note that I´m seeking a clean solution and not some kind of weird hack. thanks, patrick. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
filtering pulldowns in django admin
I realize there is probably a very simple solution for this but it has been bothering me. How do I filter a pulldown in the admin. If I have an inline form, for example, I want to be able to limit results in a pulldown to the parent object/form. Thanks for the help. Matt --~--~-~--~~~---~--~~ 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: Feature like "acts_as" in Django ORM or contrib ?
Ordering: qs = Model.objects.filter(...).order_by('ordering_field') ord_list = [el for el in qs] Versioning: code.google.com/p/django-rcsfield (There are a few others, cant remember the names offhand.) On Oct 21, 12:13 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 21 oct, 08:37, Daniel Roseman <[EMAIL PROTECTED]> > wrote: > > > > > acts_as is a Ruby design pattern rather than a Python one. However, > > for the specific higher/lower functionality, look into > > django-mptt:http://code.google.com/p/django-mptt/ > > Very good. > > Do you know something to do : > > * ordered list > * versionning > > ? --~--~-~--~~~---~--~~ 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: Query: Field of model "not defined", but existing
On Tue, Oct 21, 2008 at 6:55 AM, Micha Pietsch <[EMAIL PROTECTED]> wrote: > > Hi, > I've got a model "Note" with a DateTimeField "updated". I ran dbsync and > entered some data but making the query > "n = Note.objects.filter(owner=request.user.id > ).exclude(updated__tle=datetime.datetime.now())" > tells me that "updated" is "not defined". Without the exclude statement it > works, I also imported "datetime". > Anybody got an idea of what could be the problem? > It is a little hard to be sure because your problem description is not very precise. It is unclear if you created a model Note with a field named updated, or added a field named updated to an existing model Note. If the latter, syncdb would not do anything -- syncdb only creates tables, it does not make changes like adding/changing/removing columns. The actual error you received (including traceback) would make it clear if this was the problem, since it would show if it was the database or Django code that objected to "updated" on the grounds it was "not defined". This condensing of the actual error you see into summary form makes it hard to tell where it is really coming from, though. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: referencing the slug of parent ('self')
thanks Daniel. On Oct 21, 2:09 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Oct 21, 1:13 pm, coderb <[EMAIL PROTECTED]> wrote: > > > def category(request, myslug): > > category_list = get_list_or_404(Category, parent=myslug) > > get_list_or_404(Category, parent__slug=myslug) > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Accessing Sessions in Custom Tags
On Oct 21, 7:58 am, "Eugene A." <[EMAIL PROTECTED]> wrote: > Thanks for post, I searched this solve too long. > > But: > > I added in settings.py > TEMPLATE_CONTEXT_PROCESSORS = ( > 'django.core.context_processors.request', > ) > and it doesn't work, raises 'Failed lookup for key [request] in > u"[{'sess': 'hello', 'mods': [, all>]}]"' > So 'request' field isn't in context variable. Why? You need to pass context_instance in your render_to_response: render_to_response(template, context, context_instance=RequestContext(request)) See http://docs.djangoproject.com/en/dev/topics/http/shortcuts/ -- DR --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Security Trimming and Roles
http://docs.djangoproject.com/en/dev/topics/auth/?from=olddocs#id6 http://docs.djangoproject.com/en/dev/topics/auth/#the-permission-required-decorator might be a good place to start reading Dj Gilcrease OpenRPG Developer ~~http://www.openrpg.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
i18n translation in forms?
Hi there, I am trying to get I18N working for a website. So far the language selection, custom messages and their translation in templates using {% trans "" %} etc. works like a charm. However I can't quite figure out how to get things like the Paginator (it displays and such stuff) or field names in forms generated with the forms module. Code such as the following: class SearchForm(forms.Form): names = forms.CharField() places = forms.CharField() dates = forms.CharField() This will field display on the form with labels like "Names", "Places", "Dates" and so on, but I can't figure out how to tell the i18n framework that this should be translated. Any help appreciated! Chris --~--~-~--~~~---~--~~ 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: referencing the slug of parent ('self')
On Oct 21, 1:13 pm, coderb <[EMAIL PROTECTED]> wrote: > def category(request, myslug): > category_list = get_list_or_404(Category, parent=myslug) get_list_or_404(Category, parent__slug=myslug) -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Comments in reversed order
Is possible obtain the comments of django.contrib in reversed order? In old version: {% get_free_comment_list for workgroups.workgroup group.id as comment_list reversed %} But in new version the templatetag not have control of this parameter. The method for order is other? Regards --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Security Trimming and Roles
Loving django 1.0! But one thing I notice they don't seem to have is security trimming (where you can hide certain links based on the role permissions of a user) or any sort of roles security. Is there any solid way at going about this that already exists in the django framework or is this something we have to code up ourselves? I was thinking about it and I've come up with a few possible directions. 1) Make an inherited request object and then running a function that checks for proper permissions everytime a secure page is accessed. I've seen some places do this, but it seems pretty cumbersome and violates the DRY philosophy 2) Another idea is to edit the app.yaml to make sure login is required for a certain colleciton of pages, but what if you have multiple roles? That doesnt solve what roles can access what funcitons. And if different roles can see different things on a page, that doesn't solve that either. So security trimming is still an issue 3) Another thing I'm considering is making a custom template tag that maybe checks for security based on url. This may be pretty tough, but seems the most viable in doing security trimming at the very least. Are there any better approaches to this? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
referencing the slug of parent ('self')
hi, I know this is probably easy, but ... I have a category model: class Category(models.Model): name = models.CharField(max_length=100, unique=True) slug = models.SlugField(max_length=100, unique=True) parent= models.ForeignKey('self',blank=True,null=True) ... the view function that browses categories should return a list of sub- categories based on receiving the slug field of the parent value. however, the parent is set to the id value, not the slug. How do I associate the parent with the parents slug? my view currently looks like this: def category(request, myslug): category_list = get_list_or_404(Category, parent=myslug) return render_to_response('listings/browse.html', {'category_list': category_list}) this expects the parents id in myslug, I obviously need the parents slug. any help appreciated, thanks. (using django 1.0) --~--~-~--~~~---~--~~ 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: Python on Windows re-using old .pyc files?
Ulf Kronman schrieb: > I'm using Django trunk and I have set the MaxRequestsPerChild 1 > directive in httpd.conf. I'm running on Windows XP (sp3?). > Here a guess: Apache creates several threads (or worker processes) and after one request the thread/process gets killed. But the other are still alive and have the old code loaded. Maybe you could try mod_wsgi. It is much more flexible. See "Time to deprecate mod_python": http://groups.google.com/group/modwsgi/browse_thread/thread/95c5de2b996e2f49/fe4f823a391ad954 HTH, Thomas Güttler -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ 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: i18n all languages not displayed
Great! It works like a charm! Thank you. On Oct 21, 12:33 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote: > Wiadomość napisana w dniu 2008-10-21, o godz. 09:30, przez Jarek Zgoda: > > > > > > >> gettext = lambda s: s > > >> LANGUAGES = ( > >> ('en', gettext('English')), > >> ('ta', gettext('Tamil')), > >> ('hi-IN', gettext('Hindi')), > >> ) > > >> My folder structure on the locale is as follows > > >> locale\en\LC_MESSAGES > >> locale\hi-in\LC_MESSAGES > >> locale\ta\LC_MESSAGES > > >> Any suggestions? > > > I suppose there is no Django translation for the language you cann't > > get to work. There is "ta" translation, but not "hi". You might want > > to check this list, the translations are located in your > > / > > conf/locale directory. > > And of course, nothing should stop you from adding missing > translations and translation catalogs. :) > > -- > We read Knuth so you don't have to. - Tim Peters > > Jarek Zgoda, R, Redefine > [EMAIL PROTECTED] Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Spliting a single result from a db
HI all, I've just starting using django and am really impressed. In my simple app I want to retrieve a single "article" from a db and then display it broken into reasonable length pages (either based on word count or a specific markup in the text). I'd really appreciate any pointers on how I might try to achieve this? I think the built-in paginate seems to work on multiple objects, so I'm not sure if I can use that? thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Accessing Sessions in Custom Tags
Thanks for post, I searched this solve too long. But: I added in settings.py TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.request', ) and it doesn't work, raises 'Failed lookup for key [request] in u"[{'sess': 'hello', 'mods': [, ]}]"' So 'request' field isn't in context variable. Why? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Query: Field of model "not defined", but existing
Hi, I've got a model "Note" with a DateTimeField "updated". I ran dbsync and entered some data but making the query "n = Note.objects.filter(owner=request.user.id).exclude(updated__tle=datetime.datetime.now())" tells me that "updated" is "not defined". Without the exclude statement it works, I also imported "datetime". Anybody got an idea of what could be the problem? -- Pt! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Can't validate a datetime ...
Getting an error when i try to validate a datetime ... help ! Table "public.tarait1_teleint" Column | Type | Modifiers -+-- +-- id | integer | not null default nextval('tarait1_teleint_id_seq'::regclass) business_name | character varying(100) | not null name| character varying(100) | company_type| character varying(100) | not null meeting_date| timestamp with time zone | city| character varying(100) | not null address | text | phone | character varying(20)| not null email | character varying(75)| notes | text | technical_notes | text | entry_date | date | x_coord | numeric(12,6)| y_coord | numeric(12,6)| follow_up | boolean | call_back | timestamp with time zone | business| integer | not null default 0 # No errors if form.is_valid(): teleint = form.save(commit=False) teleint.meeting_date = request.POST.get('meeting_date','') teleint.call_back = request.POST.get('call_back','') # Teleint form class TeleIntForm(ModelForm): class Meta: model = TeleInt # Excluding these will exclude them from form saving also # You'll have to manually include them for the object exclude = ('call_back','meeting_date') ValidationError Enter a valid date/time in -MM-DD HH:MM[:ss[.uu]] format. --~--~-~--~~~---~--~~ 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: cheeserater css reference
nevermind, solved - using djangos - serving static pages - work around On Oct 18, 1:22 am, coderb <[EMAIL PROTECTED]> wrote: > forgot to mention that I did actually change the template css > references to match settings.py, but obviously still got it wrong. I'm > using django 1.0 on win XP. > > thanks > > On Oct 18, 1:16 am, coderb <[EMAIL PROTECTED]> wrote: > > > hi all, > > > I'm learning django using a downloaded copy ofcheeserater (thanks > > Jacob) > > > but am stuck at an early hurdle. > > > The template base.html has the following css references: > > http://media.jacobian.org/cheeserater/ > > reset.css" type="text/css"> > > http://media.jacobian.org/cheeserater/ > >cheeserater.css" type="text/css"> > > > I'm trying to change this template to reference the dowloaded project > > css files located in > >cheeserater/media/ > > > my attempts by changing the settings.py MEDIA_ROOT and MEDIA_URL > > values have all failed. > > > I know django docs mentions using media as a static class definition, > > but thats not the waycheeserateris defined (I think), so if anyone > > give me a quick pointer here, I'd really appreciate it. > > > thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: is it possible to run 0.96 and 1.0 in parallel?
Virtualenv - great, just what I've been looking for :-) Thanks Rachel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to save/link/rename thumbnail in model
Hello, I'd suggest you also consider this app: http://code.google.com/p/sorl-thumbnail/ . It makes it very simple to have thumbnails of various sizes associated with your image fields. -Matt On Oct 21, 2:10 am, krylatij <[EMAIL PROTECTED]> wrote: > You can define image upload path at runtime (check manual for > ImageField) > > def get_photo_path(instance, filename): > return 'static/upload_to/photos/%s' % instance.name > > class ProductImage(models.Model): > name = models.CharField(max_length=50) > file = models.ImageField(upload_to= get_photo_path) > ... > > In my projects i don't use additional field for thumbnails > Because i need thumbnails in different sizes > So i use property for that > # If i don't allready have thumbnail in this size i generate it > def _get_thumb_url(self, folder, size): > if not self.photo: > return '#' > upload_to = path.dirname(self.photo.path) > tiny = path.join(upload_to, folder, > path.basename(self.photo.path)) > tiny = path.normpath(tiny) > if not path.exists(tiny): > import Image > im = Image.open(self.photo.path) > im.thumbnail(size, Image.ANTIALIAS) > im.save(tiny, 'JPEG') > return path.join(path.dirname(self.photo.url), folder, > path.basename(self.photo.path)).replace('\\', '/') > > def get_thumb_url(self): > return self._get_thumb_url('thumb_40_40', (40,40)) > > def thumb(self): > link = self.get_thumb_url() > if link is None: > return 'NO IMAGE' > else: > return ' alt="tiny thumbnail image"/>' % (self.photo.url, link) > thumb.allow_tags = True > > So if i need thumbnail in my template i write this: > {{ my_model.thumb }} --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
MySQL to Oracle db engine
Hi All - I'm having trouble going from using a mysql database to an oracle database. The MySQL db settings work fine and I can validate & syncdb my tables into the database. However, when I change my settings.py to point to an oracle database then I get the following error (I have cx_Oracle installed)... python manage.py validate Traceback (most recent call last): File "manage.py", line 11, in ? execute_manager(settings) File "/usr/local/django-versions/Django-1.0/django/core/management/ __init__.py", line 340, in execute_manager utility.execute() File "/usr/local/django-versions/Django-1.0/django/core/management/ __init__.py", line 295, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/django-versions/Django-1.0/django/core/management/ base.py", line 77, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/local/django-versions/Django-1.0/django/core/management/ base.py", line 87, in execute translation.activate('en-us') File "/usr/local/django-versions/Django-1.0/django/utils/translation/ __init__.py", line 73, in activate return real_activate(language) File "/usr/local/django-versions/Django-1.0/django/utils/translation/ __init__.py", line 43, in delayed_loader return g['real_%s' % caller](*args, **kwargs) File "/usr/local/django-versions/Django-1.0/django/utils/translation/ trans_real.py", line 209, in activate _active[currentThread()] = translation(language) File "/usr/local/django-versions/Django-1.0/django/utils/translation/ trans_real.py", line 198, in translation default_translation = _fetch(settings.LANGUAGE_CODE) File "/usr/local/django-versions/Django-1.0/django/utils/translation/ trans_real.py", line 181, in _fetch app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), appname[p+1:]) File "/usr/local/django-versions/Django-1.0/django/contrib/admin/ __init__.py", line 1, in ? from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL File "/usr/local/django-versions/Django-1.0/django/contrib/admin/ options.py", line 5, in ? from django.contrib.contenttypes.models import ContentType File "/usr/local/django-versions/Django-1.0/django/contrib/ contenttypes/models.py", line 1, in ? from django.db import models File "/usr/local/django-versions/Django-1.0/django/db/__init__.py", line 16, in ? backend = __import__('%s%s.base' % (_import_path, settings.DATABASE_ENGINE), {}, {}, ['']) File "/usr/local/django-versions/Django-1.0/django/db/backends/ oracle/base.py", line 23, in ? from django.db.backends.oracle.introspection import DatabaseIntrospection File "/usr/local/django-versions/Django-1.0/django/db/backends/ oracle/introspection.py", line 7, in ? class DatabaseIntrospection(BaseDatabaseIntrospection): File "/usr/local/django-versions/Django-1.0/django/db/backends/ oracle/introspection.py", line 9, in DatabaseIntrospection data_types_reverse = { AttributeError: 'module' object has no attribute 'NCLOB' Has anyone seen this before - not much on the web. Thanks, Martin --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Adding a custom permission to the User model
Hi, I'm trying to specify a custom permission on the User model. I would use it to delegate control to users over certain models. I have an admin.py file where i add this: from django.contrib.auth.models import User ... class UserAdmin(admin.ModelAdmin): class Meta: permissions = ( ("create_user", "Create a user from the standard view"), ) I can't add admin.site.register(User, UserAdmin) because then i get a message that it's already registered. When i do python manage.py syncdb i don't see anything written to the db. The permission is also not visible from within the users part of the admin site. How can i add a custom permission to the standard User model? Thanks, Benedict --~--~-~--~~~---~--~~ 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: login_required for imported apps
On 20 oct, 01:33, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Sun, Oct 19, 2008 at 2:10 PM, bruno desthuilliers > > <[EMAIL PROTECTED]> wrote: > > Indeed. But , OTHO, having to copy/paste a whole urls.py just to a add > > a simple decorator on the view functions is not really DRY. > > Personally, I don't agree; writing code to do what you want, even if > it starts with copy/pasting someone else's code, isn't really > "repetition". Far too often on this list, people confuse "DRY" with > "never write any code at all". I don't think this last remark apply here. Of course, if what the OP wanted was to customize the third-part app's urls on a per-url basis, your answer would have been perfectly appropriate (and that's certainly what I would have answered too). But the use case here is somewhat different - it's about wrapping *all* the app's views with a *same* decorator, without doing _any other change_ to the url's patterns, args etc. I'm really surprised you don't see this as a repetition... "I hereby retrograde you to grade 36" !-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Authenticating static files against Django Auth with FastCGI
Hi, I am using Django on my university webspace. I set it up by following (and slightly modifying) the instructions on this page: http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache Now I would like to protect certain static files by authenticating against my Django user database; basically what's described here: http://docs.djangoproject.com/en/dev/howto/apache-auth/. Unfortunately, I do not have access to the httpd.conf. I can put .htaccess files into the directories, but that's about it. How can I get the same functionality? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: i18n all languages not displayed
Wiadomość napisana w dniu 2008-10-21, o godz. 09:30, przez Jarek Zgoda: >> gettext = lambda s: s >> >> LANGUAGES = ( >>('en', gettext('English')), >>('ta', gettext('Tamil')), >>('hi-IN', gettext('Hindi')), >> ) >> >> My folder structure on the locale is as follows >> >> locale\en\LC_MESSAGES >> locale\hi-in\LC_MESSAGES >> locale\ta\LC_MESSAGES >> >> Any suggestions? > > > > I suppose there is no Django translation for the language you cann't > get to work. There is "ta" translation, but not "hi". You might want > to check this list, the translations are located in your > / > conf/locale directory. And of course, nothing should stop you from adding missing translations and translation catalogs. :) -- We read Knuth so you don't have to. - Tim Peters Jarek Zgoda, R, Redefine [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: i18n all languages not displayed
Wiadomość napisana w dniu 2008-10-21, o godz. 07:46, przez bluefireredsky: > I am implementing an i18n for a web application. The customer requires > support for certain Indian languages such as Hindi and Tamil. I had > refered to http://www.i18nguy.com/unicode/language-identifiers.html > for identifying the respective language codes. I am not able to get it > working for Hindi, however Tamil works. Based on the above URL, the > language code for tamil should be "ta-IN" and for hindi it should be > "hi". For tamil, ta-IN does not work, but it works when i specify just > "ta". I am unable to get it to work for hindi with either "hi" or "hi- > IN". My languages in the settings.py file is as follows: > > gettext = lambda s: s > > LANGUAGES = ( > ('en', gettext('English')), > ('ta', gettext('Tamil')), > ('hi-IN', gettext('Hindi')), > ) > > My folder structure on the locale is as follows > > locale\en\LC_MESSAGES > locale\hi-in\LC_MESSAGES > locale\ta\LC_MESSAGES > > Any suggestions? I suppose there is no Django translation for the language you cann't get to work. There is "ta" translation, but not "hi". You might want to check this list, the translations are located in your / conf/locale directory. -- We read Knuth so you don't have to. - Tim Peters Jarek Zgoda, R, Redefine [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: Feature like "acts_as" in Django ORM or contrib ?
On 21 oct, 08:37, Daniel Roseman <[EMAIL PROTECTED]> wrote: > > acts_as is a Ruby design pattern rather than a Python one. However, > for the specific higher/lower functionality, look into > django-mptt:http://code.google.com/p/django-mptt/ Very good. Do you know something to do : * ordered list * versionning ? --~--~-~--~~~---~--~~ 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: Feature like "acts_as" in Django ORM or contrib ?
On Tue, Oct 21, 2008 at 12:45 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > In Elixir, when I add acts_as_list(qualifier=qualify) in Model I can > use move_higher, move_lower ... methods. Be careful about confusing multiple things here; there are applications available for Django which add features like this -- objects which behave like hierarchical lists/trees, taggable objects, etc. -- and if you like those features you should certainly go look them up. But those applications do not implement those features with precisely the same names or syntax as ActiveRecord (or Elixir, which deliberately borrows many such conventions from ActiveRecord). Which is a perfectly good thing; Django isn't Rails, isn't written in the same language and consciously tries to be idiomatic Python rather than idiomatic Ruby, so trying to simply apply a a feature from Rails using precisely the syntax Rails uses would cause it to stick out like a sore thumb in Django. -- "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: In URL dispatcher, is there a way to pass values of Named Groups directly to template?
I'm not sure what happened to my previous reply, maybe i sent it to you directly, lol.. I'm new. but i think this is what you want: http://docs.djangoproject.com/en/dev/ref/generic-views/?from=olddocs#django-views-generic-simple-direct-to-template urlpatterns = patterns('django.views.generic.simple', (r'^machine_logs/$', 'direct_to_template', {'template': 'machine_logs.html'}), (r'^machine_logs/(?P.*)/$', 'direct_to_template', {'template': 'machine_logs.html'}), ) you can access the variable in template from " {{params.unit_name}} On Oct 21, 2:12 pm, "yuanyun.ken" <[EMAIL PROTECTED]> wrote: > Hi,all great Django users and developers, I have a little problem. > In URL dispatcher, is there a way to pass values of Named Groups > directly to template, don't want to write a view function just for > this. > for example, I have the following urls: > (r'^machine_logs/$', direct_to_template, {'template': > 'machine_logs.html'}), > (r'^machine_logs/(?P.*)/$', direct_to_template, > {'template': 'machine_logs.html', 'unit_name':unit_name}), > > How can I pass the value of captured unit_name to machine_logs.html. > Thanks for any help in advance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: In URL dispatcher, is there a way to pass values of Named Groups directly to template?
Hey, I'm new to this group, but I believe you want generic views, specifically: django.views.generic.simple.direct_to_template http://docs.djangoproject.com/en/dev/ref/generic-views/?from=olddocs#django-views-generic-simple-direct-to-template which would give you something like this: urlpatterns = patterns('django.views.generic.simple', (r'^machine_logs/$', 'direct_to_template', {'template': 'machine_logs.html'}), (r'^machine_logs/(?P.*)/$', 'direct_to_template', {'template': 'machine_logs.html'}), ) ... a request to /machine_logs/ would render the template machine_logs.html, and a request to /machine_logs/machine4/ would render the foo_detail.html with a context variable {{ params.unit_name }} that is set to "machine4". On Oct 21, 2:12 pm, "yuanyun.ken" <[EMAIL PROTECTED]> wrote: > Hi,all great Django users and developers, I have a little problem. > In URL dispatcher, is there a way to pass values of Named Groups > directly to template, don't want to write a view function just for > this. > for example, I have the following urls: > (r'^machine_logs/$', direct_to_template, {'template': > 'machine_logs.html'}), > (r'^machine_logs/(?P.*)/$', direct_to_template, > {'template': 'machine_logs.html', 'unit_name':unit_name}), > > How can I pass the value of captured unit_name to machine_logs.html. > Thanks for any help in advance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
i18n all languages not displayed
Hi, I am implementing an i18n for a web application. The customer requires support for certain Indian languages such as Hindi and Tamil. I had refered to http://www.i18nguy.com/unicode/language-identifiers.html for identifying the respective language codes. I am not able to get it working for Hindi, however Tamil works. Based on the above URL, the language code for tamil should be "ta-IN" and for hindi it should be "hi". For tamil, ta-IN does not work, but it works when i specify just "ta". I am unable to get it to work for hindi with either "hi" or "hi- IN". My languages in the settings.py file is as follows: gettext = lambda s: s LANGUAGES = ( ('en', gettext('English')), ('ta', gettext('Tamil')), ('hi-IN', gettext('Hindi')), ) My folder structure on the locale is as follows locale\en\LC_MESSAGES locale\hi-in\LC_MESSAGES locale\ta\LC_MESSAGES Any suggestions? Thank you. --~--~-~--~~~---~--~~ 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: In URL dispatcher, is there a way to pass values of Named Groups directly to template?
On Oct 21, 4:12 am, "yuanyun.ken" <[EMAIL PROTECTED]> wrote: > Hi,all great Django users and developers, I have a little problem. > In URL dispatcher, is there a way to pass values of Named Groups > directly to template, don't want to write a view function just for > this. > for example, I have the following urls: > (r'^machine_logs/$', direct_to_template, {'template': > 'machine_logs.html'}), > (r'^machine_logs/(?P.*)/$', direct_to_template, > {'template': 'machine_logs.html', 'unit_name':unit_name}), > > How can I pass the value of captured unit_name to machine_logs.html. > Thanks for any help in advance. The documentation for direct_to_template explains how to do this: "Renders a given template, passing it a {{ params }} template variable, which is a dictionary of the parameters captured in the URL." http://docs.djangoproject.com/en/dev/ref/generic-views/#ref-generic-views Your URL pattern above won't work of course because unit_name is not defined as a variable at that point. -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: render_to_response failed to render media files in base.html
On Oct 21, 4:26 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Mon, Oct 20, 2008 at 9:30 PM, Chuck22 <[EMAIL PROTECTED]> wrote: > > Adding context_instance=RequestContext(request) to the method fixed > > the problem. Seems this should be done by default for > > render_to_response method. Thank you. > > It would be technically impossible to do this; render_to_response has > no knowledge of the HttpRequest object (which is required for a > RequestContext) unless you explicitly pass it as an argument. True, but there's no reason that render_to_response couldn't just take 'request' as its third parameter, using a RequestContext if it is provided, rather than the unnecessarily verbose context_instance stuff. In fact at work we have written a shortcut to do just this. -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Feature like "acts_as" in Django ORM or contrib ?
On Oct 21, 6:45 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > Are there something in Django ORM or contrib to do "acts_as" like in > RoR or Elixir (SqlAlchemy). Example : > > http://elixir.ematia.de/apidocs06/elixir.ext.htmlhttp://elixir.ematia.de/apidocs06/elixir.ext.list.html > > In Elixir, when I add acts_as_list(qualifier=qualify) in Model I can > use move_higher, move_lower ... methods. > > Do you know a Django project like this ? If isn't I can make it. > > Regards, > Stephane acts_as is a Ruby design pattern rather than a Python one. However, for the specific higher/lower functionality, look into django-mptt: http://code.google.com/p/django-mptt/ -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Returning Queryset that excludes certain results from another queryset.
Sounds like it is, will try it out soon. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to save/link/rename thumbnail in model
You can define image upload path at runtime (check manual for ImageField) def get_photo_path(instance, filename): return 'static/upload_to/photos/%s' % instance.name class ProductImage(models.Model): name = models.CharField(max_length=50) file = models.ImageField(upload_to= get_photo_path) ... In my projects i don't use additional field for thumbnails Because i need thumbnails in different sizes So i use property for that # If i don't allready have thumbnail in this size i generate it def _get_thumb_url(self, folder, size): if not self.photo: return '#' upload_to = path.dirname(self.photo.path) tiny = path.join(upload_to, folder, path.basename(self.photo.path)) tiny = path.normpath(tiny) if not path.exists(tiny): import Image im = Image.open(self.photo.path) im.thumbnail(size, Image.ANTIALIAS) im.save(tiny, 'JPEG') return path.join(path.dirname(self.photo.url), folder, path.basename(self.photo.path)).replace('\\', '/') def get_thumb_url(self): return self._get_thumb_url('thumb_40_40', (40,40)) def thumb(self): link = self.get_thumb_url() if link is None: return 'NO IMAGE' else: return '' % (self.photo.url, link) thumb.allow_tags = True So if i need thumbnail in my template i write this: {{ my_model.thumb }} --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---