Re: Question about Form Wizard

2008-06-07 Thread Grupo Django

Thank you Andrew, very interesting.
In case of using sessions, maybe it.s possilbe to create an object to
serialize only the data, the same as the hidden fields do. So this way
we can solve a problem,
Example: form = MyForm( serialized_data ) where serialized data is a
dictionary get by form.cleaned_data.
In the example of the e-commerce, instead of serializing the products,
we could serialize the products ids.
At this time, I don't need to leave the form and return later, but
sometimes I have used wizards implemented with sessions. And that's
why I asked the way Form Wizard works.
I don't like the hidden fields options too much because it's easy to
be hacked. The data validated in the first step can easily be changed
in the last one, so at the end of the process, there must be a
validation process again. I do this with sessions, and if the data has
been changed, I redirect the user to a Hacking attempt page.

Now I have to study if it's possible to get back to the previous steps
using Form Wizard, but I think it's not quite clean, and I should
create a new form with custom hidden field to return. Also I have to
check if a validation is done again in the last step, in order to
prevent hacks.

On 7 jun, 01:40, Andrew Ingram <[EMAIL PROTECTED]> wrote:
> I believe the general best practice is that sessions should be viewed as
> a last resort for storing data.
>
> You can store data in a number of places and they each have their
> benefits and drawbacks.
>
> The easiest place to store data is the URL, but storing user-specific
> information in the URL is a huge security risk and also tends to result
> in huge (and ugly) URLs. So this obviously isn't suitable for storing
> form state (especially things like payment processing forms).
>
> The second place might think to store data is in the session, there is
> nothing strictly wrong with this approach but you have to be careful
> about how you'd do it. You wouldn't store a user object in the session
> but rather the user id for retrieval from the database. The session is
> useful but you don't want it to be too big otherwise you incur
> serialization/deserialization overhead which is especially risky in
> clustered server environments.
>
> In the case of multi-stage forms the best place (in most cases) to store
> data between stages is in hidden fields that get POSTed with each stage
> submission, this completely alleviates any session overhead and can even
> let you go forward and backward between stages (assuming the
> implementation allows it, i'm not sure if the FormWizard stuff lets you
> go backwards). You do reach potential problems however if you want the
> user to be able to leave the form and return to it later and continue
> from where they left are.
>
> The solution in this case would be to use the session (or you could
> write the state to the database if you want them to be able to retrieve
> the state even after sessions have expired, but I'd consider this the
> very last option), when you do have to use a session for this (i'm
> thinking things like e-commerce order processes) you want to be careful
> to ensure that the objects involved aren't too deep (you don't want to
> blindly serialize a shopping basket which would in turn serialize all
> the products in the basket and then all the categories for those
> products etc), and you also want to ensure that you take any security
> measures in the format of the session that you would be taking in the
> storage of the final result of the form submission (ie encrypted credit
> card numbers).
>
> The line is always a bit fuzzy, but basically store state in hidden
> fields as a first resort unless you really need to allow the user to
> leave the form in which case store state in a carefully considered
> session object.
>
> - Andrew
>
> Grupo Django wrote:
> > Hi! Just a simple question.
> > The Form Wizard application stores the data hashed in hidden fields.
> > Why not in a session? Why is it better? I just want to learn best
> > practices.
>
> > Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Question about Form Wizard

2008-06-06 Thread Grupo Django

On 7 jun, 00:05, Grupo Django <[EMAIL PROTECTED]> wrote:
> Hi! Just a simple question.
> The Form Wizard application stores the data hashed in hidden fields.
> Why not in a session? Why is it better? I just want to learn best
> practices.
>
> Thank you.

Another question :-)
Can you get back to review the data of the previous steps?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Question about Form Wizard

2008-06-06 Thread Grupo Django

Hi! Just a simple question.
The Form Wizard application stores the data hashed in hidden fields.
Why not in a session? Why is it better? I just want to learn best
practices.

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: About newforms-admin branch

2008-06-02 Thread Grupo Django

On 2 jun, 00:26, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> Grupo Django wrote:
> > When newforms-admin is merged to the trunk, what will happen with all
> > the sites that are currently using the current admin application? It's
> > completely different. Should we change every single project to make
> > them compatible with the newforms-admin version?
>
> Short answer: yes
> Long answer: django is subject to API changes-- a disclaimer that is
> presented when opting to use the development version.
>
> What I'm going to do is when nf-a gets closer, I'll create a branch for
> each project I have that will continue to follow the development version
> of django.
Do you know when nf-a will be close to merge?

Thank you.

>  I can continue to do development on my main branch, and merge changes
> into the newforms-admin branch.
>
> Once django's newforms-admin branch is merged, I'll merge the branches I
> have on my various projects. Code for admin is usually quite short, and
> doesn't take too much effort to get it working. It takes very little
> effort to tweak it.
>
> You won't be forced to update to the latest development version
> immediately after the merge. You can wait until you are comfortable to
> do that.
>
> Hope this is helpful!
>
> Jeff Anderson
>
>  signature.asc
> 1 KDescargar
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



About newforms-admin branch

2008-06-01 Thread Grupo Django

Hello,
I'd like to know the status in the newforms-admin branch, I have seen
the todo list:
http://code.djangoproject.com/query?status=new=assigned=reopened=%7Enfa-blocker=priority

but it would be great the current state (80%,90%...). The reason I'm
starting a new project and newforms admin would suit my current needs,
although I think the merge won't happen this month so I'll probably
use the current admin.

When newforms-admin is merged to the trunk, what will happen with all
the sites that are currently using the current admin application? It's
completely different. Should we change every single project to make
them compatible with the newforms-admin version?

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Custom Q object for Full-text

2008-04-29 Thread Grupo Django

HI,
I'm trying to make a custom Q-like object as Malcolm recommended me. I
have this code:
class FT:
def add_to_query( self, query, used_aliases ):
select={
'rank': "ts_rank_cd(tsv, query, 32)",
}
query.add_extra( select,None,('tsv @@
query',),None,None,None )

and I'm stuck with it. It's hard to understand the Query class
quickly.
I need a sql clause like this:
SELECT * FROM table, plainto_tsquery( %s ) as query WHERE tsv @@
query;
This is the simplest one.
I can't add 'plainto_tsquery( %s )' to extra tables since it renders
the content between double quotes.

Also, I try to use this class like the Q object:
items = Model.objects.filter( FT() )
FT should have a string argument to fill the content inside:
plainto_tsquery( %s )

Problems:
1.- This code fails. I get a TypeError, unpack non-sequence in line
914 of query.py:
arg, value = filter_expr
2.- I don't know how I can add: plainto_tsquery( %s ) to the sql
clause and make it work, it shouldn't be quoted.
3.-How can I pass the content to: plainto_tsquery( %s ) in order to
get: 'plainto_tsquery( 'words I want to search' )?

I'd appreciate your help.

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Templates: 'block' tag with name 'title' appears more than once

2008-04-25 Thread Grupo Django

Hello,

I have this template code:
{% block title %}{% endblock %}


And I get the error: 'block' tag with name 'title' appears more than
once.

What could I do to make this work?

I have this in all my templates:
{% extends index.html %}
{% block title %}Here the title{% endblock %}

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: "clever" fields

2008-04-01 Thread Grupo Django

Yes, of course I know, but it's not suitable for my projects as I need
per row level permissions.


On 1 abr, 07:59, martyn <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Do you know the class Admin, a subclass of your model 
> ?http://www.djangobook.com/en/1.0/appendixB/#cn311
>
> Maybe it could help you.
>
> On 31 mar, 13:46, Grupo Django <[EMAIL PROTECTED]> wrote:
>
> > Hi!
> > I'm trying to create a generic form template for a custom admin zone.
> > I'm doing it this 
> > way:http://www.djangoproject.com/documentation/newforms/#complex-template...
>
> > But I need to modify the output depending of the field type.
> > It's easy to add a javascript calendar in a DateField if you add a
> > custom class to it, but I need to go further.
> > I want to check within the template if the field type is a ImageField,
> > and if True, add:
> > 
> > Thumbnail
> > 
> > 
>
> > The problem here is that I can't determine the field type within the
> > {% for field in form %}{% endfor %} loop.
>
> > I'd like something like this  (this is a simplified version):
>
> > {% for field in form %}
> > {{ field.label_tag }}
> > {{ field }}
> >  
> > {% ifequal field.type 'ImageField' %}
> >   Thumbnail
> >
> >  {% endif %}
> > {% endfor %}
>
> > Is there any workaround to make it work?
>
> > Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Newforms] "clever" fields

2008-03-31 Thread Grupo Django

Hi!
I'm trying to create a generic form template for a custom admin zone.
I'm doing it this way: 
http://www.djangoproject.com/documentation/newforms/#complex-template-output

But I need to modify the output depending of the field type.
It's easy to add a javascript calendar in a DateField if you add a
custom class to it, but I need to go further.
I want to check within the template if the field type is a ImageField,
and if True, add:

Thumbnail



The problem here is that I can't determine the field type within the
{% for field in form %}{% endfor %} loop.

I'd like something like this  (this is a simplified version):

{% for field in form %}
{{ field.label_tag }}
{{ field }}
 
{% ifequal field.type 'ImageField' %}
  Thumbnail
   
 {% endif %}
{% endfor %}

Is there any workaround to make it work?

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Documentation Project [No django directly related]

2008-03-06 Thread Grupo Django



On 6 mar, 01:54, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Wed, Mar 5, 2008 at 3:52 PM, Grupo Django <[EMAIL PROTECTED]> wrote:
> >  These anotations are not 100% real, I've been looking only for a few
> >  hours documentation about them, I don't know all the features of each
> >  system yet.
>
> reST has two advantages:
>
> 1. Django already supports it for auto-generated documentation.
>
> 2. It doesn't go directly to PDF, but it will convert to other useful
> formats that can go to PDF (e.g., LaTeX).
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."

How does Django support it? Is there any application for reSTt?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Documentation Project [No django directly related]

2008-03-05 Thread Grupo Django



On 5 mar, 23:54, Tim Chase <[EMAIL PROTECTED]> wrote:
> > I'm building a complex Web site using Django of course, and I
> > have to start the documentation this week. I'd like some
> > suggestions about this. I want to make the documentation
> > available  through the web and a PDF file.
>
> I've found that there are two over-arching categories of
> documentation:
>
> -developer documentation
> -end user documentation
>
> For the former, rest2html or some other means of extracting
> docstrings is great.  It may not offer PDF, but most developers
> just want accurate, up-to-date, easy to reach information.
> Docstrings do that, and there are tools to export a walk of your
> .py files and emit programming documentation as HTML.  I can't
> say I find this terribly helpful, but some folks like it.  One
> key aspect is that it's intimately tied to the code.
>
> For the end-user documents, you're not tied so closely to the
> code, but rather tied to user-experience/flow.  You can include
> screen-shots, add more hand-holding text, and do other such
> niceties.  For this, something that produces nicer documents is
> in order:  LaTeX and DocBook are the big contenders.  You can
> produce all sorts of output from these (HTML, PDF, PostScript,
> and I understand there are even DocBook->LaTeX or Latex->DocBook
> converters).  As Alex's message notes, you can use HTML->PDF
> converters.  Personally, I merely tolerate PDF and much prefer
> HTML, so it's my first choice of documentation medium.
>
> I've found mind-mapping software (many are available, but I've
> taken to Vym[1]) helpful for organizing out the user
> documentation.  Some even have an export-to-$FORMAT
> functionality, such as Vym's direct-to-HTML output.  It also
> supports direct-to-LaTeX, and since the file-format is just
> zipped XML (plus supporting files), it wouldn't be too hard to
> write an XSLT template to remap it to DocBook too.
>
> -tim
>
> [1]http://www.insilmaril.de/vym/

In my case it's end-user documentation, with a lot of screenshots. I
think I'll give docbook a try, or maybe Latex, not sure right now.
Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Documentation Project [No django directly related]

2008-03-05 Thread Grupo Django

Hello, this is not directly related to django, but I'm pretty sure
someone could help me here.
I'm building a complex Web site using Django of course, and I have to
start the documentation this week.
I'd like some suggestions about this.
I want to make the documentation available  through the web and a PDF
file. Ususally I use OpenOffice for this task, because I don't need
publish on the web.
I think OO is not the best option here because it's not easy
synchronize the OO document with the web.
I've been looking for alternatives, and I found three:
These anotations are not 100% real, I've been looking only for a few
hours documentation about them, I don't know all the features of each
system yet.
* DocBook:
- Pros: Export to html and PDF
- Cons: Complex and complicated, exporting would require a lot of
work in the templates
* rest2web:
- Pros: Simple
- Cons: No PDF exporting
* Trac:
- Pros: I already use Trac for the tickets, and the wiki is very
usefull
- Cons: No PDF exporting.

What would you recommend me? I'm thinking about DocBook, but I'm
reluctant because is complicated and I don't know if I can easily
create a good template for the web and PDF and a combination of OO and
Trac would be hard to maintain as it need to be synchronized.

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Optimizing code for a query

2008-03-05 Thread Grupo Django

On 5 mar, 12:02, Grupo Django <[EMAIL PROTECTED]> wrote:
> On 5 mar, 11:25, Evert Rol <[EMAIL PROTECTED]> wrote:
>
>
>
> > >>> I need to optimize some code related to django db api.
> > >>> Imagine a model like this:
>
> > >>> class Languages( models.Model ):
> > >>>   name = models.CharField( max_length=255 )
> > >>>   ...
>
> > >>> class Object ( models.Model ):
> > >>>   name = models.CharField( max_length=255 )
> > >>>   languages = models.ManyToManyField( Languages, radio_admin=True )
>
> > >>> I need to create a form to search Objects:
> > >>> def my_view(request):
> > >>>   ...
> > >>>   if request.POST:
> > >>>   form = MyForm( request.POST )
> > >>>   if form.is_valid():
> > >>>   data = form.cleaned_data
> > >>>   objects = Object.objects.all()
> > >>>   if data['name']:
> > >>>   objects = objects.filter( name__icontains =
> > >>> data['name'] )
> > >>>   if data['languages']:
> > >>>   (1)
> > >>>   ...
>
> > >>> I need to search an Object with name ILIKE %name% and with the
> > >>> languages specified in the form. data['languages'] looks like:
> > >>> [ u'1',u'2' ] the IDs of each language.
>
> > >>> I needs some help with the code that should be placed in (1).
> > >>> I thought:
> > >>> 
> > >>> for language in languages:
> > >>>   objects = Object.filter( languages__id = language)
>
> > >> Have a look at 'in' 
> > >> filtering:http://www.djangoproject.com/documentation/db-api/#in
> > >> Maybe that can help you out. The code above is certainly not going to
> > >> work, because you try on the model, not the results returned from the
> > >> managaer. Besides, you'd be filtering in an 'AND' combination, not
> > >> 'OR'
>
> > > I can't use IN because it returns an Object that has any of the
> > > languages requested.
>
> > Sorry, then I missed what you're trying to achieve; I guessed you
> > wanted to have all languages specified by the form (shouldn't 'IN'
> > return that?), and you can then filter those on the name by appending
> > a .filter() to the returned QuerySet.
> > At least, that's what I thought you wanted and would work.
>
> > > The SQL clause I need is:
> > > select DISTINCT ... from app_object_languages as m2m INNER JOIN
> > > app_object as ob ON ob.id = m2m.object_id where ( m2m.language_id=1 or
> > > m2m.language_id=2);
>
> > > I can't get it!
> > > Thank you for your help.
>
> Well, my English is far from perfect, and I'm not really sure what you
> mean, but what I want is to retrieve all the objects that have the
> lenguages of the form.
> i.e.
> There are 2 languages in the model Language: English and Spanish.
> o1 is an object with two relations to languages English and Spanish
> 02 is an object with only one relation to language English
> I need to get all the Objects that have English and Spanish, so only
> o1 should be retrieved.
> I hope this is clearer, sorry about the misunderstanding, sometimes
> it's hard to say what I think :-)
> Thank you.

I think I solved the problem:
for language in data['languages']:
objects = objects.extra(where=["EXISTS ( SELECT 0 FROM
app_object_languages as m2m WHERE m2m.object_id = app_object.id AND
m2m.language_id = %s )",], params=[ idioma ])

Thank you for your help.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Optimizing code for a query

2008-03-05 Thread Grupo Django



On 5 mar, 11:25, Evert Rol <[EMAIL PROTECTED]> wrote:
> >>> I need to optimize some code related to django db api.
> >>> Imagine a model like this:
>
> >>> class Languages( models.Model ):
> >>>   name = models.CharField( max_length=255 )
> >>>   ...
>
> >>> class Object ( models.Model ):
> >>>   name = models.CharField( max_length=255 )
> >>>   languages = models.ManyToManyField( Languages, radio_admin=True )
>
> >>> I need to create a form to search Objects:
> >>> def my_view(request):
> >>>   ...
> >>>   if request.POST:
> >>>   form = MyForm( request.POST )
> >>>   if form.is_valid():
> >>>   data = form.cleaned_data
> >>>   objects = Object.objects.all()
> >>>   if data['name']:
> >>>   objects = objects.filter( name__icontains =
> >>> data['name'] )
> >>>   if data['languages']:
> >>>   (1)
> >>>   ...
>
> >>> I need to search an Object with name ILIKE %name% and with the
> >>> languages specified in the form. data['languages'] looks like:
> >>> [ u'1',u'2' ] the IDs of each language.
>
> >>> I needs some help with the code that should be placed in (1).
> >>> I thought:
> >>> 
> >>> for language in languages:
> >>>   objects = Object.filter( languages__id = language)
>
> >> Have a look at 'in' 
> >> filtering:http://www.djangoproject.com/documentation/db-api/#in
> >> Maybe that can help you out. The code above is certainly not going to
> >> work, because you try on the model, not the results returned from the
> >> managaer. Besides, you'd be filtering in an 'AND' combination, not
> >> 'OR'
>
> > I can't use IN because it returns an Object that has any of the
> > languages requested.
>
> Sorry, then I missed what you're trying to achieve; I guessed you
> wanted to have all languages specified by the form (shouldn't 'IN'
> return that?), and you can then filter those on the name by appending
> a .filter() to the returned QuerySet.
> At least, that's what I thought you wanted and would work.
>
> > The SQL clause I need is:
> > select DISTINCT ... from app_object_languages as m2m INNER JOIN
> > app_object as ob ON ob.id = m2m.object_id where ( m2m.language_id=1 or
> > m2m.language_id=2);
>
> > I can't get it!
> > Thank you for your help.

Well, my English is far from perfect, and I'm not really sure what you
mean, but what I want is to retrieve all the objects that have the
lenguages of the form.
i.e.
There are 2 languages in the model Language: English and Spanish.
o1 is an object with two relations to languages English and Spanish
02 is an object with only one relation to language English
I need to get all the Objects that have English and Spanish, so only
o1 should be retrieved.
I hope this is clearer, sorry about the misunderstanding, sometimes
it's hard to say what I think :-)
Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Optimizing code for a query

2008-03-05 Thread Grupo Django

On 5 mar, 10:52, Grupo Django <[EMAIL PROTECTED]> wrote:
> On 4 mar, 11:40, Evert Rol <[EMAIL PROTECTED]> wrote:
>
>
>
> > > I need to optimize some code related to django db api.
> > > Imagine a model like this:
>
> > > class Languages( models.Model ):
> > >name = models.CharField( max_length=255 )
> > >...
>
> > > class Object ( models.Model ):
> > >name = models.CharField( max_length=255 )
> > >languages = models.ManyToManyField( Languages, radio_admin=True )
>
> > > I need to create a form to search Objects:
> > > def my_view(request):
> > >...
> > >if request.POST:
> > >form = MyForm( request.POST )
> > >if form.is_valid():
> > >data = form.cleaned_data
> > >objects = Object.objects.all()
> > >if data['name']:
> > >objects = objects.filter( name__icontains =
> > > data['name'] )
> > >if data['languages']:
> > >(1)
> > >...
>
> > > I need to search an Object with name ILIKE %name% and with the
> > > languages specified in the form. data['languages'] looks like:
> > > [ u'1',u'2' ] the IDs of each language.
>
> > > I needs some help with the code that should be placed in (1).
> > > I thought:
> > > 
> > > for language in languages:
> > >objects = Object.filter( languages__id = language)
>
> > Have a look at 'in' 
> > filtering:http://www.djangoproject.com/documentation/db-api/#in
> > Maybe that can help you out. The code above is certainly not going to
> > work, because you try on the model, not the results returned from the
> > managaer. Besides, you'd be filtering in an 'AND' combination, not 'OR'
>
> I can't use IN because it returns an Object that has any of the
> languages requested.
> The SQL clause I need is:
> select DISTINCT ... from app_object_languages as m2m INNER JOIN
> app_object as ob ON ob.id = m2m.object_id where ( m2m.language_id=1 or
> m2m.language_id=2);
>
> I can't get it!
> Thank you for your help.

The SQL clause I wrote above is not valid. I messed it up sorry. I'm
gonna try to relax myself and open my mind :-)
Any suggestion is  appreciated.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Optimizing code for a query

2008-03-05 Thread Grupo Django

On 4 mar, 11:40, Evert Rol <[EMAIL PROTECTED]> wrote:
> > I need to optimize some code related to django db api.
> > Imagine a model like this:
>
> > class Languages( models.Model ):
> >name = models.CharField( max_length=255 )
> >...
>
> > class Object ( models.Model ):
> >name = models.CharField( max_length=255 )
> >languages = models.ManyToManyField( Languages, radio_admin=True )
>
> > I need to create a form to search Objects:
> > def my_view(request):
> >...
> >if request.POST:
> >form = MyForm( request.POST )
> >if form.is_valid():
> >data = form.cleaned_data
> >objects = Object.objects.all()
> >if data['name']:
> >objects = objects.filter( name__icontains =
> > data['name'] )
> >if data['languages']:
> >(1)
> >...
>
> > I need to search an Object with name ILIKE %name% and with the
> > languages specified in the form. data['languages'] looks like:
> > [ u'1',u'2' ] the IDs of each language.
>
> > I needs some help with the code that should be placed in (1).
> > I thought:
> > 
> > for language in languages:
> >objects = Object.filter( languages__id = language)
>
> Have a look at 'in' 
> filtering:http://www.djangoproject.com/documentation/db-api/#in
> Maybe that can help you out. The code above is certainly not going to
> work, because you try on the model, not the results returned from the
> managaer. Besides, you'd be filtering in an 'AND' combination, not 'OR'

I can't use IN because it returns an Object that has any of the
languages requested.
The SQL clause I need is:
select DISTINCT ... from app_object_languages as m2m INNER JOIN
app_object as ob ON ob.id = m2m.object_id where ( m2m.language_id=1 or
m2m.language_id=2);

I can't get it!
Thank you for your help.

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



Re: Optimizing code for a query

2008-03-04 Thread Grupo Django

This code:

for language in languages:
objects = Object.filter( languages__id = language)

doesn't work, so I'd be happy to receive some suggestions.

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Optimizing code for a query

2008-03-04 Thread Grupo Django

Hi,
I need to optimize some code related to django db api.
Imagine a model like this:

class Languages( models.Model ):
name = models.CharField( max_length=255 )
...

class Object ( models.Model ):
name = models.CharField( max_length=255 )
languages = models.ManyToManyField( Languages, radio_admin=True )

I need to create a form to search Objects:
def my_view(request):
...
if request.POST:
form = MyForm( request.POST )
if form.is_valid():
data = form.cleaned_data
objects = Object.objects.all()
if data['name']:
objects = objects.filter( name__icontains =
data['name'] )
if data['languages']:
(1)
...

I need to search an Object with name ILIKE %name% and with the
languages specified in the form. data['languages'] looks like:
[ u'1',u'2' ] the IDs of each language.

I needs some help with the code that should be placed in (1).
I thought:

for language in languages:
objects = Object.filter( languages__id = language)

Is this code good or there is a better solution?
Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Cache problem with language

2008-02-02 Thread Grupo Django

Hello, I'm having a problem using the cache system with different
languages.
I have used the vary_on_cookie decorator in my view:

@vary_on_cookie
@cache_page(60 * 60 * 12)
def my_view(request):
...


I've even test with:
@vary_on_headers('Cookie')

and:

my_view = vary_on_headers(my_view, 'Cookie')

but not working at all. the cache doesn't difference the language.
Any idea?

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Apache & lighthttpd configuration

2008-01-24 Thread Grupo Django

Hello, I need some help to set up an apache+lighthttpd server.
Now I have an apache server serving everything, including the media,
but I'd like to follow the suggestions of the documentation and serve
the media throught lighthttpd.
I only have one server so I must run apache and lighthttpd in the same
machine.
How can I configure the site for serving media through lighthttpd?

My first idea was using apache as a proxy and redirect the traffic
from /media to the lighthttpd server. But I'm not still very convinced
about this way.

Any suggestion?

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Internationalization

2008-01-16 Thread Grupo Django

On 16 ene, 22:21, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> > Hi! Here I answer your questions:
> > I don't have the translations anywhere right now, I'd like to have
> > them in the po file. The menus don't change often, this is the reason
> > I think that it's better to keep translations in the po file (if
> > possilbe)
> > I don't have translations in the db.
>
> In that case the answer is really simple! This is a regular i18n
> usecase.
>
> 1. At the top of your template tags file add this import:
>
> from django.utils.translation import ugettext as _
>
> 2. In the template tags file, change this line:
>
> salida += u"\t
> %s\n" %( entrada.enlace, entrada.nombre, entrada.nombre )
>
> to this:
>
> salida += u"\t
> %s\n" %(_(entrada.enlace), _(entrada.nombre), _(entrada.nombre))
>
> 3. Lastly, in your .po file, add your translations by hand. For
> example:
>
> msgid "DB Text String"
> msgstr "Translated Text String"
>
> msgid "DB Text String2"
> msgstr "Translated Text String2"
>
> and so on...
>
> Then, follow instructions in the i18n Django docs to compile that .po
> file and restart your server.http://www.djangoproject.com/documentation/i18n/
>
> -Rajesh D

Thank you very much for your help! I was a bit lost with this stuff.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Internationalization

2008-01-16 Thread Grupo Django

On 16 ene, 21:35, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi again,
>
> Please see some questions below:
>
>
>
> > This is the function, I'm sorry it's written in Spanish but I think
> > you can understan what I'm saying
>
> > def items(bloque, padre):
> > if padre == 0:
> > entradasMenu =
> > bloque.menu_set.filter(padre__isnull = True,
> > visible=True).order_by('orden')
> > else:
> > entradasMenu = bloque.menu_set.filter(padre =
> > padre,visible=True).order_by('orden')
> > salida=""
> > if entradasMenu:
> > for entrada in entradasMenu:
> > (1)->>>   salida += u"\t
> > %s\n" %( entrada.enlace, entrada.nombre, entrada.nombre )
>
> Where do you keep the translations for entrada.enlace, entrada.nombre,
> entrada.nombre? Are they in a DB? If so, what's the model in which
> they are stored? Do these menus change often? If you had the language
> code available in this templatetag function, would you be able to
> fetch the correct translations from the DB?

Hi! Here I answer your questions:
I don't have the translations anywhere right now, I'd like to have
them in the po file. The menus don't change often, this is the reason
I think that it's better to keep translations in the po file (if
possilbe)
I don't have translations in the db.

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



Re: Internationalization

2008-01-16 Thread Grupo Django

On 16 ene, 20:59, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi,
>
> > I have a Menu app that takes data from the database and renders it
> > into a template. I was wondering if I can translate the output from
> > the database. There are only a few entries.
> > Can I add the text that the menu will render that is stored in the db
> > and add it to the .po file?
> > How can I do it?
>
> I am assuming that you mean "how can I add the language translations
> from the DB to the .po file dynamically?". That's complicated by the
> fact that adding to the .po file is not enough -- you will need to
> compile the .po file and restart the Django application. Translations
> get loaded only once when the application/server process starts up.
>
> If your menu doesn't change at all, you could just add the
> translations to the .po file manually :)
>
> Otherwise, something simple like the following will allow you to get
> dynamic translations:
>
> In your view that renders the menu, grab the value of
> request.LANGUAGE_CODE and fetch your menu items from the DB based on
> that language code. Then, send the menu items to your template. You
> will need to include LocaleMiddleware for this to work as described
> here:
>
> http://www.djangoproject.com/documentation/i18n/
>
> If you're not rendering your menus through a view, let us know how
> you're doing it and there's probably a way to use the above solution
> with it (middleware, templatetags, ...)
>
> -Rajesh D

I'm rendering the menu through templatetags, The output is a unordered
list (without the first ul) like this:

   Category 1
   
  Subcategory1
  Subcategory2
   

so what I need to translate Category 1, Subcategory1...
The list is built using a recursive function, and all the texts come
from the db.
This is the function, I'm sorry it's written in Spanish but I think
you can understan what I'm saying

def items(bloque, padre):
if padre == 0:
entradasMenu =
bloque.menu_set.filter(padre__isnull = True,
visible=True).order_by('orden')
else:
entradasMenu = bloque.menu_set.filter(padre =
padre,visible=True).order_by('orden')
salida=""
if entradasMenu:
for entrada in entradasMenu:
(1)->>>   salida += u"\t
%s\n" %( entrada.enlace, entrada.nombre, entrada.nombre )
#Si no tiene hijos cierro el li y si
no los meto aqui
tmp = items (bloque, entrada.id)
if tmp !="":
salida += u"%s" %
( tmp, )
salida += u""
return salida

In the line (1) is where the translation should be done.

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Internationalization

2008-01-15 Thread Grupo Django

I have a Menu app that takes data from the database and renders it
into a template. I was wondering if I can translate the output from
the database. There are only a few entries.
Can I add the text that the menu will render that is stored in the db
and add it to the .po file?
How can I do it?
Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: How it's ugettext_noop() used?

2008-01-15 Thread Grupo Django

On 15 ene, 10:40, Simon Rivada <[EMAIL PROTECTED]> wrote:
> To quote the documentation
> (http://www.djangoproject.com/documentation/i18n/) on this one:
> Use the function django.utils.translation.ugettext_noop() to mark a
> string as a translation string without translating it. The string is
> later translated from a variable.
>
> Use this if you have constant strings that should be stored in the
> source language because they are exchanged over systems or users -- such
> as strings in a database -- but should be translated at the last possible
> point in time, such as when the string is presented to the user.
>
> Grupo Django wrote:
> > I can't understand how django.utils.translation.ugettext_noop() is
> > used for translation, could someone give me an example please?
>
> > Thank you!

Yes I read that, but still I don't know how to use it correctly,
that's why I wrote here.
Thank you anyway.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How it's ugettext_noop() used?

2008-01-15 Thread Grupo Django

I can't understand how django.utils.translation.ugettext_noop() is
used for translation, could someone give me an example please?

Thank you!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Multilingual text in db

2008-01-14 Thread Grupo Django

On 13 ene, 01:24, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Jan 12, 2008 11:04 PM, Grupo Django <[EMAIL PROTECTED]> wrote:
>
>
>
> > IMHO Internationalization is useless if there is no support for
> > multilingual translations in the database. I've seen different
> > approaches like Django Multilingual 
> > (http://code.google.com/p/django-multilingual/
> > ) and transdb (http://code.google.com/p/transdb/), but I have no
> > idea which I should use if I should use one of those. Is there any
> > plan to include this feature before django 1.0? I think this is the
> > biggest lack in the django framework, and it's a very important
> > problem especially for non English speakers.
>
> I18n of the database isn't on the v1.0 plan.
>
> The fact that there are multiple approaches should give you a hint as
> to why this is the case - there isn't a consensus on how the problem
> can be solved in a generic fashion (or even if it can be solved in a
> generic fashion at all). The needs for a content i18n system will
> depend very much on your own local site requirements.
>
> Yours,
> Russ Magee %-)

Is there any place where I can find a discussion about this? I'm
really interested in this feature.
I'd like to help as much as I can.

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Problem subclassing forms

2007-11-27 Thread Grupo Django

Hello, it seems that when I create this code, doesn't work as
expected.

baseForm = forms.form_for_model( MyModel )
class Form ( baseForm ):
extra_field = forms.CharField()

I'd like to have the fields defined in MyModel and add the
extra_field, but it doesn't work.
Besides, I'd like to have a clear example about how to use the forms
with files (FileField or ImageField)

Thank you very much.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Complicated question

2007-11-20 Thread Grupo Django

On 20 nov, 21:54, RajeshD <[EMAIL PROTECTED]> wrote:
> > That's interesting, but I think that leaving the models untouched
> > would be better.
> > Do you think there is a different way?
>
> There might be. First, you'd have to explain what you didn't like
> about doing queries like:
>
> Image.objects.filter( book__library_owner=request.user)
>
> Since you don't want to change your models, only your Library model
> maintains the source of ownership and so, by definition, all your
> queries would have to lead to a check on the Library.owner field
> thereby ending up with filters like xyz__library_owner=some_user.

Is not that I don't want to use:
Image.objects.filter( book__library_owner=request.user)
but I can't use it if I want to create a generic funtion, because
depending of the distance from the model to the model who has the
owner field, it can be:
Image.objects.filter( book__library_owner=request.user) or
Book.objects.filter( library_owner=request.user)
I pass the module to the function:
very roughly:
def list_items_by_owner( module, parent_id ):
for field in module._meta.fields:
 if field.name == 'owner':
 return True
for field in module._meta.fields:
   if field.rel and not field.null:
   parent = field.rel.to
   new_parent_id
   out = list_items_by_owner( parent,  new_parent_id)
   ...

Anyway, what I'm trying to get is quite complicated and the code above
is not correct at all, it was only for trying to explain what I want.
I think I need somethig similar to django.db.query.fill_table_cache
but I'm not sure.

This could be used as a row-level permissions. it has some
inconvenient because depending on the number of ForeignKeys, the
recursive function might take longer.

I'm pretty sure I didn't explain myself clear, I do my best :-)

Thank you.


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



Re: Complicated question

2007-11-20 Thread Grupo Django

RajeshD ha escrito:
> From what I understand, you want a generic ability to declare an owner
> item for any model object.
>
> Django's generic relations work that way. Take a look at the examples
> here:
>
> http://www.djangoproject.com/documentation/models/generic_relations/
>
> Specially, instead of TaggedItem in that example, you could have an
> ObjectOwner model class. And instead of TaggedItem.tag you would have
> TaggedItem.owner_user
>
> Your other objects will not need an owner field anymore. They would be
> like the Mineral class in the example linked above.
>
> Hope this gives you a starting point.

That's interesting, but I think that leaving the models untouched
would be better.
Do you think there is a different way?
Thank you!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Complicated question

2007-11-20 Thread Grupo Django

On 20 nov, 20:46, RajeshD <[EMAIL PROTECTED]> wrote:
> From what I understand, you want a generic ability to declare an owner
> item for any model object.
>
> Django's generic relations work that way. Take a look at the examples
> here:
>
> http://www.djangoproject.com/documentation/models/generic_relations/
>
> Specially, instead of TaggedItem in that example, you could have an
> ObjectOwner model class. And instead of TaggedItem.tag you would have
> TaggedItem.owner_user
>
> Your other objects will not need an owner field anymore. They would be
> like the Mineral class in the example linked above.
>
> Hope this gives you a starting point.

That's interesting, but I think it would be better to leave the models
untouched would be better.
Do you think there is a different way?
Thank you!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Complicated question

2007-11-20 Thread Grupo Django

Hello, I'm programing a kind of admin zone for users, where users can
add, manage and delete objects.
I want to do it generic, but I have a big problem now.
Imagine these models:

from django.contrib.auth.models import User
class Library ( models.model ):
library_name = models.CharField(..)
owner = models.ForeignKey( User )

class Book( models.model ):
library = models.ForeignKey( Library )
title = models.CharField(...)

class Image ( models.model ):
front_page = models.ImageField(..)
book = models.ForeignKey( Book )

What I want is a function wich returns the class that have the field
owner, populating the fields tables and where to use it with the extra
method of the object. I have seen fill_table_cache in query.py, but I
don't really understand how it works and if it's suitable for my
needs.
I need it because I want to show only the images that belong to an
user, so I need to make something similar to:
images = Image.objects.filter( book__library_owner = request.user )
I started the recursive function but I almost got crazy and this
morning I deleted everything. As I'd like to do it general, It should
work for diferent models at diferents levels of distance from classes.
i.e.
words = Word.objects.filter( page__book__library__owner =
request.user ) or
libraries =Library.objects.filter( owner = request.user )

Do you have any suggestions?

Thank you very much.

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



Re: Dynamically load objects

2007-11-17 Thread Grupo Django



On 17 nov, 01:28, "Ramiro Morales" <[EMAIL PROTECTED]> wrote:
> On Nov 16, 2007 8:18 PM, Grupo Django <[EMAIL PROTECTED]> wrote:
>
>
>
> > Thanks a lot! get _model works.
> > Only one thing, I've been reading the code in te file django/db/models/
> > loading.py and I don't understand how it works, and now I need to know
> > or I won't sleep :-)
>
> > What should I do to reference stuff?
>
> > app = __import__('app_name',{},{},['models'])
> > mods = getattr(app,'models')
> > module = getattr(mods,'ModuleIWant')
>
> > This actually works, but I'm not sure if it's the right way or the
> > "python way".
>
> Do you want to reimplement or do you want to use
> get_model()?. If the answer is the latter you might
> find this article helpful:
>
> http://www.b-list.org/weblog/2007/nov/03/working-models/
>
> Regards,
>
> --
>  Ramiro Morales
I'm using get_model, I just wanted to learn how it works. and if the
code I wrote was ok.
Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Permissions for generic modules

2007-11-16 Thread Grupo Django

I figured out this code to get the permissions of a dynamic module:

def my_view( request ):
...
app_label = module._meta.app_label
add_p = app_label+'.'+module._meta.get_add_permission()
chg_p = app_label+'.'+module._meta.get_change_permission()
del_p = app_label+'.'+module._meta.get_delete_permission()
perm_add = request.user.has_perm( add_p )
perm_chg = request.user.has_perm( chg_p )
perm_del = request.user.has_perm( del_p )

But I think this is ugly, and I'm pretty sure there is a better way
that I can't see now.
Any sugestion?

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



Re: Dynamically load objects

2007-11-16 Thread Grupo Django

Thanks a lot! get _model works.
Only one thing, I've been reading the code in te file django/db/models/
loading.py and I don't understand how it works, and now I need to know
or I won't sleep :-)

What should I do to reference stuff?

app = __import__('app_name',{},{},['models'])
mods = getattr(app,'models')
module = getattr(mods,'ModuleIWant')

This actually works, but I'm not sure if it's the right way or the
"python way".

Thanks.


On 16 nov, 20:56, Doug B <[EMAIL PROTECTED]> wrote:
> I'd love to know if there is a better method, but this is the best I
> could come up with... pretty much the same thing you are doing, but
> forcing the view functions to call 'import_feed' which can only load a
> restricted set of modules.
>
> AVAILABLE_FEEDS =
> {'columbia':'columbia.search','glvar':'glvar.search'}
>
> def import_feed(name):
> if name in AVAILABLE_FEEDS:
> return __import__(AVAILABLE_FEEDS[name])
> else:
> return None
>
> That only gets me the app, so if I do
> feed=import_feed('columbia')
> I still have to reference stuff like feed.search.myfunction() instead
> of feed.myfunction()
>
> Hmm.. now that I reread your post, I might have confused module with
> model.  If so you might want to take a look at:
> from django.db.models.get_model
>
> m=get_model(appname,modelname)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Dynamically load objects

2007-11-16 Thread Grupo Django

Hello,
In a view, I have:
from app.models import something

def my_view( request, mod_name ):
   m = __import__('app.models',globals(),locals(),['something'] )

Now I'd like to do:
   items = m.filter( ... )
   for item in items:
   ...

What I need is to load a model dynamically and then use it.
Well, I think this is  very insecure, and I'd like you to give me a
different approach.
Anyway, If I'd like to do it this way, how could I do it, just for
learning purposes.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Reutilizing views

2007-08-29 Thread Grupo Django

You are right, entrada is front door, but front page is portada, the
front page of a magazine or a newspaper is called portada, and the
entrance or front door of a house entrada :-)

On 29 ago, 15:39, Etienne Robillard <[EMAIL PROTECTED]>
wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> You're welcome, and thanks for the Spanish tip..
>
> (I thought entrada was the appropriate word for front door,
> but my Spanish skills arent very sharp..)
>
> Have to go catch a bus now.. =]
>
> Gracias,
> Etienne
>
> On Wed, 29 Aug 2007 05:45:41 -0700
>
>
>
> Grupo Django <[EMAIL PROTECTED]> wrote:
>
> > Thanks Etienne!
> > By the way, the minus sign in the view was a mistake, I wanted to
> > write front_page. Anyway, it was just an example, in my case, the view
> > is called 'portada' = 'front page' in Spanish :-)
>
> > Thanks.
>
> > On 29 ago, 14:30, Etienne Robillard <[EMAIL PROTECTED]>
> > wrote:
> > > -BEGIN PGP SIGNED MESSAGE-
> > > Hash: SHA1
>
> > > Hi Grupo,
>
> > > I think it would be better not using the minus sign for naming your
> > > front page function. Also, dont put weird attributes directly in a view,
> > > but instead use a dictionary in your urls.py (read "Passing extra options 
> > > to view
> > > functions in url_dispatch.txt).
>
> > > Here's a quick rewrite for the records:
>
> > > def myview(request, *args, **kwargs):
> > > if kwargs['returnHttp']:
> > ># do stuff here
> > >...
>
> > > Cheers,
>
> > > Etienne
>
> > > On Wed, 29 Aug 2007 04:09:42 -0700
>
> > > Grupo Django <[EMAIL PROTECTED]> wrote:
>
> > > > Hello, I'd like to know if there is some way for reutilizing a view.
>
> > > > In my case, I have an application to show some data, but I want to
> > > > show the same data in the front page, among other data from other
> > > > models.
> > > > Well, I have figured out this method:
>
> > > > def myview(request, returnHTTP=True):
> > > > t = loader.get_template('template.html')
> > > > ...
> > > > c = RequestContext(request,{ 'data':data })
> > > > if returnHTTP:
> > > > return HttpResponse(t.render(c))
> > > > else:
> > > > return data
>
> > > > and in the view of the front page:
>
> > > > def front-page(request):
> > > > from someApp.views import myview
> > > > data = myview(request,False)
>
> > > > Is this ok? Perhaps there is a better way of doing it with django.
> > > > Thank you very much.
>
> > > -BEGIN PGP SIGNATURE-
> > > Version: GnuPG v2.0.5 (FreeBSD)
>
> > > iEYEARECAAYFAkbVZvUACgkQdXKAffkXj4MQ/ACfT+ZbiErc/hgzo3wnJWvn/za8
> > > QLkAn3PJ0GeB0E47KRR9phbMgotv6F2t
> > > =ayKi
> > > -END PGP SIGNATURE-
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2.0.5 (FreeBSD)
>
> iEYEARECAAYFAkbVdyUACgkQdXKAffkXj4NceQCfQ/r5hqK8YgkQ64f18oVteZkC
> IUkAnRnSIAQP6hafuf0nK0TE/Kcj9vRy
> =eQft
> -END PGP SIGNATURE-


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



Re: Reutilizing views

2007-08-29 Thread Grupo Django

Thanks Etienne!
By the way, the minus sign in the view was a mistake, I wanted to
write front_page. Anyway, it was just an example, in my case, the view
is called 'portada' = 'front page' in Spanish :-)

Thanks.

On 29 ago, 14:30, Etienne Robillard <[EMAIL PROTECTED]>
wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hi Grupo,
>
> I think it would be better not using the minus sign for naming your
> front page function. Also, dont put weird attributes directly in a view,
> but instead use a dictionary in your urls.py (read "Passing extra options to 
> view
> functions in url_dispatch.txt).
>
> Here's a quick rewrite for the records:
>
> def myview(request, *args, **kwargs):
> if kwargs['returnHttp']:
># do stuff here
>...
>
> Cheers,
>
> Etienne
>
> On Wed, 29 Aug 2007 04:09:42 -0700
>
>
>
> Grupo Django <[EMAIL PROTECTED]> wrote:
>
> > Hello, I'd like to know if there is some way for reutilizing a view.
>
> > In my case, I have an application to show some data, but I want to
> > show the same data in the front page, among other data from other
> > models.
> > Well, I have figured out this method:
>
> > def myview(request, returnHTTP=True):
> > t = loader.get_template('template.html')
> > ...
> > c = RequestContext(request,{ 'data':data })
> > if returnHTTP:
> > return HttpResponse(t.render(c))
> > else:
> > return data
>
> > and in the view of the front page:
>
> > def front-page(request):
> > from someApp.views import myview
> > data = myview(request,False)
>
> > Is this ok? Perhaps there is a better way of doing it with django.
> > Thank you very much.
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2.0.5 (FreeBSD)
>
> iEYEARECAAYFAkbVZvUACgkQdXKAffkXj4MQ/ACfT+ZbiErc/hgzo3wnJWvn/za8
> QLkAn3PJ0GeB0E47KRR9phbMgotv6F2t
> =ayKi
> -END PGP SIGNATURE-


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



Re: modpython and python2.5

2007-08-29 Thread Grupo Django

Finally I have rewritten the code to make it compatible with
python2.4. It was the easiest solution.

I hope Debian makes python 2.5 the default interpreter soon.

On 28 ago, 17:40, TheMaTrIx <[EMAIL PROTECTED]> wrote:
> mod_python needs to be compiled against the python version your using.
>
> On windows mod_python even trows errors in the logfile (although it
> still functions) when you use the mod_python for python 2.5, while
> your using python 2.5.1.
>
> On Aug 28, 1:48 pm, Leandro Zanuz <[EMAIL PROTECTED]> wrote:
>
> > You'll need to recompile your apache/mod-python. When you
> > compile the mod-python you'll need ro inform the python path
> > that you want to use.
>
> > Grupo Django escreveu:
>
> > > This is not a django related problem, but I thought that maybe someone
> > > could help me.
> > > I have a Debian 4 server with apache2, modpython 3.3., python2.4 and
> > > python2.5
> > > PYthon 2.4 is required by Debian to solve some dependency problem, I
> > > have just installed python2.5 and made it the default interpreter, but
> > > modpython is not using it, I have no idea why.
> > > Now I have a web down because I can't solve this problem.
>
> > > Thank you.


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



Reutilizing views

2007-08-29 Thread Grupo Django

Hello, I'd like to know if there is some way for reutilizing a view.

In my case, I have an application to show some data, but I want to
show the same data in the front page, among other data from other
models.
Well, I have figured out this method:

def myview(request, returnHTTP=True):
t = loader.get_template('template.html')
...
c = RequestContext(request,{ 'data':data })
if returnHTTP:
return HttpResponse(t.render(c))
else:
return data

and in the view of the front page:

def front-page(request):
from someApp.views import myview
data = myview(request,False)


Is this ok? Perhaps there is a better way of doing it with django.
Thank you very much.


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



modpython and python2.5

2007-08-28 Thread Grupo Django

This is not a django related problem, but I thought that maybe someone
could help me.
I have a Debian 4 server with apache2, modpython 3.3., python2.4 and
python2.5
PYthon 2.4 is required by Debian to solve some dependency problem, I
have just installed python2.5 and made it the default interpreter, but
modpython is not using it, I have no idea why.
Now I have a web down because I can't solve this problem.

Thank you.


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



Re: db-api optimization

2007-08-21 Thread Grupo Django

Yes sorry, In this example I didn't realize about that, but in my code
I have Q objects.
I wrote it very quick.


On 21 ago, 10:27, Collin Grady <[EMAIL PROTECTED]> wrote:
> That probably isn't what you want, though it will work (technically
> speaking)
>
> The way you're doing it, that's going to chain the filters with AND,
> not OR, so only things that match the title and description for all
> words will show up.
>
> You probably want to build a Q object with | for an OR lookup
> instead :)


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



db-api optimization

2007-08-20 Thread Grupo Django

Hello, I'm preparing a search form to perform searches against the db
(Postgre ).

well, Imagine the form with a category field, and a words field.

My view is something similar to this:

def my_view( request ):
items = a_model.objects.all()
if request.GET:
   ...
   if form.is_valid():
   ...
   words = data['words'].split()
   for word in words:
   items = items.filter( title__icontains = word)
   items = items.filter( description__icontains = word)
   if data['category']:
   items = items.filter( category = data['category'] )

Well, I know that since full-text is not available, this way is quite
intensive for the db.This code, search the words in the title and the
description, and if the category is defined, refines the result to
that category, if not, all categories are shown. I have read in the
docs, that chaining filters doesn't hit the database. Is this a good
way of chaining filters or perhaps there is other more effective?

Is there any way I can see the final generated sql clause?

Thank you!

(I'm really looking forward to postgre 8.3 with full-text in the core)


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



Re: Dynamic default value in models

2007-08-15 Thread Grupo Django

I think I found the answer here:

http://www.b-list.org/weblog/2006/11/02/django-tips-auto-populated-fields

Grupo Django ha escrito:
> Hello, I'm writing an application for publishing news, one of the
> fields is:
> author = models.CharField( maxlength=100)
>
> I want that that field is filled automatically when someone add a new
> from the administration zone.
> Is there any way of defining a default parameter with the username who
> is actually creating the content?
> e.g.
> author = models.CharField( maxlength=100, default=username)
>
> Thank you!


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



Dynamic default value in models

2007-08-15 Thread Grupo Django

Hello, I'm writing an application for publishing news, one of the
fields is:
author = models.CharField( maxlength=100)

I want that that field is filled automatically when someone add a new
from the administration zone.
Is there any way of defining a default parameter with the username who
is actually creating the content?
e.g.
author = models.CharField( maxlength=100, default=username)

Thank you!


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



FileField / ImageField problem on update

2007-08-11 Thread Grupo Django

Hi,
When I update a register that has a ImageField, the old file is not
deleted from the disk, so I have created a custom save method like
this:

def save( self ):

path = self.get_foto_filename()
delete_file(path)
super(Perfil, self).save()

But path is set to the new file I'm uploading instead the oldone, so I
can't access the old file to delete it.
Is this a bug or it works like this? How can I solve this problem? I
thought even creating a custom procedure in the database (postgre) but
I have never done it before, and I prefer to have all the code in the
django application.

Thank you very much.


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



Re: Multilingual site best practices

2007-08-10 Thread Grupo Django


Vincent Foley ha escrito:
> Hello,
>
> I work for a company who develops web sites and web applications for
> clients in Quebec.  People in Quebec mainly speak french, but there
> are english speaking people too.  Most sites we make eventually want
> to have a french and english version with french being the "main"
> version.
>
> I would like to know if anyone could share best practices for
> multilingual sites.  I also have some questions:
>
> 1. In the {% trans %} and {% blocktrans %} tags, should I include the
> full text, or just a quick description and enter the full text in
> the .po files?
>
> 2. As I said, french is the main language in Quebec, so if I write a
> site in french and am later asked to translate it, will the accented
> characters cause a problem if they're used in the msgid of the .po
> files?
>
> 3. It seems the server always has to be restarted after the .po files
> have been compiled.  Is that so?  If I don't have root access to the
> server to restart Apache, is there a way I can have the new
> definitions appear on the site?
>
> Thanks for the input,
>
> Vincent.

I'd like to extend this questions.
4. Best practice to use a multilingual database. i.e. News in English
and French from an app. I need it for a project. I'll write some docs
about it when I get it to work, if I get it ;-) IMHO, multilingual in
the interface but monolingual in database, is not very useful.
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to display an error

2007-08-09 Thread Grupo Django

You can use the shell.
Run python manage.py shell within your project path.
Import your model:
from app.models import foo
f = foo( bar=2 )
f.save()

now you can check all the variables you want. f.id returns the id of
the new created object.


On Aug 9, 1:29 pm, "Lic. José M. Rodriguez Bacallao"
<[EMAIL PROTECTED]> wrote:
> if I have a model with save method overrided to check if some values in my
> model are ok, how can I display the field(s) with errors in red in admin
> like django admin does when an error occur with that field(s)?
>
> --
> Lic. José M. Rodriguez Bacallao
> Cupet
> -
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
> mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic por
> profesionales
> -


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



Memcache

2007-06-23 Thread Grupo Django

Hello, I have set up a cache system, storing the cache data in disk.
I have a kind of static pages, that usually, it never change, but just
in case, I have set a cache for 12 hours.
If I change a page and I need to make the changes visible inmediatly,
I delete the cache file from disk.
Now I'm thinking to set a memcache system, and I have a question. Is
there any way to flush the cache and force the load of the new
content?
As a second question, I'd like to know your experiences with memcache,
and how much memmory have you assigned to it.

Thank you very much.


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



Add a css file into the admin zone

2007-06-02 Thread Grupo Django

Hello, I read that it's possible to add custom javascript to the admin
zone using:

class Admin:
js = (
'/templates/jscripts/admin.js',
)

How can I add a customs stylesheet? I had to do it appending it to the
document, using javascript and the DOM.

Thank you.


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



Re: multilanguage site

2007-05-31 Thread Grupo Django

Can you please provide me some document where I can find some
information and examples?
Thank you.

On 31 mayo, 12:11, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Grupo Django napisał(a):
>
> > Hello, I'm going to start a new multilingual site. I think that the
> > django tools are very powerful for this purpose, but I need a bit
> > more.
> > I have to translate the content from the database and I have a few
> > options:
>
> The simplest thing that comes to my mind is to create dummy python
> module with the database content marked for translation. I saw this
> approach for the first time in QuodLibet sources, then we implemented it
> in our applications and it works fine.
>
> --
> Jarek Zgoda
>
> "We read Knuth so you don't have to."


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



Re: multilanguage site

2007-05-31 Thread Grupo Django

> > - Could it be implemented in futures django releases?
>
> I think something like this could go in django.contrib. But I'm not sure
> how many people need this.

IMHO I think it's quite useful and it would be a great improvement.
Django is so good that it's possible to use it for very professional
sites, and those sites need generally content in several languages.
Moreover, it's not very difficult to implement it in the way I
exposed, and the text in the main language it's still stored in the
original table, not in the translation one, so it's backwards
compatible.
Perhaps for the English speakers it's not especially necessary but for
the rest of the world, we need to use our native language and English
in our sites very often.
If someone tell me what documents should I look to modify the django
code, I'll try to do it, and propose it.
I built a complete multilingual system for a PHP framework in just a
few hours.


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



multilanguage site

2007-05-31 Thread Grupo Django

Hello, I'm going to start a new multilingual site. I think that the
django tools are very powerful for this purpose, but I need a bit
more.
I have to translate the content from the database and I have a few
options:
- Translate it using the standard way, I mean, using po files.
  Problems: Every time I add/modify something to the database, I
have to do the same in the po file, the
right way is do everything in the admin zone.

- Create some tables for the translation. I have built some
multilanguage sites using PHP, and in the admin zone we had a select
combo box with the available languages, if you change the language in
the select, the fields with translation enabled, changed.
I'm thinking about creating a model for the languages with 3 fields:
 *id
 *language code (ISO 639)
 * language name

an other model for the translation strings:
* id
* table
* field
* id_row
* string

In the translation table, I'll have translations for the strings that
require translation in other models.ie:
| id | table |  field | id_row |
string|
=
|1 | 'polls'  | 'question' | 34| 'Do you like this translation
method?'

And then implement it within the admin zone, wich is the main problem
to me because I don't feel confident yet  for manipulating the admin
code and if I did, I'd have a lot of problems with the updates.

- Does anyone know a better solution for doing it?

- Could it be implemented in futures django releases?
I really like to help but I have only made one web using django, and
I'm still a newbie with a lot of questions,


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



Re: Change admin widget

2007-05-24 Thread Grupo Django

I used to use tinymce too, but it doesn't generate well formed xhtml,
and I found http://www.wymeditor.org/ which looks great, it's still
very simple, but it has a lot of interesting features, and now It'll
become a jquery plugin, and that's great because I use to work with
jquery.
Anyway, I must say that I have never implemented it yet.


On 24 mayo, 16:35, Michel Thadeu Sabchuk <[EMAIL PROTECTED]> wrote:
> Hi
>
> I use tinymce too, what rich text editor would you use (just to know
> another options)?
>
> Best regards


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



Re: Change admin widget

2007-05-24 Thread Grupo Django

You are right, I didn't know about add javascript in the model
definition, is good to know it :-)
I was thinking about doing an admin zone using a bit more of Ajax, and
autoload a select widget depending of a previous select... stuff like
that.

First I thought that I could create a second admin zone, but It's too
much work and it's already done, probably extend the admin in other
app would be the best option, but I don't know if it's possible.

Thanks.


On 24 mayo, 14:53, "Ben Jones" <[EMAIL PROTECTED]> wrote:
> > Hello, I need to hack a little bit the admin app, I'd like to use a
> > custom widget (Rich text editor) in some places. I think I'll have to
> > modify the admin code, is it right?
>
> Most browser based WYSIWYG editors I've ever tried allow you to
> implement them with only a little bit of javascript so you shouldn't
> need any customization outside of adding the proper proper javascript
> URLs to your model definitions. I just added TinyMCE to a page in the
> admin section for content editing, and after just a very little bit of
> fiddling it works nicely.
>
> See here for an example:
>
> http://code.djangoproject.com/wiki/AddWYSIWYGEditor
>
> > After this, I'll probably need to make some changes in the admin zone,
> > s I have to rewrite some code. I think there is two possible ways of
> > doing it. Copy the admin folder to my site directory, or modifying the
> > admin app inside the django source.
> > Both of them have any inconvenience, for example, in the first one, I
> > won't be able to update the admin zone easily when I update django,
> > and in the second one, when I update django I'll loose all the changes
> > I made.
> > What do you recommend me? Is there any other way?
>
> I don't know what the experts recommend, but from my own experience
> I've found that maintaining your own set of changes to a framework or
> application that you use is always a joy-sapping headache. What do you
> need to do that Django doesn't already provide for?
>
> --
> -Ben


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



And after many questions in this place...

2007-04-30 Thread Grupo Django

I'm happy to announce that I've released my first site based in
django, I'm very happy, and I want to say thank you to all the people
who made it possible, the django developers, and all the users of this
forum.
The site is:
http://www.universoheroes.com

(The server needs more RAM at this moment,I'm working on it)

Thank you everybody


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



Re: Atom feed not working

2007-04-20 Thread Grupo Django

Don't worry! If you are one of the developers, I only have to say
thank you for the excelent job. I really like django.
Just a question:
When will it be available in the trunk?


On 20 abr, 16:53, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-04-20 at 07:44 -0700, Grupo Django wrote:
> > Hello, I think that the atom feeder is not working properly.
>
> > The subtitle item is not shown.
>
> > Here is the code:
> > class UltimasNoticias(Feed):
> > feed_type = Atom1Feed
> > description_template = "noticias/sindicacion_resumen.html"
> > title = "Title of my site"
> > link = "http://www.mysite.com/;
> > subtitle = u"Subtitle I want"
>
> > def items(self):
> > return Noticia.objects.filter(visible=True).order_by('-
> > fecha_inicio_publicacion')[:10]
>
> > but the subtilte element isn't shown in the code xml.
> > I have tried to set the element logo and other atom items but still
> > not working.
> > Am I doing something wrong?
>
> No... you've found a bug. I have an uncommitted change in one of my
> local trees that I hadn't noticed was relevant. Sorry, my fault
> completely here -- I'm juggling too many versions of the code.
>
> I've just committed it in [5045].
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Atom feed not working

2007-04-20 Thread Grupo Django

Hello, I think that the atom feeder is not working properly.

The subtitle item is not shown.

Here is the code:
class UltimasNoticias(Feed):
feed_type = Atom1Feed
description_template = "noticias/sindicacion_resumen.html"
title = "Title of my site"
link = "http://www.mysite.com/;
subtitle = u"Subtitle I want"

def items(self):
return Noticia.objects.filter(visible=True).order_by('-
fecha_inicio_publicacion')[:10]

but the subtilte element isn't shown in the code xml.
I have tried to set the element logo and other atom items but still
not working.
Am I doing something wrong?

Thank you.


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



Re: django-Postgre bug?

2007-04-15 Thread Grupo Django

This is the postgrelog:
2007-04-15 11:23:06 CEST ERROR:  no se puede truncar una tabla
referida en una llave foránea
2007-04-15 11:23:06 CEST DETALLE:  La tabla «galeria_galeria» hace
referencia a «galeria_album».
2007-04-15 11:23:06 CEST HINT:  Trunque la tabla «galeria_galeria» al
mismo tiempo, o utilice TRUNCATE ... CASCADE.
2007-04-15 11:23:06 CEST SENTENCIA:  TRUNCATE TABLE galeria_album
2007-04-15 11:23:06 CEST ERROR:  transacción abortada, las consultas
serán ignoradas hasta el fin de bloque de transacción
2007-04-15 11:23:06 CEST SENTENCIA:  INSERT INTO
galeria_album(nombre,path) VALUES('Galeria','media/fotos/')
2007-04-15 11:23:06 CEST ERROR:  inserción o actualización en la tabla
«galeria_album» viola la llave foránea «padre_id_refs_id_8fc3037»
2007-04-15 11:23:06 CEST DETALLE:  La llave (padre_id)=(0) no está
presente en la tabla «galeria_album».
2007-04-15 11:23:06 CEST SENTENCIA:  END
2007-04-15 11:23:38 CEST ERROR:  no se puede truncar una tabla
referida en una llave foránea
2007-04-15 11:23:38 CEST DETALLE:  La tabla «galeria_galeria» hace
referencia a «galeria_album».
2007-04-15 11:23:38 CEST HINT:  Trunque la tabla «galeria_galeria» al
mismo tiempo, o utilice TRUNCATE ... CASCADE.
2007-04-15 11:23:38 CEST SENTENCIA:  TRUNCATE TABLE galeria_album
2007-04-15 11:23:38 CEST ERROR:  transacción abortada, las consultas
serán ignoradas hasta el fin de bloque de transacción
2007-04-15 11:23:38 CEST SENTENCIA:  INSERT INTO
galeria_album(nombre,path) VALUES('Galeria','media/fotos/')

I'm gonna check what you said about referential integrity. I'll post
again if I solve it and if I don't.



On 15 abr, 08:48, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> On Apr 15, 1:46 am, "Grupo Django" <[EMAIL PROTECTED]> wrote:
>
> > Hello!
> > I was building a gallery image, and everithing went fine with mysql,
> > but lately, I changed my mind and I changed the database to postgres,
> > it's the django recommendation.
> > Well, sudenly I got this message:
> > ProgrammingError?: ERROR: current transaction is aborted, commands
> > ignored until end of transaction block
>
> What do the PostgreSQL logs say?
>
> L.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [EMAIL PROTECTED]
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-Postgre bug?

2007-04-14 Thread Grupo Django

Hello!
I was building a gallery image, and everithing went fine with mysql,
but lately, I changed my mind and I changed the database to postgres,
it's the django recommendation.
Well, sudenly I got this message:
ProgrammingError?: ERROR: current transaction is aborted, commands
ignored until end of transaction block

The problem is this insert:
INSERT INTO galeria_album(nombre,path) VALUES('Galeria','media/
fotos/')

and here is the model:

class GaleriaManager( models.Manager ):
def borrar_galeria( self ):
from django.db import connection
cursor = connection.cursor()
try:
cursor.execute( "TRUNCATE TABLE galeria_galeria" )
return True
except:
return False
def borrar_album( self ):
from django.db import connection
cursor = connection.cursor()
try:
cursor.execute( "TRUNCATE TABLE galeria_album" )
return True
except:
return False
def borrar_todo( self ):
if self.borrar_album():
if self.borrar_galeria():
return True
return False

def cargar_galeria( self, path = 'media/fotos/', padre=0 ):
import os
import imghdr
from django.db import connection

cursorG = connection.cursor()
cursorA = connection.cursor()
list = {}

#Creo el album raiz:
root_gallery_name = 'Galeria'
if padre == 0:
 The next query breaks everything ###
cursorA.execute( "INSERT INTO galeria_album(nombre,path)
VALUES('%s','%s')" % ( root_gallery_name , path ) )
connection.connection.rollback()
padre= cursorA.lastrowid

files = os.listdir( path )
for file in files:
newpath = os.path.join( path, file )
if os.path.isdir( newpath ):
cursorA.execute( "INSERT INTO
galeria_album(padre_id,nombre,path) VALUES(%s,'%s','%s')" % ( padre,
file, path ) )
list[file]= cursorA.lastrowid
#print "Directorio %s " %(file), " listado: ",list
self.cargar_galeria(newpath, list[file])

elif os.path.isfile( newpath ):
 if imghdr.what( newpath ):
 cursorG.execute( "INSERT INTO
galeria_galeria(album_id,nombre,path,visible) VALUES(%s,'%s','%s',1)"
% ( padre, file, newpath ) )
 #print "Archivo: %s - Padre: %u \n" %( file,
padre )

return True


def reset_galeria( self ):
self.borrar_todo()
self.cargar_galeria()

# Create your models here.
class Album( models.Model ):
padre = models.ForeignKey( 'self', 'id', blank=True,null=True )
nombre = models.CharField( maxlength=255 )
path = models.CharField( maxlength=255 )
imagen = models.ImageField(upload_to='albumes', null=True )

class Admin:
pass
def __str__(self):
return self.nombre

class Galeria( models.Model ):
album = models.ForeignKey( 'Album', 'id', blank=True )
#padre = models.ForeignKey( 'self', 'id', blank=True )
nombre = models.CharField( maxlength=255 )
path = models.CharField( maxlength=200 )
visible = models.BooleanField( default=True )
objects = GaleriaManager()

def __str__( self ):
return self.nombre
class Admin:
list_display = ( 'nombre', 'visible' )

I found this information:
   http://code.djangoproject.com/ticket/852
but it didn't help me.
I'm testing it in the shell:

>>> from mysite.galeria.models import Galeria
>>> Galeria.objects.reset_galeria()


I was excited because my first django site is almost ready for
production and suddenly... it failed :-(
Could anybody help me please?
Thank you very much.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [EMAIL PROTECTED]
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
-~--~~~~--~~--~--~---



Re: Simple python question

2007-04-11 Thread Grupo Django

Thank you!
What I'm doing is to load a model from a template.
I have in a template something like this:
{% block menu %}
{% block rss %}

I want to load "menu" and "rss", but I think that is too much work for
now, I have no idea how to implement it and I probably won't do it.
Thank you very much for your help.




On 11 abr, 00:07, "Todd O'Bryan" <[EMAIL PROTECTED]> wrote:
> On Tue, 2007-04-10 at 18:03 -0500, Jeremy Dunck wrote:
> > On 4/10/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> > ...
> > > The key is that he wanted to use the string name of the class, not the
> > > class itself. Assuming that Foo is available (i.e., is local to the code
> > > you're running or has been imported), this should work:
>
> > > o = locals()['Foo']()
>
> > Oh.  In that case, you also want to make sure the string is trust-worthy.
>
> > I hope you're not creating a class instance from a request parameter. :)
>
> What he said! (I'm inclined to be so trusting...)


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



Simple python question

2007-04-10 Thread Grupo Django

I know this is not the right place for asking about python, but it's a
simple question.
I need to load an object given in a string. Example:

#I have a class called foo
class foo:
def Hello():
return "Hello World"

object = 'foo'

print object.Hello()

Something like this.
Is it possible in python? I think it is but I don't know how to do it.

Thank you very much.


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



model inheritance

2007-04-10 Thread Grupo Django

Hi!
I need to create a custom user profile, and I was going to do it as
James said in his blog [1], but first I'd like to know how is the
model inheritance going.
Is still the James way the best way to do it?
Thank you.


[1] http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model


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



Re: request object out of a view (I need to access session['data'])

2007-04-03 Thread Grupo Django

I don't know if I didn't understand you or if I you didn't don't
understand me :-)
Not sure abou what you are saying, I think I can't use it to make the
template tag work.
The template tag doesn't use a view to render the content, so it
doesn't get the request object as a parameter.
This is the code of the template tag:
--
register = template.Library()
def menu(position):

data = request.session["stored_data"]
...
return {'output': output,}

register.inclusion_tag('menu/menu.html')(bloque_menu)
--

So I need to read into data the data that is stored in the session.
But the request object is not accessible.
Sorry, I didn't understand what you wrote very good.
Thank you.






On 3 abr, 23:37, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 4/3/07, Grupo Django <[EMAIL PROTECTED]> wrote:
>
> > Inside the custom template tag, I don't get the request object since
> > it's not a view.
>
> Look into using RequestContext[1] in your views (generic views all use
> it automatically), and enabling the "request" context processor[2].
> This will make the variable "request" -- containing the HttpRequest
> object -- available in template contexts, so in your tag's 'render'
> method you could access it by doing something like:
>
> def render(self, context);
> request = template.resolve_variable('request', context)
> ...do stuff with the request...
>
> [1]http://www.djangoproject.com/documentation/templates_python/#subclass...
> [2]http://www.djangoproject.com/documentation/templates_python/#django-c...
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


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



request object out of a view (I need to access session['data'])

2007-04-03 Thread Grupo Django

Hi, I need to know how can I access data stored in the session out of
a view.
I have created a custom template tag which has to check a variable
stored in the request.session. It's strictly necessary to store the
data in a session variable at this moment.
Inside the custom template tag, I don't get the request object since
it's not a view.
I have no idea about how to retrieve the data.

And a secondary question related to this. If I wanted to retrieve a
value by GET within the template tag. Is it possible to access it?

Thank you very much.


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



Re: unordered_list in templates

2007-03-30 Thread Grupo Django

I have written a custom tag.
Here is the code:

register = template.Library()

def bloque_menu(posicion):

def items(bloque, padre):
entradasMenu = bloque.menu_set.filter(padre = padre,visible=1)
salida=""
if entradasMenu:
salida = "\n"
for entrada in entradasMenu:
salida += "\t" 
+ entrada.nombre +
"\n"
salida += items (bloque, entrada.id)
salida += "\n"
return salida

posicion = Posicion.objects.get(posicion=posicion)
bloques = posicion.bloquemenu_set.all()
for bloque in bloques:
bloque.salida = items(bloque,0)

return {'bloques': bloques,}

register.inclusion_tag('menu/menu.html')(bloque_menu)

<-- End of the code -->
It's written in spanish, if someone needs a translation I'll provide
it.



On 17 feb, 03:15, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-02-16 at 15:16 -0800, [EMAIL PROTECTED] wrote:
> > Hello, I have a menu in a database, and I want to display it in an
> > unordered list, but I have to apply a class for every element like
> > Entry 1 
> > I think that this can't be done with the filter unordered_list.
>
> > Is there any way to use a kind of recursion to generate a menu like
> > this:
> > - Entry 0
> > - Entry 1
> > -Entry 1_0
> > -Entry 1_0_0
> > -Entry 1_1
> > Entry 2
>
> > formatted using  and .
>
> You cannot achieve exactly what you want with the builtin filter,
> however I can think of a couple of alternatives that would work:
>
> (1) If the class is the same for all elements in the list and you have
> some control over the stylesheet, put the class on the container (the
> "ul" element) and then your stylesheet can refer to "ul.theclass li",
> rather than "li.theclass". You could, alternatively, wrap all of the
> list item contents in a span element, but that would lead to spurious
> markup just for the sake of styling, which I would avoid if I could get
> away with annotating the container instead.
>
> (2) Copy the existing code for unordered_list and use it as the start
> for your own custom filter. Custom filters are not at all hard to write
> (see [1]) and modifying the existing code to suit your needs should not
> be too hard.
>
> [1]http://www.djangoproject.com/documentation/templates_python/#writing-...
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and referential integrity.

2007-03-19 Thread Grupo Django

Thank you very much both of you!

On 19 mar, 20:32, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 3/19/07, Grupo Django <[EMAIL PROTECTED]> wrote:
>
>
>
> > Does Django support referential integrity?
>
> Django does its best to emulate integrity features when they are not
> present in the underlying database (for example, if you delete an
> object to which other objects were related via foreign keys, Django
> will work out what those objects are and delete them as well,
> effectively emulating "ON DELETE CASCADE"), but it is preferred to use
> a database -- such as PostgreSQL -- which has strong integrity support
> by default.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


--~--~-~--~~~---~--~~
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 and referential integrity.

2007-03-19 Thread Grupo Django

Does Django support referential integrity?


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



Re: Configure eclipse and pydev to debug django

2007-03-17 Thread Grupo Django

Ok, I got it, sorry for the not-very-intelligent question.


On 17 mar, 19:35, "Grupo Django" <[EMAIL PROTECTED]> wrote:
> Ok, I knew that, but I don't know how to check the value of a var
> while running the app.
> Thank you anyway.
>
> On 17 mar, 19:04, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On 3/17/07, Grupo Django <[EMAIL PROTECTED]> wrote:
>
> > > Hello, does someone know how can I configure eclipse with pydev
> > > installed to debug django apps.
> > > I just need to watch some variables, dictionaries...
> > > Thank you.
>
> > I'm not sure what you're asking for exactly.  Assuming you have eclipse with
> > pydev installed, you create a debug/run configuration with your djago app's
> > manage.py as the "Main module", make sure django is in the Python path, and
> > specify "runserver 8000 --noreload" as program arguments (assuming you want
> > to listen on port 8000).  --noreload makes the development server run the
> > code in the current process, so the debugger can activate at breakpoints you
> > set (but it also means you have to manually re-load the program when you
> > make code changes).  This, at least, is what works for me.
>
> > Cheers,
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Configure eclipse and pydev to debug django

2007-03-17 Thread Grupo Django

Ok, I knew that, but I don't know how to check the value of a var
while running the app.
Thank you anyway.

On 17 mar, 19:04, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On 3/17/07, Grupo Django <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello, does someone know how can I configure eclipse with pydev
> > installed to debug django apps.
> > I just need to watch some variables, dictionaries...
> > Thank you.
>
> I'm not sure what you're asking for exactly.  Assuming you have eclipse with
> pydev installed, you create a debug/run configuration with your djago app's
> manage.py as the "Main module", make sure django is in the Python path, and
> specify "runserver 8000 --noreload" as program arguments (assuming you want
> to listen on port 8000).  --noreload makes the development server run the
> code in the current process, so the debugger can activate at breakpoints you
> set (but it also means you have to manually re-load the program when you
> make code changes).  This, at least, is what works for me.
>
> Cheers,
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Configure eclipse and pydev to debug django

2007-03-17 Thread Grupo Django

Hello, does someone know how can I configure eclipse with pydev
installed to debug django apps.
I just need to watch some variables, dictionaries...
Thank you.


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



Re: Select filled with data from a table

2007-03-15 Thread Grupo Django



On 15 mar, 19:38, "Rubic" <[EMAIL PROTECTED]> wrote:
> On Mar 15, 10:06 am, "Grupo Django" <[EMAIL PROTECTED]> wrote:
>
> > Hello, I think I have seen some way to fill aselectfield with data
> > from a table, but I'm not 100% sure and I can't find it anywhere. Is
> > it possible?
>
> ## models.py ##
> from django.db import models
>
> class Team(models.Model):
> name = models.CharField(maxlength=20)
> active = models.BooleanField(default=True)
>
> ## views.py ##
> from django import newforms as forms
>
> class TeamForm(forms.Form):
> teams = [(e.id, e.name) for e in Team.objects.order_by('name') if
> e.active]
> team_id = forms.ChoiceField(required=False, choices=[('','')]
> +teams)
>
> --
> If you need more dynamically table-based choices:
>
>http://www.djangosnippets.org/snippets/26/
>http://www.djangosnippets.org/snippets/49/
> --
> Jeff Bauer
> Rubicon, Inc.
Thank you very much!
Now I want to save the data in a database, how can I do it? I have
this form model:
categoria = forms.ChoiceField(required=False,
choices=[('','Seleccione una categoria')]+categorias)
fecha_inicio_publicacion = forms.DateField(input_formats=['%d/
%m/%Y'])
fecha_fin_publicacion = forms.DateField(input_formats=['%d/%m/
%Y'],required=False)
titulo = forms.CharField()
resumen = forms.CharField(widget=forms.Textarea)
contenido = forms.CharField(widget=forms.Textarea)

if request.POST:
  (save the form)

How can I save it? I'm sorry, I really need to learn a lot, I know it,
I hope you can help me.

Note: I can't use "form_for_model" because it doesn't validate the
date fields all right.
Thank you!


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



[newforms] Select filled with data from a table

2007-03-15 Thread Grupo Django

Hello, I think I have seen some way to fill a select field with data
from a table, but I'm not 100% sure and I can't find it anywhere. Is
it possible?
Thank you.


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



newforms dateField

2007-03-14 Thread Grupo Django

Hello, I have noticed that the field DateField in the newforms library
doesn't validate all right when introducing data.
I have this code:

FormClass = forms.models.form_for_model(Model)
form = FormClass(data)
data = request.POST.copy()
data['author'] = request.user
formulario = FormClass(data)

if form.is_valid():
  form.save()

And I get a validation error, meanwhile, when I validate using the
shell with the following code, it's ok:
>>> f2 = forms.DateField(input_formats=['%d/%m/%Y'])
>>> f2.clean('25/10/2006')
datetime.date(2006, 10, 25)

What's wrong in the first case?

Thank you.


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



newforms and special characters

2007-03-13 Thread Grupo Django

Hello, I'm having some problem using newforms. When I introduce a
string with special characters like ñ it just cut it. example:
Añadir
output: A

Does anybody know why?
Thank you.


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



QueryDict instance is immutable

2007-03-12 Thread Grupo Django

Hi!
I have created a form using newforms, and one field is author which I
want to fill using the current username, I did this:
request.POST['author']="Username I want"
and I got this error:
"QueryDict instance is immutable"
Ok, what should I do? I thought about create a hidden widget for this
field, but that's not secure enough.
Is there a way to do what I want?

Thank you!


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



How much work has been done with newforms?

2007-03-12 Thread Grupo Django

Hello, I'd like to know how is the work going with newforms. I don't
want a release date or something like this, just to know how is it
going, and the documentation as well.
I'm programming a website in django and I'd like to know more about
newfors, since I left the forms to the end, but now I have to start
with them.
Thank you.


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



Re: Api and user auth

2007-03-11 Thread Grupo Django

Thank you for your help!
I think I'll create a form to intorduce the news.
Thank you.

On 10 mar, 08:26, "risomt" <[EMAIL PROTECTED]> wrote:
> Actually, what I said is a bit wrong.
>
> To fill the author field correctly you should use a foreign key that
> points to the User model (again, assuming you're using the builtin
> django.contrib.auth User).
>
> On Mar 10, 2:21 am, "risomt" <[EMAIL PROTECTED]> wrote:
>
> > While I thoroughly agree with the above two, I'll go one step further
> > and say you should probably never put any code that sets admins
> > (superusers, or even straight access to django admin console) into
> > code whatsoever.
>
> > To help you out with a direct answer:
>
> > django has no difference between admin and regular user except a few
> > flags that grant the ability to login to admin (or edit it).  While
> > those flags arent the subject, what you're looking for is part of the
> > request.
>
> > "request.user" will allow access to any *basic* information (assuming
> > you're using the django.contrib.auth module) the author may have
>
> > "request.user.username" is the login name of the current user, and the
> > actual information you want for the author field (I do this for a
> > picture upload app for a local project)


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



Api and user auth

2007-03-07 Thread Grupo Django

Hello, I have two questions:

-Where can I browse the django API?

- I have made a news app. One of the fields is author, i want to set
its default value to the username logged in the admin zone. How could
I do it? What do I have to import to use request.username? so I would
do: default= request.username, editable=False.

Thank you!


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



Using data from other DB

2007-03-04 Thread Grupo Django

Hello!
I want to add a block in the site that shows the "Last topics" of the
forum.
The forum is a MyBB. I'd like to know the best approach to do it.
- Create a model based in the tables that I want to retrieve and use
it as  a normal model in django.
- Use pure SQL to do the same.

Thank you!


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



Recursion in templates... again

2007-02-27 Thread Grupo Django

Hello, I have been looking around about some information about how to
do recursion in templates but what I found didn't help me.
This is the case:

class Menu(models.Model):
id = models.AutoField('id', primary_key=True)
parent = models.ForeignKey('self','id',null=True,blank=True)
name = models.CharField(maxlength=200)

And the plan is to create a menu like this:
- Entry 1
-- Subentry 1_1
-- Subentry 1_2
 sub_Subentry 1_2_1
- Entry 2
...

I have created a custom tag to manage this but so far I only have this
in the template:

{% for entry in menu_list %}
 {{ entry }} 
{% endfor %}


and the customtag def is:

def menu(pos):
menu_list = Menu.objects.all()
return {menu_list': menu_list}

I have no idea how can I solve this problem, I have seen some posts
about this,  but no clean solution.
Thank you!


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



Use an application inside other application

2007-02-25 Thread Grupo Django

Hello, I have created an app named "menu". I want to build an easy way
of adding items to the menu in the admin zone. I want to render this
menu in every view of others applications (blog, static pages...).
I'd like some suggestions about how to implement it in the template
system.
I thought about using the {% include %} tag, and then import the menu
app in every application. Is this a good way?
I accept suggestions.
Thank you very much!


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



Use an application inside other application

2007-02-25 Thread Grupo Django

Hello, I have created an app named "menu". I want to build an easy way
of adding items to the menu in the admin zone. I want to render this
menu in every view of others applications (blog, static pages...).
I'd like some suggestions about how to implement it in the template
system.
I thought about using the {% include %} tag, and then import the menu
app in every application. Is this a good way?
I accept suggestions.
Thank you very much!


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



Postgre and mysql

2007-02-21 Thread Grupo Django

Hello, I want to know which of these two databases are prefered by
django. I can choose and I'd like to know if there is some differences
in performance or integration (like foreign keys).
If someone knows a comparative between both of them it would be good,
not only about django integration but about everything.

Thank you.


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



Re: Django over modpython

2007-02-19 Thread Grupo Django

They told me that modpython is running through cgi, I have no idea
about that.
I want that all my objects are privated, and that nobody is able to
see anything from my code.
To be honest, I just read about this, I don't know anything about this
and I'd like to learn.
What is the best in a vps?
What is the best in a shared hosting?

Thank you everybody.

On 19 feb, 20:51, "ScottB" <[EMAIL PROTECTED]> wrote:
> For VPS hosted based in the UK, I can highly recommend Xtraordinary
> Hosting.  I have a basic VPS with them and it's super fast.
>
> http://www.xtrahost.co.uk/xenvps
>
> Scott


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



Re: Django over modpython

2007-02-18 Thread Grupo Django

I can't afford it right now. I would be good anyway.
In bluehost, they offer me modpython, but i have some questions about
that.
First of all, modpython is running through cgi. As Nathan said, this
would be a a loss of permormance, but what about security? I have read
that with fastcgi, only one instance of python is running, but
everybody could access to my objects, even to my config files where
the database password are stored. I supposse that with cgi, nobody can
do this, because I would have one instance of python for each request.
I prefer security.
I'm a bit lost with all this stuff. What is the best for running a
python script? VPS and modpython, VPS and fcgi or  VPS and cgi?
and in a shared hosting, what is the best thinking about security?
I will use a shared hosting. Is it secure enough with modpython
through cgi?

Thank you very much, I'm very confused.


On 18 feb, 15:07, "Benjamin Slavin" <[EMAIL PROTECTED]> wrote:
> I second the SliceHost VPS recommendation... my experience with them
> has been nothing but positive.
>
>  - Ben
>
> On 2/17/07, Scott Paul Robertson <[EMAIL PROTECTED]> wrote:
>
> > On Sat, Feb 17, 2007 at 04:41:46PM -, akonsu wrote:
>
> > >www.prgmr.comseem to have affordable VPS hosting. but i agree, they
> > > still offer less space and bandwidth than shared hosting.
>
> >www.slicehost.comhas been treating me very well for VPS hosting.
> > $20/month for 256 MB RAM, 10 GB disk, 100 GB bandwidth. They even
> > provide DNS for free.
>
> > --
> > Scott Paul Robertson
> >http://spr.mahonri5.net
> > GnuPG FingerPrint: 09ab 64b5 edc0 903e 93ce edb9 3bcc f8fb dc5d 7601


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