Re: Using a message queue from Django to write to database asynchronously
hi, On 8 May 2010 14:44, Continuation wrote: > After a user submitted data to my app, I'd like to write to the > database asynchronously, possibly through a message queue. > > How do I set up such a system? Are there any pluggable Django apps > that do such message queue-based database writes? > > Would really appreciate any pointers you can give me. Thank you. quick google found this: http://github.com/fwenzel/django-gearman cheers justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: send an email to users after saving is_active=True
2010/5/4 zinckiwi > On May 4, 9:49 am, Sander wrote: > > I don't want to check if if_active = True > > I wan't to check if if_active is changed to True > > If you use the pre_save signal, you can get the object as it currently > exists (based in the signalled instance's pk) and compare the existing > object's `is_active` with the signalled instance's `is_active`. Of > course, then you run into the problem of the email being sent even if > the save itself fails, so you might then want to figure out a way of > persisting a flag from pre_save (which determines whether an email > should be sent) to post_save (which does the sending). Might be over- > engineering it, though. > I solved with this code: http://dpaste.com/192120/ and pre_save.connect(account_moderated_email, sender=Profile) -- Alessandro Ronchi http://www.soasi.com SOASI - Sviluppo Software e Sistemi Open Source Hobby & Giochi, l'e-commerce del divertimento http://hobbygiochi.com http://www.facebook.com/hobbygiochi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Bit Flags Field
Hi Have a django bit flags field ?? For example i have int field in base whit name "flags". The flags can be 0=empty, 1=locked . 2=unused I need to save this flags i one int field locked/unused =3 . I change this code http://www.djangosnippets.org/snippets/1200/ to use Int db field and its work well but is builtin way to do this without write special field class ?? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Localeurl and django-multilingual
I need to have links with language code prefix, and different contents. I've achieved that with both localeurl and django-multilingual, and I can get the tranlated version if i choice the correct url: for example http://mydomain.com/it/c/auto-intere/1/ and http://mydomain.com/pl/c/auto-intere/1/ but if I open http://mydomain.com/pl/c/auto-intere/1/ all the next link will redirect back to /it/ So, I need to fix the user choice and set it to the user request language. Is it possible? How? -- Alessandro Ronchi http://www.soasi.com SOASI - Sviluppo Software e Sistemi Open Source Hobby & Giochi, l'e-commerce del divertimento http://hobbygiochi.com http://www.facebook.com/hobbygiochi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Hi
How can we display manay to many field in list_display? pls help. -- Shyam Chandran Computer Science and Engineering Model Engineering College -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using a message queue from Django to write to database asynchronously
On 8 Μάϊος, 07:44, Continuation wrote: > After a user submitted data to my app, I'd like to write to the > database asynchronously, possibly through a message queue. > > How do I set up such a system? Are there any pluggable Django apps > that do such message queue-based database writes? > > Would really appreciate any pointers you can give me. Thank you. You can also look at http://www.celeryproject.org -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django with mod_wsgi on centos
Dear All I know this is strictly speaking off topic, so please forgive me. I have asked at the mod_wsgi list. On an Ubuntu machine I have a working django site, using nginx, apache and mod_wsgi. Now I am having to install the site on a CentOS machine. Everything is working, apart form one thing: apache is returning 403 permission denied when I try to access the wsgi script. I have carefully followed the mod_wsgi installation and configuration instructions, and scoured the blogs, forums, and wikis of the web. I have tried many things, but nothing will shift that 403. Below is a summary of the install and config steps I took and the fixes I've tried. Can anyone suggest anything I've missed? Can anyone suggest to me which permissions I need to change and to what? Presumably read/write permissions to some file or directory but which one(s)? Please let me know if you need more information. Can anyone help? Unfortunately, I think we have to stick with CentOS. With apologies, thanks and best wishes Ivan * What I did As CentOS uses python 2.4, I installed python 2.6 into /opt. I compiled from source using the following configure: ./configure --prefix=/opt --enable-ipv6 --with-threads --enable-shared I made the libpython so available $ cd /opt/lib/python2.6/config $ ln -s ../../libpython2.6.so . $ cat >> /etc/ld.so.conf.d/opt-python2.6.conf /opt/lib ^D $ ldconfig $ cp /etc/ld.so.conf.d/opt-python2.6.conf /etc/ld.so.conf.d/python2.6.conf (added later; just in case) When compiling mod_wsgi from source I used the following configure: ./configure --with-python=/opt/bin/python The resulting mod_wsgi.so is about 395k and is loading the python so: # ls -l mod_wsgi.so -rwxr-xr-x 1 root 385009 Apr 29 11:44 mod_wsgi.so # ldd mod_wsgi.so libpython2.6.so.1.0 => /opt/lib/libpython2.6.so.1.0 (0x2b249eec) libpthread.so.0 => /lib64/libpthread.so.0 (0x2b249f26f000) libdl.so.2 => /lib64/libdl.so.2 (0x2b249f48a000) libutil.so.1 => /lib64/libutil.so.1 (0x2b249f68f000) libm.so.6 => /lib64/libm.so.6 (0x2b249f892000) libc.so.6 => /lib64/libc.so.6 (0x2b249fb15000) /lib64/ld-linux-x86-64.so.2 (0x003dd100) The django app and its django_wsgi.py wgi script are outside of document root. django_wsgi.py has permissions 755, as does its containing directory. Here are some relevant apache configs I'm using: NameVirtualHost *:8080 Listen 127.0.0.1:8080 LoadModule wsgi_module modules/mod_wsgi.so AddHandler wsgi-script .wsgi WSGISocketPrefix run/wsgi WSGIPythonHome /home/path/to/py26/sys/prefix # ... WSGIScriptAlias / /path/to/django/app/apache/django_wsgi.py Order deny,allow Allow from all The error in apache's error logs is just: [error] [client 127.0.0.1] (13)Permission denied: access to / denied And it's the same error with LogLevel set to info. I have tried disabling selinux: no effect. I have tried switching the CentOS machine off and on again: no effect. I have tried the example wsgi script in the mod_wsgi wiki quick configuration page: still a 403. I have not tried daemon mode: sounds good but doesn't look like it would address my current problem. -- Ivan A. Uemlianin Speech Technology Research and Development i...@llaisdy.com www.llaisdy.com llaisdy.wordpress.com www.linkedin.com/in/ivanuemlianin "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" (Schiller, Beethoven) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django with mod_wsgi on centos
On Saturday 08 May 2010 20:32:51 Ivan Uemlianin wrote: > Can anyone suggest to me which permissions I need to change and to > what? Presumably read/write permissions to some file or directory but > which one(s)? > I do not know whether this will help, but I have seen permission denied errors in mandriva and fedora when the relevant directories/files are not executable by all. Maybe a chmod a+x would help. -- Regards Kenneth Gonsalves Senior Associate NRC-FOSS at AU-KBC -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Thread safety, transactions and best practices
Hello, I have a question about transactions and thread safe applications. I have an invoice app, where I have a model like this: class Counter(models.Model): client = models.ForeignKey(Client) number = models.CharField(max_length=10, db_index=True) class Meta: unique_together = (("client", "number"),) Where number is the number of the invoice: "2010/321" What I need is to create a view that takes the last invoice number of a client, parse it and add 1. ie: "2010/321" -> "2010/322" I have something like this: @transaction.commit_on_success def increment_counter(name, client): counter = Counter.objects.filter(client=client).order_by('-id')[0] #Step 2: Parse format and Increment the counter newcounter = "2010/322" counter.count = newcounter #Step 3: Save the new counter counter.save() I don't know if this is the best approach. Imagine that when the first thread (thread1) is in step2, the second thread (thread2) just inserted a new value in the database, so the counter is already on "2010/322" but thread1 will try to write the same value. It will fail because there is already a row with that value in the ddbb. How can I solve this problem? Can I use the F() function for this? Should I use SQL "SELECT ... FOR UPDATE" ? Thank you very much, Adrian Ribao -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Hi
On za, 2010-05-08 at 16:04 +0530, Shyam chandran wrote: > How can we display manay to many field in list_display? > pls help. You can't. http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display -- Dennis K. They've gone to plaid! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Hi
On 8 Maj, 12:34, Shyam chandran wrote: > How can we display manay to many field in list_display? > pls help. U can do this. " If you want to do this nonetheless, give your model a custom method, and add that method's name to list_display. (See below for more on custom methods in list_display.) " -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Open source CMS (if based on Django better)
Right now i'm evaluating which technology learn to develope applications (web app). I'm thinking on CMS and lately in Flex (also pyjamas) or more interactive technologies, thinking in develope an application to monitoring remote systems through the Internet. I have to consider the most requested specifications for common applications and mix that with the experienced guy opinions as yours to make a decision on what mix of technologies git worth study hard for the future. Thanks for your ideas !! On May 7, 7:59 pm, Andy McKay wrote: > On 2010-05-05, at 12:52 PM, Jonatan.mv wrote: > > > What would be you recommended CMS?. Could you please give some reasons > > (pro and cons)?. > > Just to confuse things, don't forget you can pretty much use any non-Django > CMS as long as it can write to a relational database. All depends what you > want to do. > -- > Andy McKay, @andymckay > Django Consulting, Training and Support > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Quotas for Django models
Hi! I'm starting using Django and I have a little problem, may be someone can help me. Thanks in advance. My problem: 1. I have 2 models: Places and Photos. 2. There is a ManyToMany relation between Places and Photos through a custom model 'PlacePhotos' Class Photo(models.Model): ... Class Places(models.Model): photos = models.ManyToManyField(Photo, through='PlacePhotos') ... Class PlacePhotos(models.Model): place = models.ForeignKey(Place) photo = models.ForeignKey(Photo) ... 3. Now, I want to restrict the number of Photos added (for example, max 25 photos by place) 4. I've created PlacePhotos instances in this way: place = get_object_or_404(Place, slug=slug) photo = Photo() x = PlacePhotos(place=place, photo=photo) x.save() 5. I've redefined the PlacePhotos.save() method in this way: Class PlacePhotos(models.Model): place = models.ForeignKey(Place, related_name='place_photos') photo = models.ForeignKey(Photo) def save(self, request): if Photos.objects.filter(place=self.place).count() > 25: raise Exception("Too many photos for this place...") ## ## If everything OK, save the Photo and then save the relationship. ## self.photo.save() ## I save the photo but I don't receive any id :( models.Model.save(self) 5. The problem raises in the last sentence (models.Model.save(self)). I cannot save the new relationship because self.photo.id = Null so I cannot save the photo inside this function, I have to save it before creating the PlacePhotos relationship, but I don't want to save the new photo if I'm not sure if the quota will be exceeded. 6. Of course I can check the condition count() > 25 before create a new Photo, but I prefer to do it in the save() method (and avoid to check the condition in every view). Any ideas to resolve this please? Thanks, and sorry for my English mistakes. x13 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Additional Text Form Field within a Models Admin Screen
Hi all, I'm pretty new to Django so bare with me if this is a simple question. Basically, I have an Article model which is simply title, body, status etc. Now, I want to add an additional TextBox to the admin for the model, but I don't want to add it as part of the Article model, as I don't want to store it directly into the database as a string. The TextBox will take an input, lets say "1, 2, 3, 4" I then want to programmatically split this by the comma and add each item (1, 2, 3, 4) as a separate record which is a pre-existing model. Any advice here would be greatly appreciated! Thanks a lot, Nick -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Errors while attempting to enable admin
:( As Daniel pointed out this is a simple case of RTFM. I didn't read and my eyes and brain ASSUMED (you know what that does) that 'django.contrib.auth' was 'django.contrib.admin' and just needed to be uncommented in urls. Well, guess what? When you add the proper line IT WORKS! I am extremely embarrassed about this because although I am a newcomer to django I am not a technical or even programming newbie. Thank you for taking the time to point that out Daniel. On May 7, 2:09 am, Daniel Roseman wrote: > On May 7, 4:37 am, Andrew Burns wrote: > > > > > > > Django newbie here. I am learning by following the Django book. All > > is good until I try to enable the admin interface (on v1.1.1) and I > > get the following error: > > TemplateDoesNotExist at /admin/ > > admin/login.html > > > So I did some poking around and changed my TEMPLATE_DIRS to the > > following (which I don't think was the right way to do it anyway): > > import os.path #import so we can use magic for the template import > > TEMPLATE_DIRS = ( > > os.path.join(os.path.dirname(__file__), > > 'templates').replace('\ > > \','/'), > > > > '/usr/lib/pymodules/python2.6/django/contrib/admin/templates/', > > ) > > > When I do that I get: > > TemplateSyntaxError at /admin/ > > 'adminmedia' is not a valid tag library: Could not load template > > library from django.templatetags.adminmedia, No module named > > adminmedia > > > This is a 'vanilla' ubuntu django install (I didn't pull from SVN) so > > I am hoping that this is a well-known issue, I read the comments on > > the book site and none appeared to be this issue. > > > Can someone give me some pointers? > > > Thanks in advance. > > Are you sure you have added 'django.contrib.admin' to the > INSTALLED_APPS tuple? > > With that, you shouldn't need to hack the template path. > -- > 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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Is Django's session lazy?
If I don't access Django's User object in a view, does Django still retrieve the session data from the session backend? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.