PDF response using wkhtmltopdf.

2011-02-16 Thread juanefren
I am using wkhtmltopdf to create PDF files, how ever I don't know how
to return them properly, docs says using a single dash instead of
output file name will write that to stdout. But I don't realize how to
return that content.

I have been trying using subprocess.Popen this way:

r = HttpResponse(Popen(command_args), mimetype='application/pdf')
r['Content-Disposition'] = 'filename=my_file_name.pdf'
return r

But I am not getting the result.

The only way I have managed to work is writting to file system in
media folder, and then redirect to the url based file, but this way
doesn't look good.

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 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.



Model ineritance problem

2009-08-20 Thread juanefren

Having these Models...

class Parent(models.Model):
date = models.DateField()
n = models.IntegerField(default = 0)

class Kind1(Parent):
def total(self):
return cantidad * 3

class Kind2(Parent):
def total(self):
return cantidad * 2

How can I do this ?
for p in Parent.objects.all().order_by('-date'):
print p.total() #this should print self.n * 2  or self.n * 3
depending the case

What I did was:
k1 = Kind1.objects.all().order_by('-date')
k2 = Kind2.objects.all().order_by('-date')
objects = itertools.chain(k1, k2)
for o in objects:
print o.total()

But I think is not a correct solution, what do you think ?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



TemplateSyntaxError

2009-05-28 Thread juanefren

I have created a custom tag to generate select inputs from my database
models it is registered as a simple tag.
Everything is fine, except that I should do this to avoid my problem
is that calling my tag of this way {% combo "model"
instance.property.id  %} raises TemplateSyntaxError when object is
None. right now I should do this:

{% if instance.property %}
{% combo "model" instance.property.id %}
{%else%}
{% combo "model" %}
{%endif%}

Is there a cleaner way to avoid the error ?
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: login_required

2009-03-27 Thread juanefren


Thanks, that corrected the problem, (I was missing import in my ajax
views).

On Mar 12, 6:35 pm, Jacob Kaplan-Moss <jacob.kaplanm...@gmail.com>
wrote:
> On Wed, Mar 11, 2009 at 7:10 PM, juanefren <juanef...@gmail.com> wrote:
> > Few times when I open any page in my site this error appears.
> > Caught an exception while rendering: name 'login_required' is not
> > defined.
>
> Somewhere in your app you're missing an import. Try grepping your
> source for "login_required" and check that every single place you
> reference it you've also imported it.
>
> Jacob
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



login_required

2009-03-11 Thread juanefren

Few times when I open any page in my site this error appears.
Caught an exception while rendering: name 'login_required' is not
defined.
Reloading page solves the problem, and rarely occurs again.
I am using @login_required() over all my functions and imported from
django.contrib.auth.decorators.login_required

Do you have any suggestions ?

Cheers...
--~--~-~--~~~---~--~~
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: TemplateSyntaxError on unicode strings

2009-03-09 Thread juanefren

Thanks for your replies, It worked.

On Mar 8, 6:16 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Sun, 2009-03-08 at 18:01 -0700, juanefren wrote:
> > Right I would mean 1.1 alpha. Looking with more details I found that
> > error only appears when I use my class __str__ method, for example in
> > my Address Class I have
>
> > class MyClass(models.Model):
> >     string1 = models.CharField(max_length = 100, null=True)
> >     string2 = models.CharField(max_length = 100, null=True)
> >     def __str__(self) :
> >         return self.string1  +'  -  ' + self.string2
>
> > If in my template I use {{ myclass.string1 }} -  {{ myclass.string2 }}
> > Works fine. But if I use {{ myclass }} and either string1 or string2
> > has non ascci char, Error appears.
>
> That's expected. The __str__ method is only intended to handle ASCII --
> it returns a Python "str" object, not a "unicode" object. That's a
> Python thing, nothing specific to Django. You should use a __unicode__
> method instead. That's why all the examples in the documentation do
> that, for example.
>
> See also,
>
> http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db
>
> and
>
> http://docs.djangoproject.com/en/dev/ref/unicode/
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TemplateSyntaxError on unicode strings

2009-03-08 Thread juanefren

Right I would mean 1.1 alpha. Looking with more details I found that
error only appears when I use my class __str__ method, for example in
my Address Class I have

class MyClass(models.Model):
string1 = models.CharField(max_length = 100, null=True)
string2 = models.CharField(max_length = 100, null=True)
def __str__(self) :
return self.string1  +'  -  ' + self.string2

If in my template I use {{ myclass.string1 }} -  {{ myclass.string2 }}
Works fine. But if I use {{ myclass }} and either string1 or string2
has non ascci char, Error appears.

It is not correct to use __str__ method ?
Thanks


On Mar 7, 2:05 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Sat, Mar 7, 2009 at 3:07 PM, juanefren <juanef...@gmail.com> wrote:
>
> > I am using django 1.1  and  MYSQL 5.0 with collation utf8_unicode_ci
>
> Django 1.1 doesn't exist yet, so I guess you are either running 1.1 alpha1
> or an SVN trunk checkout.  I doubt the specific version really matters here
> (since full unicode support existed well before 1.0), but it's best to be
> precise on stuff like this, and 1.1 is not, yet, a precise version.
>
>
>
> > I have no problems storing unicode strings to database, but when I try
> > to render a template using any of these chars ñáéíóúÑÁÉÍÓÚ from
> > database, it throws a TemplateSyntaxError, what should I do ?
>
> You should give us more information.  What is the full traceback of the
> error?  Snippets from the bits of the template that are attempting to
> display accented characters might be helpful as well and an explanation of
> what any variables the template is using are.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



TemplateSyntaxError on unicode strings

2009-03-07 Thread juanefren

I am using django 1.1  and  MYSQL 5.0 with collation utf8_unicode_ci

I have no problems storing unicode strings to database, but when I try
to render a template using any of these chars ñáéíóúÑÁÉÍÓÚ from
database, it throws a TemplateSyntaxError, what should I do ?


--~--~-~--~~~---~--~~
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: Change widgets in ModelFormSet

2009-02-03 Thread juanefren

Yes, I missed that possible solution, It worked, Thankyou!

On Jan 30, 6:46 pm, Antoni Aloy  wrote:
> 2009/1/31juanefren:
>
> > I am using modelformset_factory, to show forms and is working good, my
> > question now is, how can I modify widgets created ? (I want to change
> > the size of the html text elements).
>
> Use CSS, javascript o CSS+Javascript. The formeset are generated
> following alwasy the same rules, so you can be sure that id would be
> always the same. Get the id and add a css acording, for exemple.
>
> --
> Antoni Aloy López
> Blog:http://trespams.com
> Site:http://apsl.net
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Change widgets in ModelFormSet

2009-01-30 Thread juanefren

I am using modelformset_factory, to show forms and is working good, my
question now is, how can I modify widgets created ? (I want to change
the size of the html text elements).

This is the documentation about model formsets.
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#id1

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---