Re: Location of temporary file writes in Django production mode
Hi, it seems to be something with Python-PYx and writing permissions, I google it and find this: http://permalink.gmane.org/gmane.comp.python.pyx.users/347 check it out -- Anler Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Sunday, January 8, 2012 at 8:32 PM, wilbur wrote: > Hello, > > I have recently migrated my Django application from a development server to a > production server. Everything works pretty well with the exception of a PDF > generating view that uses Python-PYx. The PyX package uses Tex/LaTex, and > when I try to generate a PDF, I get the following error: > > IOError at /buildMetCatalog/ > [Errno 13] Permission denied: 'tmpYHNZ4b.tex' > > Traceback Switch to copy-and-paste view > (http://meteorite.unm.edu/buildMetCatalog/#) > /usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py in > get_response > response = callback(request, *callback_args, **callback_kwargs) > ... > > > ▶ Local vars (http://meteorite.unm.edu/buildMetCatalog/#) > > /home/wilbur/IOM/iom_catalog/views.py in buildMetCatalog > c1.text(306, 680, header_text, [text.halign.boxcenter, text.halign.center, > text.size.Huge]) > ... > > > ▶ Local vars (http://meteorite.unm.edu/buildMetCatalog/#) > > /usr/lib/pymodules/python2.6/pyx/canvas.py in text > return self.insert(self.texrunner.text(x, y, atext, *args, **kwargs)) > ... > > > ▶ Local vars (http://meteorite.unm.edu/buildMetCatalog/#) > > /usr/lib/pymodules/python2.6/pyx/text.py in text > self.execute("\\begin{document}", self.defaulttexmessagesbegindoc + > self.texmessagesbegindoc) > ... > > > ▶ Local vars (http://meteorite.unm.edu/buildMetCatalog/#) > > /usr/lib/pymodules/python2.6/pyx/text.py in execute > texfile = open("%s.tex" % self.texfilename, "w") # start with filename -> > creates dvi file with that name > ... > > > ▶ Local vars (http://meteorite.unm.edu/buildMetCatalog/#) > > > > From the file extension, it appears that tex is trying to write some kind of > temporary file to the filesystem, but I am unclear about where I need to look > to set permissions. Any guidance would be appreciated > > Bill > -- > 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/-/rOUUrEV1CCkJ. > To post to this group, send email to django-users@googlegroups.com > (mailto:django-users@googlegroups.com). > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > (mailto: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.
Re: Joining Tables
Oh sorry, it should be this: photos = Photos.objects.filter(user__groups__id=the_group_id) -- Anler Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Sunday, January 8, 2012 at 12:04 PM, Anler wrote: > Swaroop I think this is what you're asking for: > > photos = Photos.objects.filter(user__groups__name='admin') > > -- > Anler > Sent with Sparrow (http://www.sparrowmailapp.com/?sig) > > > On Sunday, January 8, 2012 at 11:42 AM, Jonas Geiregat wrote: > > > > > > > > Thanks Jonas, the statements you had provided would give me a list of > > > users who belong that group, but how can I retrieve the photos of those > > > users? Actually I was looking for a single statement which would join all > > > these tables and returns the data based on the Group ID. > > > > I would recommend reading through > > https://docs.djangoproject.com/en/dev/topics/db/queries/ > > > > Getting a row by ID: > > > > Group.objects.get(pk=group_id) > > > > -- > > 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 > > (mailto:django-users@googlegroups.com). > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > > (mailto: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.
Re: Joining Tables
Swaroop I think this is what you're asking for: photos = Photos.objects.filter(user__groups__name='admin') -- Anler Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Sunday, January 8, 2012 at 11:42 AM, Jonas Geiregat wrote: > > > > Thanks Jonas, the statements you had provided would give me a list of users > > who belong that group, but how can I retrieve the photos of those users? > > Actually I was looking for a single statement which would join all these > > tables and returns the data based on the Group ID. > > I would recommend reading through > https://docs.djangoproject.com/en/dev/topics/db/queries/ > > Getting a row by ID: > > Group.objects.get(pk=group_id) > > -- > 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 > (mailto:django-users@googlegroups.com). > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > (mailto: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.
Re: Bulk import of data
Hi, this is probably not your case, but in case it is, here is my story: Creating a script for import CSV files is the best solution as long as they are few, but in my case, the problem was that I need to import nearly 40 VERY BIG CSV files, each one mapping a database table, and I needed to do it quickly. I thought that the best way was to use MySQL's "load data in local..." functionality since it works very fast and I could create only one function to import all the files. The problem was that my CSV files were pretty big and my database server were eating big amounts of memory and crashing my site so I ended up slicing each file in smaller chunks. Again, this is a very specific need, but in case you find yourself in such situation, here's my base code from which you can extend ;) https://gist.github.com/1dc28cd496d52ad67b29 -- anler On Sun, Nov 27, 2011 at 7:56 PM, Andre Terra <andrete...@gmail.com> wrote: > This should be run asynchronously (i.e. celery) when importing large files. > > If you have a lot of categories/subcategories, you will need to bulk > insert them instead of looping through the data and just using > get_or_create. A single, long transaction will definitely bring great > improvements to speed. > > One tool is DSE, which I've mentioned before. > > Good luck! > > > Cheers, > AT > > > On Sat, Nov 26, 2011 at 8:44 PM, Petr Přikryl <prik...@atlas.cz> wrote: > >> >> >>> import csv >> >>> data = csv.reader(open('/path/to/csv', 'r'), delimiter=';') >> >>> for row in data: >> >>> category = Category.objects.get_or_create(name=row[0]) >> >>> sub_category = SubCategory.objects.get_or_create(name=row[1], >> >>> defaults={'parent_category': category}) >> >>> product = Product.objects.get_or_create(name=row[2], >> >>> defaults={'sub_category': sub_category}) >> >> There are few potential problems with the cvs as used here. >> >> Firstly, the file should be opened in binary mode. In Unix-based >> systems, the binary mode is technically similar to text mode. >> However, you may once observe problems when you move >> the code to another environment (Windows). >> >> Secondly, the opened file should always be closed -- especially >> when building application (web) that may run for a long time. >> You can do it like this: >> >> ... >> f = open('/path/to/csv', 'rb') >> data = csv.reader(f, delimiter=';') >> for ... >> ... >> f.close() >> >> Or you can use the new Python construct "with". >> >> P. >> >> -- >> 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. > -- 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.