Re: upload image with Django

2013-05-25 Thread Gianluca Dileo
Can you show me an example?
With the HttpResponseRedirect are forced to send the information to another 
page.
While I need to display the image (in a window, that the user can close) on 
the same page that contains the form.

Thanks in advance.
GD

Il giorno venerdì 24 maggio 2013 20:27:55 UTC+2, mir ha scritto:
>
> Gianluca Dileo > writes: 
>
> > Hi guy, 
> > I've created a form in a page html that upload a image. 
> > After capturing the image and edit it, I need to have it appear in a 
> window 
> > j 
> > How can i do? 
>
> Does HttpResponseRedirect do what you want to achieve? 
>
>
> Kind regards 
>
> Michael 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




upload image with Django

2013-05-24 Thread Gianluca Dileo
Hi guy,
I've created a form in a page html that upload a image.
After capturing the image and edit it, I need to have it appear in a window 
j
How can i do?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Setup a webserver that handles user input

2012-02-24 Thread Gianluca
Hi!

I was wondering whether Django can be used to setup a webserver that
can handle a user request and send a job to a backend queue.

Specifically, I want to setup a frontend website through which a user
enters the coordinates of protein atoms (a text based PDB file). This
input is then used to perform a Monte Carlo simulation on a backend
linux cluster setup with a queueing system, e.g. openPBS. The result
of the Monte Carlo simulation are then sent back to the user, possibly
per e-mail.

I was wondering whether anybody has had any experience with this kind
of setup.

Thanks in advance!

Gianluca

-- 
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: good django twitter login tutorial

2011-09-26 Thread Gianluca Sforna
On Mon, Sep 26, 2011 at 7:49 PM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> You are kidding, right?
> https://bitbucket.org/david/django-oauth-plus/wiki/Home
> I appreciate you are a total beginner, but come on, get your hands dirty! :)

Are you sure that covers the OP question? I think django-oauth is
useful to create oauth providers; for consumers (like the one he's
trying to build) he needs a client. For that, I found python-oauth2 at
https://github.com/simplegeo/python-oauth2; the readme there has even
an example of authenticating a django app with twitter.

-- 
Gianluca Sforna

http://morefedora.blogspot.com
http://identi.ca/giallu - http://twitter.com/giallu

-- 
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: Weird join conditions

2011-07-02 Thread Gianluca Sforna
On Thu, Jun 30, 2011 at 5:19 PM, peroksid  wrote:

>
> I need to have for the "ON" expression slighlty more complex
> expression, something like
> "left_table.left_column=right_table.right_column AND
> right_table.another_column=42". Method join() obviously  can not be
> used for this purpose because it tuple defining join connection
> consists off 4 elements.
> I suspect there is no way to create such a double join condition at
> all, event without constant involved instead of column.

Maybe you can use F objects to create the correct filters? It would be
something like:

object_list = 
ObjectModel.filter(sometable__leftcolumn=F('right_table__right_column'))

and then you can use Q objects to combine two of them:

q1 = Q(sometable__leftcolumn=F('right_table__right_column'))
q2 = Q(right_table__another_column=42)

object_list = ObjectModel.filter(q1 & q2)

more info at:
https://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-reference-fields-on-the-model
https://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects

-- 
Gianluca Sforna

http://morefedora.blogspot.com
http://identi.ca/giallu - http://twitter.com/giallu

-- 
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: How to setup the django progject to apache2

2011-05-01 Thread Gianluca Sforna
On Sun, May 1, 2011 at 12:41 PM, Steven Han  wrote:
> But every time I run the URL http://127.0.0.1:9000
> it always displays:
>
> "Oops! Google Chrome could not connect to 127.0.0.1:9000 "
>
> :(
> Do you know what I missed ?

This is more an apache question than a django question, however I
think you're missing to let the server actually listen on port 9000.

Try adding a line like:
Listen 9000
outside your virtualhost directive.

See http://httpd.apache.org/docs/2.2/bind.html#virtualhost for details


-- 
Gianluca Sforna

http://morefedora.blogspot.com
http://identi.ca/giallu - http://twitter.com/giallu

-- 
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: Using Q objects vs explicit filters

2011-04-14 Thread Gianluca Sforna
On Thu, Apr 14, 2011 at 11:46 AM, Massimiliano della Rovere
 wrote:
> what about Parent.objects.filter(~q) ?

In [16]: f1 = Parent.objects.filter(~q)

In [17]: print f1.query
SELECT "molserv_parent"."id", "molserv_parent"."name" FROM
"molserv_parent" WHERE NOT ("molserv_parent"."id" IN (SELECT
U1."parent_id" FROM "molserv_child" U1 WHERE (U1."gender" = f  AND
U1."parent_id" IS NOT NULL)))


-- 
Gianluca Sforna

http://morefedora.blogspot.com
http://identi.ca/giallu - http://twitter.com/giallu

-- 
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: Using Q objects vs explicit filters

2011-04-14 Thread Gianluca Sforna
On Wed, Apr 13, 2011 at 3:43 PM, Brian Bouterse  wrote:
> Could you include the output to highlight the differences?

I've just created a simpler test case. I've a couple models like:

class Parent(models.Model):
name = models.CharField(max_length=200, db_index=True)

class Child(models.Model):
parent = models.ForeignKey('Parent')
gender = models.CharField(max_length=1)

Now let's filter them (I'm doing this in the ipython shell):

In [11]: f1 = Parent.objects.filter(child__gender='f')
In [12]: print f1.query
SELECT "molserv_parent"."id", "molserv_parent"."name" FROM
"molserv_parent" INNER JOIN "molserv_child" ON ("molserv_parent"."id"
= "molserv_child"."parent_id") WHERE "molserv_child"."gender" = f

Now the same with a Q object:

In [13]: q = Q(child__gender='f')
In [14]: f2 = Parent.objects.filter(q)
In [15]: print f2.query
SELECT "molserv_parent"."id", "molserv_parent"."name" FROM
"molserv_parent" INNER JOIN "molserv_child" ON ("molserv_parent"."id"
= "molserv_child"."parent_id") WHERE "molserv_child"."gender" = f

So far, so good, they are the same. Now I'll replace filter with exclude:

In [16]: f1 = Parent.objects.exclude(child__gender='f')
In [17]: print f1.query
SELECT "molserv_parent"."id", "molserv_parent"."name" FROM
"molserv_parent" WHERE NOT ("molserv_parent"."id" IN (SELECT
U1."parent_id" FROM "molserv_child" U1 WHERE (U1."gender" = f  AND
U1."parent_id" IS NOT NULL)))

In [18]: f2 = Parent.objects.exclude(q)
In [19]: print f2.query
SELECT "molserv_parent"."id", "molserv_parent"."name" FROM
"molserv_parent" INNER JOIN "molserv_child" ON ("molserv_parent"."id"
= "molserv_child"."parent_id") WHERE NOT ("molserv_child"."gender" = f
)

So only the second (Q based) filter in this case works for me. For the
records, this is with Django 1.2.5 in Fedora 14

-- 
Gianluca Sforna

http://morefedora.blogspot.com
http://identi.ca/giallu - http://twitter.com/giallu

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



Using Q objects vs explicit filters

2011-04-13 Thread Gianluca Sforna
In writing a complex filter for an application, I've found a different
behavior between a filter like:
Model.objects.exclude(filter1, filter2)

and one like:
Model.objects.exclude(Q(filter1), Q(filter2))

where filter1 and filter2 are both field lookups on related models; in
particular only the second syntax yields the desired result set. Are
the above forms supposed to produce comparable queryset?

Thanks in advance

G.


-- 
Gianluca Sforna

http://morefedora.blogspot.com
http://identi.ca/giallu - http://twitter.com/giallu

-- 
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: Django app for data management and visualization

2011-04-05 Thread Gianluca Riccardi


On 5 Apr, 17:06, alessio c  wrote:
> Ciao,

ciao Alessio,

>
> yes I do. I need more basic stuff then that and I need tables. Think of this
> as tentative to reduce Excel use (which is killing me).
>
> I can use matplotlib or openflash if I want to go really fancy. However, now
> I need to set up the framework. After that, I have a platform from which I
> can run all my scripts.
>
> Let's say I have a database with invoice data from different subsidiaries. I
> want to be able to: 1) create different views (subsidiary level, macro
> level, invoice level, first 10 invoice, first 10 customers, etc.); 2) upload
> data from different formats (because people are lazy and it is impossible to
> impose a single format); 3) allow some users to upload data (to avoid them
> to send me excel files by email, this is a huge feature...); 4) allow some
> other users (managers) to access and download online reports (tables and
> graphs).
>
> Theoretically, when I get this right I am hoping to start a project on git.
> The main idea is to create a shared reporting tool.

sounds like your going to have some fun ;) good luck, especially if
you can get rid of dealing with spreadsheets and automate it I'm sure
users will be happier(you at first;)

if You start a public git repo i'd like to read your progresses

regards,
Gianluca Riccardi

-- 
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: Django app for data management and visualization

2011-04-05 Thread Gianluca Riccardi


On 5 Apr, 15:39, alessio c  wrote:
> Hello,
>
> I am thinking about starting a Django app to manage data (I need it
> for financial reporting).
>
> What I am wondering about those days is a way to create an application
> that:
>
> 1) Allows the privileged user to insert a "plug in" that adds a module
> and its views.
>
> 2) Allows the user to add views and "scripts" to an existing model.
>
> The way I think this is a model centric application with different
> views and file uploaders. For me this would be a break out as we use
> to run different reports from the same dataset (just changing the
> grouping, filtering, formulas). I need file uploaders as the same
> model can be populated from different files, organized in different
> ways.
>
> Do you have some aviced on best practices to achieve this? I don't
> want the user to touch the main web site when adding modules and
> views.

Hello,

probably you already know of it http://graphite.wikidot.com/

regards,
Gianluca Riccardi

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



Customize inlines in django admin

2011-02-20 Thread Gianluca Pacchiella
Hi folks,

I have a problem with an admin inline form for a model having a ManyToMany 
field: the default is to
visualize a select having as options all the instances available for that kind 
of model, with a plus button to
create a new one on the fly.

My problem is I want only to add the object created with the popup window and 
not to have the
select with all the other instances and in the change page I only want the 
object instance previously
added and not all the available instances for that kind of model.

Is there any simple way to accomplish this?

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



Problem with restructuredtext filter

2010-02-22 Thread Gianluca Pacchiella
I have written for a personal django app (actually a blog), a new
restructured text role that allows to use TeX syntax and rendering math
formulas; the problem is that I don't want to allow this in comment. To
avoid to load the TeX related role I use the following snippet of code
where I delete the role directly by popping it from roles._role_registry
dictionary



@register.tag(name='restructuredTextWO')
def restructured_text_without(parser, token):
nodelist = parser.parse(('endrestructuredTextWO',))
parser.delete_first_token()

try:
tag_name, role_name = token.contents.split(None, 1)
except ValueError:
raise template.TemplateSyntaxError(
'%r tag requires an argument' % token.contents.split()[0])

return Without(nodelist, role_name)

class Without(template.Node):
def __init__(self, nodelist, role_name):
if settings.DEBUG:
print 'Without', role_name
self.nodelist = nodelist
self.role_name = role_name
self.role_fn = None

def render(self, context):
from docutils.parsers.rst import roles

self.role_fn = roles._role_registry.pop(self.role_name, None)

output = self.nodelist.render(context)

if self.role_fn:
roles._role_registry[self.role_name] = self.role_fn

return output



In the template I have



{{blog.title|capfirst}}

{{blog.creation_date|date:"D d M Y"}}


{{blog.content|restructuredtext}}


Comments

{% get_comment_list for blog as comments %}
{% for comment in comments %}
{% comment_entry comment %}
{% endfor %}



where comment_entry is a inclusion tag defined as



{% load markup %}
{% restructuredTextWO tex %}

posted by {{username}}
at {{date|date:"D d M Y"}}
{{content|restructuredtext}}

{% endrestructuredTextWO %}




Now, the problem is that this doesn't work if also the blog contains the
:tex: role and I don't understand why: there is something I'm missing in
how the template rendering works?

I would appreciate some hints about that.

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



Strange behaviour of FileField in FormWizard

2009-05-15 Thread Gianluca Pacchiella

I implemented a form wizard to import bookmarks from various website
or
from a file: the first form selects the type of the import and, in
case I
want to import from a BibTeX file, the second form is a FileField
where I
have to indicate the path of the file containing the reference to
parse.

In this last case, after submit the file, reappears the last form with
the
error "This field is required." and I don't understand why.

Anyone has hints about this? below the drive-me-crazy code

- 8< 
# forms.py
class ImportFormWizard(FormWizard):
def process_step(self, request, form, step):
if step == 0:
if form.cleaned_data['import_type'] ==
'connotea':
self.form_list[1] = ImportConnoteaForm
elif form.cleaned_data['import_type'] ==
'bibtex':
self.form_list[1] = ImportBibtexForm

def done(self, request, form_list):
form, papers = handle_import(form_list)
return render_to_response(
'article/import.html',
{ 'form': form, 'articles': papers },
context_instance=RequestContext
(request)
)

class ImportMethodForm(Form):
IMPORT_TYPE = (
('connotea','Connotea'),
('bibtex','BibTeX'),
)
import_type = ChoiceField(choices=IMPORT_TYPE)

class ImportConnoteaForm(Form):
username = CharField()
password = CharField(widget=PasswordInput(render_value=False))

class ImportBibtexForm(Form):
bibtex_file = FileField()
- >8 
# urls.py
url(r'^article/import/$', ImportFormWizard([ImportMethodForm,
ImportBibtexForm]), name='import'),
-- 8< ---
# template/wizard.html
{% extends "article/base.html" %}
{% block body %}
Step {{ step }} of {{ step_count }}
{% if form.is_multipart %}

{% else %}

{% endif %}

{{ form }}


{{ previous_fields|safe }}


{% endblock %}
- >8 -

--~--~-~--~~~---~--~~
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: Django books application i18n

2007-07-08 Thread Gianluca

Thanks...but in my case?
I have thought to extends the "change_form.html" generic template. But
how can I refer to a field of my data model? ( book name field for
example)

Thanks.

Joseph Heck ha scritto:

> I think most everything that you'd like to know is detailed out at
> http://www.djangoproject.com/documentation/i18n/
>
> -joe
>
> On 7/6/07, Gianluca <[EMAIL PROTECTED]> wrote:
> >
> > Hello,
> > I'm following the Django tutorial about books application. How can I
> > internationalize this application?
> > For example, how can I internationalize a field name of insert book
> > form?
> > Thanks
> >
> > Gianluca
> >
> >
> > >
> >


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django books application i18n

2007-07-06 Thread Gianluca

Hello,
I'm following the Django tutorial about books application. How can I
internationalize this application?
For example, how can I internationalize a field name of insert book
form?
Thanks

Gianluca


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---