Re: Insane sql logging
Good question. We decided not to do it at database level because we didn't want to write every select on the file, but only the update/insert/delete. Probably it was better that way, though, and clean the file later. Matteo Suppo - Social Media Badass "C'è sempre un altro modo" "Ho l'80% di probabilità di fare qualsiasi cosa" 2013/1/15 Addy Yeow <ayeo...@gmail.com> > Why not do this at database level? > e.g. using http://dev.mysql.com/doc/refman/5.1/en/query-log.html > > On Tue, Jan 15, 2013 at 9:35 PM, Matteo Suppo <matteo.su...@gmail.com> > wrote: > > Sometimes people ask for strange features, like "I want to log every > > database query except select". > > > > There will be drawbacks, of course: it will be slower, for example, but > they > > won't care. > > > > It happened to us, and we had to ship this insanity: > > > > import logging > > from logging.handlers import RotatingFileHandler > > from django.db.backends import BaseDatabaseWrapper > > from django.db.models.signals import pre_save, post_save, pre_delete, > > post_delete > > from django.dispatch import receiver > > > > from datetime import datetime > > > > from django.conf import settings > > > > def patch_cursor(self): > > """ Monkey Patch BaseDatabaseWrapper to always use the debug cursor > """ > > self.validate_thread_sharing() > > > > return self.make_debug_cursor(self._cursor()) > > BaseDatabaseWrapper.cursor = patch_cursor > > > > @receiver(pre_delete) > > @receiver(pre_save) > > def member_pre_save(sender, **kwargs): > > l = logging.getLogger('django.db.backends') > > l.setLevel(logging.DEBUG) > > if len(l.handlers) <= 0: > > handler = RotatingFileHandler(settings.BACKUP_FILENAME, > > maxBytes=settings.BACKUP_MAXBYTES) > > l.addHandler(handler) > > l.debug(datetime.now()) > > > > @receiver(post_delete) > > @receiver(post_save) > > def member_post_save(sender, **kwargs): > > l = logging.getLogger('django.db.backends') > > l.removeHandler(l.handlers[0]) > > > > Of course now they told us they want to log the IP of the machine who > > triggered the query, so we'll have to use a different approach. Sigh. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/django-users/-/voMGlGJ3UqgJ. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Insane sql logging
Sometimes people ask for strange features, like "I want to log every database query except select". There will be drawbacks, of course: it will be slower, for example, but they won't care. It happened to us, and we had to ship this insanity: import logging from logging.handlers import RotatingFileHandler from django.db.backends import BaseDatabaseWrapper from django.db.models.signals import pre_save, post_save, pre_delete, post_delete from django.dispatch import receiver from datetime import datetime from django.conf import settings def patch_cursor(self): """ Monkey Patch BaseDatabaseWrapper to always use the debug cursor """ self.validate_thread_sharing() return self.make_debug_cursor(self._cursor()) BaseDatabaseWrapper.cursor = patch_cursor @receiver(pre_delete) @receiver(pre_save) def member_pre_save(sender, **kwargs): l = logging.getLogger('django.db.backends') l.setLevel(logging.DEBUG) if len(l.handlers) <= 0: handler = RotatingFileHandler(settings.BACKUP_FILENAME, maxBytes=settings.BACKUP_MAXBYTES) l.addHandler(handler) l.debug(datetime.now()) @receiver(post_delete) @receiver(post_save) def member_post_save(sender, **kwargs): l = logging.getLogger('django.db.backends') l.removeHandler(l.handlers[0]) Of course now they told us they want to log the IP of the machine who triggered the query, so we'll have to use a different approach. Sigh. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/voMGlGJ3UqgJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Generating HTML code
I use http://foundation.zurb.com/ or http://twitter.github.com/bootstrap/ They don't generate html but they help build pages faster. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/UpwMctldYvIJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Facebook like button in django
You want to add a Facebook share button that lets people share things on Facebook but also save what they are sharing on your database? On Thursday, October 11, 2012 9:50:54 PM UTC+2, David Gomez wrote: > > How can I create a Facebook Share button in django? I would like something > like this: > button name my_website > When user click the button it would pop up a window with a form > When user click the button, it will grab the form information and the > information on the blog, and put it on the database like it would do on a > regular form. > The form will have: > username = username > password = password > note = what ever note the user type > blog = the blog where the button was in. > > Thanks in advance > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Y6vastIH-iEJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django-cms + Wymeditor + Heroku + AWS s3 + Cors
I found this: http://comments.gmane.org/gmane.comp.python.django.django-cms/1202 and I decided to use tinymce for now. It's not solved though. I will do something, maybe. On Thursday, October 11, 2012 7:25:19 PM UTC+2, Matteo Suppo wrote: > > Ok, here's a fun one. > > I set up a django installation on Heroku, added the django-cms app, > deployed on heroku, and collected the static files on AWS. > > The problem is Django-CMS tries to load the js file for the wymeditor but > AWS says: > > MLHttpRequest cannot load > https://s3.amazonaws.com/[...]/cms/js/wymeditor/skins/django/skin.js. > Origin [...] is not allowed by Access-Control-Allow-Origin. > > I actually searched a lot, and discovered this: > http://docs.amazonwebservices.com/AmazonS3/latest/dev/cors.html > > Seems like a solution, but even if I activated it, nothing works. > > I'm at loss. It should work but it doesn't. Am I missing something here? > Maybe it doesn't work the way I thought? Should I ask AWS directly? > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/4YPceJ2PwyoJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django-cms + Wymeditor + Heroku + AWS s3 + Cors
Apparently with Firefox I don't have the CORS problem. It doesn't work either but at least it's a different error message: Error: Permission denied to access property 'styleSheets' styles = this._doc.styleSheets[0]; that brought me to this: http://stackoverflow.com/questions/2206586/wymeditor-across-subdomains-cross-site-permission-issue Hmm I'll try it On Thursday, October 11, 2012 7:25:19 PM UTC+2, Matteo Suppo wrote: > > Ok, here's a fun one. > > I set up a django installation on Heroku, added the django-cms app, > deployed on heroku, and collected the static files on AWS. > > The problem is Django-CMS tries to load the js file for the wymeditor but > AWS says: > > MLHttpRequest cannot load > https://s3.amazonaws.com/[...]/cms/js/wymeditor/skins/django/skin.js. > Origin [...] is not allowed by Access-Control-Allow-Origin. > > I actually searched a lot, and discovered this: > http://docs.amazonwebservices.com/AmazonS3/latest/dev/cors.html > > Seems like a solution, but even if I activated it, nothing works. > > I'm at loss. It should work but it doesn't. Am I missing something here? > Maybe it doesn't work the way I thought? Should I ask AWS directly? > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ejalT2r8CbUJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django admin - store small pieces of data
> > I would like to add to panel admin new position only with edit view where > user can fill couple of text fields I don't understand what you're saying here, but for the rest it appears to me that maybe this could help you: http://www.djangopackages.com/packages/p/django-flatblocks/ On Thursday, October 11, 2012 7:02:29 PM UTC+2, Wojtek Rymaszewski wrote: > > Hi, > > It's my first post so at the beginning i would like to say Hello. > > I am quite new to django. > > I have one problem to solve. > > My website has couple of places where i would like to put some content > (static text) managed by admin panel. > I know that there is django flatpage or some project like django-chunk. > Flatpage has only couple of fields and django-chunk has all in one place > (key-value). > > I would like to add to panel admin new position only with edit view where > user can fill couple of text fields. After save data is storied in file (or > in database). > > Generally i would like to store small pieces of text like phone number, > address, some tagline which are on several pages. And creating model with > full CRUD is unnecessary. > > How can i do this? Is it possible? > > Thanks in advance. > > Best regards, > Wojtek > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ImsMwIb5K_YJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django-cms + Wymeditor + Heroku + AWS s3 + Cors
Ok, here's a fun one. I set up a django installation on Heroku, added the django-cms app, deployed on heroku, and collected the static files on AWS. The problem is Django-CMS tries to load the js file for the wymeditor but AWS says: MLHttpRequest cannot load https://s3.amazonaws.com/[...]/cms/js/wymeditor/skins/django/skin.js. Origin[...] is not allowed by Access-Control-Allow-Origin. I actually searched a lot, and discovered this: http://docs.amazonwebservices.com/AmazonS3/latest/dev/cors.html Seems like a solution, but even if I activated it, nothing works. I'm at loss. It should work but it doesn't. Am I missing something here? Maybe it doesn't work the way I thought? Should I ask AWS directly? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/X4aoCq5rnGEJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
c9.io and django admin - the quest for missing templates
So I'm trying to develop with https://c9.io/ It's basically an online development suite, with terminals and editor and stuff. I installed django via pip and tried something with the admin, but I got this ugly error: TemplateDoesNotExist at /admin/ admin/login.html YES, I added the django.contrib.admin app to the settings file. I investigated and discovered that while in my computer the templates for the admin were in the same directory as the python files venv/lib/python2.7/site-packages/django/contrib/admin/templates/ on c9.io they were in /data/share/django/contrib/admin/templates while the python files for the app were in /data/lib/python/site-packages/django/contrib/admin That's why the template loader couldn't find them. I fixed it by copying the templates in the app/templates folder, but it's not really a fix... -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/soYT3UrkQCUJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: app for kickstarter-like goals
I just wanted to be sure there wasn't already something. So, since I found nothing, I guess I'll start build it. See ya and Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Akk6r4uxdFAJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
app for kickstarter-like goals
I'm developing a website for a non-profit organization. They want something similar to kickstarter, only based on people instead of money. Let's say there's an event. A birthday. If 5 people preorder the ticket there will be a clown* If 10 people preorder the ticket there will be a clown orchestra (in a small car) il 100 people preorder the ticket there will be a golden statue of a clown. I have no problem with the "buying tickets thing", but I couldn't find in django-packages anything related to milestones or goals. Do you know if there is already something I can use? Or should I create it? Thanks! * if you hate clowns you can replace them with cookies -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/2y9biFnbiIUJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.