Changing transaction isolation level for a particular view function

2010-03-30 Thread Chris Young
Hello, Just in case I have a "XY problem", the actual problem I'm trying to solve is that I want to be able to read data from two unrelated models and make sure that the data from each appeared to come from the same instant in time. In the database, I'd use: BEGIN; SET TRANSACTION ISOLATION LEVEL

Re: Django Distinct on queryset in forms.py

2010-03-30 Thread Thomas
Dear, Look at my first post i had .distinct() into it and it didn't work out, it's pretty obvious why, he does the distinct on the primary key field (ID) and not on the field hostname, so i get no SELECT Distinct result as i would like to. Trust me the only way of doing this is my 2nd post or the

Re: transactions

2010-03-30 Thread Continuation
On Mar 30, 8:33 am, Tomasz Zieliński wrote: > If you take a look at TransactionMiddleware source: > > http://code.djangoproject.com/browser/django/tags/releases/1.1.1/djan... > > then you'll see that it's just commit_on_success in disguise: > > http://code.djangoproject.com/browser/django/tags/

How do I properly unit test a Django session?

2010-03-30 Thread adambossy
The behavior of Django sessions changes between "standard" views code and test code, making it unclear how test code is written for sessions. Googling this yields two relevant discussions about this issue: 1. "Easier manipulation of sessions by test client" [http:// code.djangoproject.com/ticket/1

Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Paulo Almeida
Cool, you're all set then. Documentation on Platypus should help you do what you want. I know it can do tables flow between pages, repeating the header in the beginning of each page if desired, and I'm sure there are ways of creating headers and footers, although I have never tried them. Best, Pau

Re: Add message each page load

2010-03-30 Thread Wiiboy
>  - have you enabled the messages' context processor? Yes >  - are you consuming the 'messages' variable in your templates? UmmYes? I'm displaying one message, but only 1, since I'm only setting 1 per request. That's probably the issue, but why is more than one message being set per request,

Re: Add message each page load

2010-03-30 Thread Rolando Espinoza La Fuente
On Tue, Mar 30, 2010 at 6:33 PM, Wiiboy wrote: > Hi guys, > How do I add a message (Django 1.2 style) each page load, and have it > cleared after the request? > > I set up a middleware running on process_request, but I end up with a > bunch of messages in the admin interface. May sound obvious, b

Add message each page load

2010-03-30 Thread Wiiboy
Hi guys, How do I add a message (Django 1.2 style) each page load, and have it cleared after the request? I set up a middleware running on process_request, but I end up with a bunch of messages in the admin interface. My code: class BetaMessageSet(object): def process_request(self, request):

Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
Shame on me. The problem was that i mixed SimpleDocTemplate (which the examples were based on), with BaseDocTemplate, which i used. And BaseDocTemplate needs an extra PageTemplate defined. So this code basically works: def generate_pdf(request): response = HttpResponse(mimetype='application/pd

Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
Hm, what makes me wonder is this one: IndexError at /office/job//admin/job/offer/generate/pdf/ This is a url that is not accessible, cause it does not exist, at least i never defined it in any urls.py. Maybe thats the problem? Django tries to access a url which doesnt exist? Greetings Sven On Tu

Re: TemplateSyntaxError Caught UnicodeEncodeError while rendering

2010-03-30 Thread Alessandro Pasotti
2010/3/30 Karen Tracey > On Tue, Mar 30, 2010 at 5:45 PM, Alessandro Pasotti wrote: > >> Hello, >> >> >> Exception Type: TemplateSyntaxError at >> /resource/news/un-nuovo-ostello-sulla-francigena/ >> Exception Value: Caught UnicodeEncodeError while rendering: 'ascii' codec >> can't encode charact

Re: TemplateSyntaxError Caught UnicodeEncodeError while rendering

2010-03-30 Thread Karen Tracey
On Tue, Mar 30, 2010 at 5:45 PM, Alessandro Pasotti wrote: > Hello, > > I need some help with a strange problem, the traceback says: > > > File "/usr/lib/python2.5/site-packages/django/core/files/storage.py" in > size > 216. return os.path.getsize(self.path(name)) > File "/usr/lib/python

TemplateSyntaxError Caught UnicodeEncodeError while rendering

2010-03-30 Thread Alessandro Pasotti
Hello, I need some help with a strange problem, the traceback says: File "/usr/lib/python2.5/site-packages/django/core/files/storage.py" in size 216. return os.path.getsize(self.path(name)) File "/usr/lib/python2.5/posixpath.py" in getsize 139. return os.stat(filename).st_size E

word processing django apps

2010-03-30 Thread John Griessen
Some potential Django site users I know asked for word processing with revisions for group writing they do. Is there a web hostable word processor with savable version history that is easy to integrate with Django? A web based editor search turns up wymeditor TinyMCE Anyone integrated these a

Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
On Tue, Mar 30, 2010 at 9:08 PM, Paulo Almeida wrote: > Ok, that is not easy to debug with so little information. Is the IndexError > in views.py? Maybe there is a mistake in urls.py, caused by adding the url > for the generate_pdf view? Hm, its indeed hard. I really dont know what that Error wil

Re: Adding records to 2 tables at the same time from admin page

2010-03-30 Thread John M
If you write something in the model's save() method that should do what you want. On Mar 28, 10:05 pm, cnone wrote: > The admin page has a button to add records. When I click a table from > admin page and click add, I can enter data. What I want to do is I > want to add records to 2 table at the

Re: Django HttpResponse performance with mimetype=application/atom+xml or text/xml

2010-03-30 Thread Dan Carroll
How big is the XML? Since you've already verified that the generation isn't the problem, this could be a browser issue. Most browsers attempt to parse and style the XML (to show it in a nice document tree), which could take a while for really huge files. When choosing to output with the HTML mim

Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Paulo Almeida
Ok, that is not easy to debug with so little information. Is the IndexError in views.py? Maybe there is a mistake in urls.py, caused by adding the url for the generate_pdf view? - Paulo On Tue, Mar 30, 2010 at 7:57 PM, Sven Richter wrote: > On Tue, Mar 30, 2010 at 8:21 PM, palmeida > wrote: > >

Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
On Tue, Mar 30, 2010 at 8:21 PM, palmeida wrote: > Is that all your code? I don't see a line like this (from my > generate_pdf function): > > doc = SimpleDocTemplate(response, pagesize=A4) I missed that one out of my example. You're right. But it doesnt generate a pdf like that, it just complains

assert_compliant_sql

2010-03-30 Thread Phlip
Django-users: Programmers can spend a lot of time developing a nice index, and a database can spend many cycles rebalancing it... ...all to see a stray "refactor" blow that index away, by changing a generated SELECT, forcing the database to skip the index. To catch that issue, before soak test t

Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread palmeida
Is that all your code? I don't see a line like this (from my generate_pdf function): doc = SimpleDocTemplate(response, pagesize=A4) That's what links the 'response' variable to the output of the doc.build function. But I don't think that should be what's causing the IndexError, because you don't

Admin Add Page

2010-03-30 Thread Asim Yuksel
I want to use a custom admin add page with custom admin look and feel. What is the template to extend? I want to use something like this http://picasaweb.google.com/110428031719333287170/BaslKsZAlbum#5454485792741726834 I tried to hack the html by viewing the source but it is time consuming and i

Problem with contrib.auth in database migration

2010-03-30 Thread dadapapa
Dear list, I am using Django 1.0 + MySQL on the production server and Django 1.1 + sqlite3 on my (local) development server. My application uses contrib.auth.User etc. and I am running into the following issue when trying to migrate the production database to the development server. production se

Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread HARRY POTTRER
On Mar 30, 12:08 pm, Sven Richter wrote: > > So if somebody could provide some working code, or a hint to > repository or an application with some working code, i'd really > appreciate that. > > Greetings > Sven You can look through my code: http://github.com/nbv4/flightloggin/blob/master/pdf/pd

Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
Great, thank you very much, this got me started. However, its not working yet. This is the code i have right now: def generate_pdf(request): response = HttpResponse(mimetype='application/pdf') response['Content-Disposition'] = 'attachment; filename=somefilename.pdf' styles = getSampleS

Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Paulo Almeida
I'm using Platypus (part of reportlab) to generate pdfs without micromanagement of Canvas elements. reportlab's documentation was very helpful to learn how to work with Paragraph, Table, Image, etc. Some code: # views.py @login_required def view_pdf(request, experiment_id): experiment = get_ob

Re: Use admin widgets in inlineformset_factory

2010-03-30 Thread Paulo Almeida
This may point you in the right direction: http://stackoverflow.com/questions/559361/inline-formset-in-django-removing-certain-fields Take home message is that you can pass a ModelForm subclass to the fomset constructor, so you can have a custom form. There is no example in that link though, and

Re: chronograph dtstart until params

2010-03-30 Thread Tim Daniel
Sorry I posted a older/bugged version, here goes the right one, inside the run function: def run(self, wait=True): if not self.disabled: if not self.check_is_running() and self.is_due(): if self.end_run and self.end_run < self.next_run: self

Re: Deleted blog posts not disappearing

2010-03-30 Thread Karen Tracey
On Tue, Mar 30, 2010 at 11:23 AM, grimmus wrote: > Thanks for the replies. > > I am using generic date based views for the page, so i am passing > other things through the extra_context : > > My code is here http://dpaste.com/hold/177740/ > > Thanks for any more info. > > Please read: http://docs

django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
Hi everybody, i am looking for a way to get BaseDocTemplate from the reportlab library working, connected with a httpresponse. I found the documentation for a simple reportlab page, using canvas. But to me it seems, that i need more options than basic Canvas offers. Like a page header or footer, t

Re: Django Distinct on queryset in forms.py

2010-03-30 Thread pjrhar...@gmail.com
On Mar 30, 2:10 pm, Thomas wrote: > I already found a solution by myself: > > doing this into the forms.py inside the class does the trick: > >         def __init__(self, *args, **kwargs): >                 super(FilterForm, self) .__init__(*args, **kwargs) >                 self.fields['host'].

Re: chronograph dtstart until params

2010-03-30 Thread Tim Daniel
Well I've implemented the UNTIL functionality by myself adding a field end_run in models.py: end_run = models.DateTimeField(_("end run"), blank=True, null=True, help_text=_("If you don't set this the job will be running eternally")) Later in the handle_run function where te next_run is calculated

Re: chronograph dtstart until params

2010-03-30 Thread Tim Daniel
Well I've implemented the UNTIL functionality by myself adding a field end_run in models.py: end_run = models.DateTimeField(_("end run"), blank=True, null=True, help_text=_("If you don't set this the job will be running eternally")) Later in the handle_run function where te next_run is calculated

Re: deepcopying form classes and thread safety

2010-03-30 Thread pjrhar...@gmail.com
This is quite old but still relevant: http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/ Basically, create your form and edit the widget with an __init__ like this: class FlightForm(forms.ModelForm): def __init__(self, profile, *args, **kwargs): super(FlightForm, self).__init__(

Re: Displaying the fields of two tables on the same admin page

2010-03-30 Thread pjrhar...@gmail.com
On Mar 29, 4:17 pm, Asim Yuksel wrote: > I am entering them on the same page otherwise I will have to note down > the ids of people and publications table and then go to bridge table > and insert the ids there. So the reason I want to enter in the same > page is I will insert the ids into bridge

Re: Deleted blog posts not disappearing

2010-03-30 Thread grimmus
Thanks for the replies. I am using generic date based views for the page, so i am passing other things through the extra_context : My code is here http://dpaste.com/hold/177740/ Thanks for any more info. On Mar 26, 4:06 pm, Karen Tracey wrote: > On Fri, Mar 26, 2010 at 9:32 AM, grimmus wrote:

Re: Custom Admin Form for ManyToMany, missing Green Plus Sign?

2010-03-30 Thread Dennis Schmidt
Hi, I have got a similar or maybe the same problem. I have customized my admin form for a specific model. My model has got Inline elements that are shown on the admin form, but the template for this is completely customized. This is how I print the (product) model: {{ fieldset.form.product.erro

Re: Error in image upload while copying file

2010-03-30 Thread bruno desthuilliers
On 29 mar, 18:59, pjmorse wrote: > On Mar 29, 8:22 am, bruno desthuilliers > > wrote: > > On 19 mar, 20:05,pjmorse wrote: > > > > In my application's admin console, there's a tiny form for updating > > > the image associated with a specific model. > > > > When a file is uploaded, the application

Not translating the admin

2010-03-30 Thread filias
Hi, I have an application in several languages but I would like to keep the admin site always in english. What is the best way to do this? Thanks 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

Re: Cassandra backend

2010-03-30 Thread Waldemar Kornewald
Hi, On Mar 29, 7:17 pm, Ricardo Bánffy wrote: > It would be more on the lines of the first one. I guess folks intent > to pretend, as much as possible, that we are running vanilla Django - > and, perhaps, deploy to a RDBMS and only move to a non-relational > store if the app is successful enough.

Re: Django Distinct on queryset in forms.py

2010-03-30 Thread Thomas
I already found a solution by myself: doing this into the forms.py inside the class does the trick: def __init__(self, *args, **kwargs): super(FilterForm, self) .__init__(*args, **kwargs) self.fields['host'].choices = Test.objects.values_list('hostname', 'h

Re: transactions

2010-03-30 Thread Tomasz Zieliński
On 30 Mar, 07:24, Continuation wrote: > If I have a view function that transfers money from savings to > checking account, is @transaction.commit_on_success the recommend way > to manage the transaction? > > So something like: > > @transaction.commit_on_success > def transfer(request): >     ... >

Re: Multiple tables, is Django suited for this?

2010-03-30 Thread Tomasz Zieliński
Just an idea based on my experience - I'm able to plug on/off tables on the fly, using database VIEWs. Such VIEW can be bound to Django model with Meta: managed = False, and you can bind anything you want to it (I mean - arbitrary SELECT). -- Tomasz Zielinski http://pyconsultant.eu -- You receiv

Re: Multiple tables, is Django suited for this?

2010-03-30 Thread Matthias
Thanks for the reply, that's pretty much what I was thinking. There is user interaction in creating a new part, they select the table and input a digikey part number and my app does the rest. So luckily all my app has to do is given them a drop down list of available tables and an option to create

Re: Multiple tables, is Django suited for this?

2010-03-30 Thread john2095
Not impossible at all. Just a lot of work :-) You'd have to build and maintain a little model generator script to detect a new table, determine its schema, and generate the models. Then what? Your application detects new models appearing and can autonomously decide what to do with each one? Sound

Re: Initializing a ModelForm don't work - BUG ?

2010-03-30 Thread pjrhar...@gmail.com
On Mar 29, 12:24 pm, bruno desthuilliers wrote: > On 29 mar, 09:12, Thierry Chich wrote: > > > Le lundi 29 mars 2010 02:14:34, pjrhar...@gmail.com a écrit :> > OK. I can > > also put an hidden field in my form. I will evaluate what is > > > > the better option for me. > > > > Bear in mind if y

Django Distinct on queryset in forms.py

2010-03-30 Thread Thomas
Hi all, I try to get a list with distinct into the forms.py like this: forms.ModelMultipleChoiceField(queryset=Events.objects.values('hostname'), required=False).distinct() In the python shell this command works perfect, but when trying it in forms.py leaves me a blank form, so nothing appears.

How can i populate app engine(production environment) database with local sdk database

2010-03-30 Thread Eximius
Hi all, I have created a django application using app engine sdk, and have stored data in database using forms. But the problem i am getting when i deploy it, the data I stored is not there in the app engine datastore. So how can i populate app engine database with local database/data and also vice

Thanks for upload_to=

2010-03-30 Thread john2095
Just a little shout out to the development team for anticipating my need and coming up with this little gem. To keep the long story short I spent the entire day trying work out how I was going to save a file somewhere in the filesystem with a file path determined by the properties of the model. D

Re: IntegrityError: foreign key violation upon delete

2010-03-30 Thread naos
Problem has been solved and it doesn't have connection to any bugs, it was just programming error (there was shipment.save() somewhere later in python code) On Mar 30, 10:21 am, naos wrote: > Hi all, > > I have problem with foreign key contraint upon calling delete() on my > model. Here's my prob

IntegrityError: foreign key violation upon delete

2010-03-30 Thread naos
Hi all, I have problem with foreign key contraint upon calling delete() on my model. Here's my problem: I have Order and Shipment model. Shipment has a foreign key to Order. class Order(...): ... class Shipment() order = m.ForeignKey('Order') ... Now in one of my views I want do delete

Re: Using Mako as a templating language

2010-03-30 Thread Wayne Koorts
Hi Colin, >>> Or any other templating language that's a bit looser in allowing a bit >>> of logic to mix in with the presentation layer? >> >> http://kid-templating.org/ > > Hasn't kid been superseded by genshi? Firstly I'll say that I hate answers which say "don't try to do what you're doing" as

Re: Using Mako as a templating language

2010-03-30 Thread Masklinn
On 30 mars 2010, at 08:42, Romain Gaches wrote: Le 28 mars 2010 à 18:34, Colin a écrit : Or any other templating language that's a bit looser in allowing a bit of logic to mix in with the presentation layer? http://kid-templating.org/ Hasn't kid been superseded by genshi? -- You receive