Re: How to use post_save signal

2008-11-05 Thread Antoni Aloy

2008/11/5 Low Kian Seong <[EMAIL PROTECTED]>:
>
> Dear all,
>
> I am using django to write an a web based sales inventory system for
> my client. To this end, I have created two objects in my models which
> is :
>
> Sales and Stock. Everytime a sales is associated with a particular
> stock is created, I want to update the Stock object's status field as
> 'Sold'. Asking on the #django channel, they suggested I override the
> save method for the model which lead me to finally try out the
> post_save signal.
>
> I tried out most of the examples and tried to associate my method
> which actually will try to get the particular stock object based on
> the foreign key entry from Sales and update that object's 'status'
> field. This however does not work. I tried to put the
> signals.post_save.connect method in my __init__.py file and models.py
> file but the code is not executed. Can someone please point me to a
> project or url which has a more complete example for using the signals
> and post_save? It seems like a very powerful component of the django
> architecture.
>
> Thank you in advance.

This is an example about how to register a delete signal to save the
deleted user to a table called Eliminat, save should be nearly the
same.

You can put the in your models file, but be sure you have the
application model in the settings.py file.

{{{
def registra(sender, **kwargs):
# get the instance
instancia = kwargs['instance']
# Creates the object who's going to store the username
usuari = Eliminat(user=instancia.username)
    # and the save it
usuari.save()

pre_delete.connect(registra, sender=User)

}}}

Hope it helps!

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can I print all of received variables in template ?

2008-11-11 Thread Antoni Aloy

2008/11/11 K*K <[EMAIL PROTECTED]>:
>
> Hi, all.
>
> I want to write a page template for test my program.
>
> How can I print all of variables posted to the template?
>
> Just like Django's error page.

well, just check the Django code ;)


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template translation

2008-11-11 Thread Antoni Aloy

2008/11/11 davidynamic <[EMAIL PROTECTED]>:
>
> Are there any other settings required to make .po files for
> translation strings in templates besides adding  {% load i18n %} to
> the top of the page. All my translation tags inside my views work fine
> and are loaded into the .po files but the template tags aren't
> working. I"m using both {% trans "" %} and {% blocktrans %} tags
>
I have such a problem once and it was solved adding the application in
the config file.

On the other hand, I assume you have extracted the translation strings
and you're using the right language in your browser, that is the
language on which you want the pages or you have managed yourself to
change the languaje.



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching and I18n

2008-11-20 Thread Antoni Aloy

2008/11/20 Malcolm Tredinnick <[EMAIL PROTECTED]>:
>

>
> Andrew's final comment on that ticket is accurate. Removing the code
> duplication is pretty easy there and following the examples in
> tests/regressiontests/middleware/tests.py to create some tests for it
> should be fairly straightforward as well. So it looks close.
>
> Regards,
> Malcolm

Anybody on this thread is going to take the ticket? I could take a
look at it and make the tests.

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching and I18n

2008-11-25 Thread Antoni Aloy

2008/11/25 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> Hello Aloy,
>
> I saw the great work you did on ticket #5691. Thanks a lot, I highly
> appreciate that! We have to offer our first release with the bug, but
> I hope to be able to include your patch or a workaround for the next
> one and will give feedback once that's been done.
>
It's nice to help!

But you have to consider this is my first patch on Django core, and I
just be really sure that everything is ok when one of django main
developers double check the tests :)

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best IDE for Django and python?

2008-11-25 Thread Antoni Aloy

2008/11/25 Kurczak <[EMAIL PROTECTED]>:
>
> I wonder why no one mentioned Komodo IDE or Komodo Edit.
> They're my personal favorites for bigger projects. Both are well
> suited for dynamic languages and really lightweight compared to
> Bloatclipse with pydev (or aptana).

I have tested Komodo Edit and personally I like best vim + extensions,
Eric4, Eclipse + pyDev or actually Netbeans.
I you haven't tested yet give Netbeans a look. In my opinion this is
the way to go on Python development.

Eclipse+pyDev and Eric4 actually have more Python options, specially
on refactoring, but Netbeans interface is much clearer and the
combination of auto completion and documentation is really good. I
also like very much the svn diff tool with syntax highlight.

Eclipse and Eric4 have a more svn interface. From Netbeans I don't
like that the auto completion shows all the packages that are in the
project even if they aren't related to it, and that it shows the pyc.
But I have been testing it during the last days and even with this
lacks it's one of the best IDEs.

--~--~-~--~~~---~--~~
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: best practices for SOAP client in Django

2008-12-05 Thread Antoni Aloy

2008/12/4 wynfred <[EMAIL PROTECTED]>:
>
> Hi, all. I am new to Django/Python. For one project, I need to be
> posting data to a .NET SOAP web service. I've read about the various
> Python SOAP libraries, mainly SOAPpy (http://diveintopython.org/
> soap_web_services/). What is not clear yet is how best to use a tool
> like SOAPpy within the Django framework.
>
> Our application should have the following routine:
> 1) Our django app would pull data from our database
> 2) We'd take that data and format the SOAP XML message
> 3) We'd post the SOAP XML message to the .NET SOAP web service
> 4) When the response verifies a successful post to the SOAP web
> service, we'd record that transaction as successful in our database
>
> Anyway, I'm learning how to do all these steps as isolated pieces of
> code, but what's not clear is how best to achieve this task flow
> within our Django application.
>
d 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
> -~--~~~~--~~--~--~---
>
>
We use ZSI to consume web services from our Django application. What
we have made is make a pythonic lawer for the web service, adding
caches when appropiated, connection pooling etc

For the Django point of view is just another library, in the form of a
service we instatiate in the application __init__.py.

I don't know if this is the best way to do it, but it works quite well for us.

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to return a specified column from database

2008-12-13 Thread Antoni Aloy

http://docs.djangoproject.com/en/dev/ref/models/querysets/

Check for values for exmple. Has a fields property that will allow you
to specify the fields you want to return.

2008/12/13 Lee :
>
> Hi,  James Bennett
>
> Thanks for you reply.
>
> Howerver, I have already read the database API documentation, and I
> can't find this method.
>
>
>
>
>
>
> On Dec 13, 11:13 pm, "James Bennett"  wrote:
>> On Sat, Dec 13, 2008 at 5:55 AM, Lee  wrote:
>> >If I want to return a specified column in this situation without
>> > using SQL query (select y from table where x =1), how to do it?
>>
>> There is a method which will do this, and it is listed in the database
>> API documentation alongside all the other querying methods.
>>
>> --
>> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
> >
>



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: MySpace clone using Django? Is it possible?

2008-12-20 Thread Antoni Aloy

A clone lot of sense if is very specific. That is, you can have a
Facebook/MyEspace/whatever clone for example in your own company
(think in a company with 1000+ employees in diferent locations) where
you can provide an interface that some people could be familiar with.
This was once a time called an Intranet, but now has evolved to the
put-your-company-here social network.

As this kind of application usually needs to get/save data from legacy
systems, in my oppinion is better to buid the solution agains
components, like Pinax does, so you have more chances to adapt the
application to your users and company needs that getting a pre-built
solution and just change the css.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: PDF to Text Coverter

2008-12-22 Thread Antoni Aloy

Check this:

http://code.activestate.com/recipes/511465/
http://pybrary.net/pyPdf/

Best regards,

2008/12/21 Harish :
>
> Hi Friends...
>
> I know this is a not a right place to ask this question.
> but it is related to Python. I thought it to ask.
>
> Is there any python library is available to read a pdf  files... ?
>
> Or any library to convert the pdf into text files?
>
> If you have any idea about above issues
>
> please let me know...
>
> Regards
> Harish Bhat M



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Executing logic for each object in object_list

2008-12-25 Thread Antoni Aloy

2008/12/25 Roy :
>
> Is it possible? Or I need to page my queryset in the wrapper function
> and do it there? (it seems not DRY to simply copy-paste the pagination
> logic from object_list)
>
> Basically I have several object_list wrappers for a particlar model,
> and I want to add logging logic every time a specific instance is
> viewed within each list. Is there a "preferred" way to do this in
> Django?
>
> I thought about creating a custom template tag that does the logging
> instead, but I'm not sure if it's a best practice to have database-
> insertion logic inside template tags.
> --~--~-~--~~~---~--~~

Sounds like a work for signals

http://docs.djangoproject.com/en/dev/topics/signals/



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Getting value of field from form.

2008-12-27 Thread Antoni Aloy

2008/12/27 evenrik :
>
> So I need to display the data for a form field from the post or from
> the instance if no post.  This works but I am hoping there is a better
> way:
>
> {% if form.is_bound %}
>{{ form.data.foo }}
> {% else %}
>{{ form.instance.foo }}
> {% endif %}
>
> Any suggestions?

I not fully understant what you're trying to do, but with the initial
parameter on the form instance you have the chance to prepopulate the
form with data which is not going to be validated at that moment. So
on the template it's just a matter to write {{form}}

Hope it helps!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: django i18n for google

2008-12-27 Thread Antoni Aloy

2008/12/27 Alessandro Ronchi :
> Il 16 dicembre 2008 19.20, Alessandro Ronchi
>  ha scritto:
>> When google spiders our i18n translated django websites, does it try
>> and indicize all languages? is it possible to force the language by a
>> GET var (for example &language_code=en) ?
>
> I think it's a critical problem.
>
> We spend time to make our i18n websites but google bot don't see other
> languages except default.  Is there a way to select language with a
> get url? Any other solution?

You could create a url that links to your localized site so Google
would be able to crawl it, but I suppose that your site depens on
changing the language via POST, isn't it?

I that case, you could write yourselve the code and allow changing the
code using GET.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: request.user is set to None

2008-12-29 Thread Antoni Aloy

2008/12/29 madhav :
>
>  As a part of django user authentication, when is request.user becomes
> None?? As I have read in the docs, it will either
> django.contrib.auth.User or AnonymousUser, but I am getting a very
> weird error telling request.user is None. Please help me out. When I
> am trying to call request.user.is_authenticated(), it is raising an
> error telling request.user doesn't exist. I am using Django 1.0
> (version:8961). Please help me out. :(
Hello!

If request.user  is None means that you don't have a user object, so
you cant access to its properties.
So double check that you have SessionMiddleware and
AuthenticationMiddleware configured in your settings.py, and if it
fails give more information about how you're accessing to the User
object.

Hope it helps!



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: reusing the same block in extends "base.html"

2009-01-02 Thread Antoni Aloy

2009/1/2 Alan :
> Dears,
> I have in my base.html something like 'href="/{% block folder %}{% endblock
> %}/"' and this block folder is expected to appears several times in
> base.html. So I create a page that inherits from base.html, I got this error
> message:
> ''block' tag with name 'folder' appears more than once"
> I understand the problem, but I don't figure out a solution other than
> creating several folder1 folder2 etc. to get the very same value (dumb)!
> Would {% with ... %} work here in my base.html? How? Another suggestion?
> Many thanks in advance.
> Alan
> --
> Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
> Department of Biochemistry, University of Cambridge.
> 80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>>http://www.bio.cam.ac.uk/~awd28<<
>
> >
>

You can create a tag, depending on how your application is could make
sense. What's clear is that you can't use the same block name twice.

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: changing code = restarting django??

2008-09-05 Thread Antoni Aloy
It depens!

On development any time you change your code the server restarts itself. In
production if you use mod_python you must reload the server any time you
change your python code, and perhaps empty cachés if you use them.

2008/9/5 samsus <[EMAIL PROTECTED]>

>
> Hello,
>
> In php when you change the code there is no need to restart the
> server, but in j2ee its necessary to recompile everything. how does
> that work in django?
>
> >
>


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Introducing django-cms

2008-09-08 Thread Antoni Aloy
2008/9/8 Thomas Steinacher <[EMAIL PROTECTED]>

>
> Hello Djangonauts!
>
> I would like to introduce django-cms, a free, BSD-licensed content
> management system based on Django. It is seamlessly integrated with
> Django's admin interface and supports a hierarchical page structure,
> internationalization and much more.
>
> You can find the project page on http://django-cms.org/. There is also
> a demo site set up which allows you to play around with the admin
> interface.


It looks impressive!


>
> The software is still in development and we would appreciate any
> feedback and contributions.
>
>
I also like very much http://code.google.com/p/django-page-cms/ . Your
project seems more oriented to a end user cms, and
django-page-cms is more oriented towards integration.

Anyway I like the idea of have a multi-language Django-based cms :)

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Introducing django-cms

2008-09-09 Thread Antoni Aloy
2008/9/8 Thomas Steinacher <[EMAIL PROTECTED]>

Hi Thomas!

>
> @Antoni Aloy:
> What do you mean by integration? Like integrating other applications
> (e.g. a gallery) into the CMS? We're still looking for a good solution
> to do that (e.g. by providing an API which allows to write a CMS
> plugin which would allow to integrate a third-party app directly into
> the CMS).
>
> I divide CMS in applications in two groups, one are just APIs, so you can
create an application and the CMS just provides the content, but in that
kind of applications textual content  is not the goal. So, they are easy to
integrate with your applications but they don't provide much functionallity.
Django-cms would be that kind.

The other group are CMS applications. That is, the CMS *is *the application.
They are very usefull when your site is content based. Usually this kind of
cms applications don't fit when creating applications that need a CMS. The
user interface for the CMS and the fucntionallity are much better than the
prevoious one.

I don't know yet where to classify it. In fact I'll be very happy if I could
have a powerfull CMS like yours being able to create applications using it
as a way to manage multilanguage content.

My english is not as good as I like but this is what I'd tried to say with
"integration".

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: PostgreSQL with Psycopg2

2008-10-13 Thread Antoni Aloy
2008/10/13 Gaus <[EMAIL PROTECTED]>

>
> Hi All
> I am developing my first-Django based project by myself. Wanted to use
> Postgresql with Psycopg2 & dont want to use Sqlite or Mysql for that
> matter. I have a problem which I cant rectify. My development
> environment is as follows :
>
> 1. Ubuntu 8.04
> 2. Python2.5 - compiled & installed\
> 3. Apache2_2.2.4-3ubuntu0.1_all.deb - Downloaded and Installed
> 3. Mod_Python-3.3.tgz - Installed & configured
> 4. Postgresql installed - using  'sudo apt-get install postgresql-8.3
> postgresql-client-8.3
>postgresql-contrib-8.3
> 5. Psycopyg2-2.0.8.tar.gz - Downloaded & Installed.
>
> Have you tried to import Psycopyg directly from the Python interpreter?
Double check that you really have psycopg2 installed. On ubunto to th
/usr/lib/python2.5/site-pacakges and type

ls psycopg2

You should have the pyscop2 egg
-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: XML Serialization Speed

2009-01-25 Thread Antoni Aloy

2009/1/26 Taylor :
>
> I'm thinking of changing my views so that they work with XSLT and an
> XML representation of my data.  I see 3 options:
> 1. Use django's xml serializer.
> 2. Use python's xml tools to make my own XML.
> 3. Use django's template systems to drop my data into xml.  Like so:
> 
> {{ monster.hp }}
> ...
> 
>
> My question is what would be the fastest option?
> It seems that #2 would give me the best flexibility, although #1 would
> allow for a more general approach, although I may not need every field
> from each object so there would be some wasted time.  Plus #2 would
> take more work and I have a deadline! (don't we all!)
>
> Is the xml serializer faster than plugging data through the template
> system?  Seems like it would be, but I don't know the django
> internals.
Just prototype and test the performance for each.

For one of my applications I found that lxml+mako templates was the
best solution for me, but perhaps it's not your case.

http://diveintopython.org/performance_tuning/timeit.html

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Change widgets in ModelFormSet

2009-01-30 Thread Antoni Aloy

2009/1/31 juanefren :
>
> I am using modelformset_factory, to show forms and is working good, my
> question now is, how can I modify widgets created ? (I want to change
> the size of the html text elements).
Use CSS, javascript o CSS+Javascript. The formeset are generated
following alwasy the same rules, so you can be sure that id would be
always the same. Get the id and add a css acording, for exemple.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Template tags question

2009-01-31 Thread Antoni Aloy

2009/1/31 zentur :
>
> Hello,
>
> i´ve got a problem with the template code of django
>
> i would like to realize this simple task
>
> for (i = 0,  i++,  i< list[0].length)
> {
>list[0][i] , list[1][i]
> }
>
> to display some data on a site, but with the django template tags I can
> ´t get somthing similar to work.
>
> Could anyone give me a hint how to realize this with django template
> tags?

templates tags has the for tag that allow you to iterate throught
collections, so you have to rethink your logic to pass the data in a
way that could be iterated and presented in the way you want.

So just pass to the template the list wicth contains the fnal data.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Reverse foreign key lookup with unknown model

2009-01-31 Thread Antoni Aloy

2009/1/31 Julian :
>
> hi there,
>
> I have a problem I really cannot solve on my own. lets say I have
> three models:
>
> class A(models.Model):
> ...
>
> class B(models.Model):
>fk = models.OneToOneField("A")
>
> class C(models.Model):
>fk = models.OneToOneField("A")
>
> If I have then a single A-instance, how can I determine to wich model
> it is connected _without_ knowing wich models do have a OneToOneField
> to A (or a ForeignKey to A)???
>
> my instance
>
> a = A()
>

Just use a property in A

class A(models.Model):

   @property
   def connected(sefl):
   try:
 x = self.b
   except: # put the real exception here
  x = self.c
   return x

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: table display with AJAX

2009-02-07 Thread Antoni Aloy

2009/2/7 Gerard Flanagan :
>
> MrJogo wrote:
>> Hi,
>>
>> One of my pages is going to have a table that I'd like to be sortable,
>> and I'm wondering the best way to do this. I looked into django-
>> tables, which seems good, but once the page is loaded, I'd also like
>> to be able to sort dynamically (using javascript). Before I go and
>> implement this myself, anyone have any suggestions on already made
>> solutions? Thanks.
>
Look at my sample code at:

http://code.google.com/p/appfusedjango/source/browse/#svn/trunk/jqagenda

It uses a slighty patched version of jqgrid.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: looking for working example of mptt

2009-02-09 Thread Antoni Aloy

2009/2/10 laspal :
>
> hi,
> Does anyone has a working example of django mptt. I am not able to
> implement it.
>
On the docs you have the way to go. I've followed them and it works for me.

Django-page-cms also uses it, so you can also look there.

Hope it helps
-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Django and jQuery trouble

2009-02-10 Thread Antoni Aloy

2009/2/10 min :
>
> Hi, everyone.
>
> I have a question for the following example.
>
> Firstly, in the view.py:
>
> def test_1(request, zipcode, pro):
>  if zipcode == 'a' and pro == 'b':
>city = 'c'
>  else:
>city = ''
>
>  return HttpResponse(city)
>
> def test_0(request):
>  return render_to_response('test_0.html', {})
> -
> Then, in the test_0.html
>
> 
> 
> 
> Register form
> 
> 
>  function getZipData() {
>var zipcode = $('#zip').val();
>var pro = $('#pro').val();
>$.get('<a  rel="nofollow" href="http://127.0.0.1/ajax/test_1/">http://127.0.0.1/ajax/test_1/</a>' + zipcode + '&' + pro +
> '/' , function(data) {
>  $('#city').attr({'value':data});
>});
>  }
> 
> 
> 
> 
> 
> Pro:
> Zip:
> City:
> 
> 
> 
> 
>
> --
> In the urls.py
>
> (r'^ajax/test_0/$', test_0),
> (r'^ajax/test_1/(\S+)/$', test_1),
> ---
> When I input b to the Pro inputbox and a to the Zip inputbox, and
> click the done button, the firebug displays :500 Interserver Error
>
> I think there are some problem with the  $.get('http://127.0.0.1/ajax/
> test_1/' + zipcode + '&' + pro +  '/' , function(data) {$('#city').attr
> ({'value':data}); }); OR
>
> def test_1(request, zipcode, pro):
>  if zipcode == 'a' and pro == 'b':
>city = 'c'
>  else:
>city = ''
>
>  return HttpResponse(city)
>
> Could you please give me some idea?
>
Test your Ajax URL agains the view directly with the browser. It's
seems there is some kind of problem there.
view: def test_1(request, zipcode, pro):
url (r'^ajax/test_1/(\S+)/$', test_1)
At firsth sight they don't match with
http://127.0.0.1/ajax/test_1/' + zipcode + '&' + pro +"/"

Try:
url  = r'^ajax/test_1/(?P\w+)/(?P\w+)/$ ...
and
http://127.0.0.1/ajax/test_1/' + zipcode + '/' + pro +"/"

Hope it helps!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: HttpResponse post

2009-02-16 Thread Antoni Aloy

2009/2/16 Mike :
>
> Hi all,
>
> I m not familiar with django and I have found several problems trying
> to sent a httpresponse with post parameters. I would like to return an
> httpresponse (or httpredirect) to a new url with the request
> parameters via post.
>
> Could anybody help me?
> Thank you in advance,
> Miguel
>
> I have defined a new view:
>
> def prueba(request, seccion):
>  if request.POST:
>new_data = request.POST.copy()
>
> [get all the parameters]
> [send a mail if correct]
>
>
>response = HttpResponse ("newUrl")
>#¿POST?
>return HttpResponseRedirect(response)
>

After a post you should use a HttpResponseRedirect(url). If you need
to have access to the post parameters an option is to save them in a
session, or encode them in the url itslef.

Hope it helps!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: HttpResponse post

2009-02-17 Thread Antoni Aloy

2009/2/17 Miguel :
> thanks karen, that is what I meant.
> So there is no way to return in my views.py an external web html with post
> parameters ... it must be a way to do that, dont think so?
>
Yes, but you can't do it this way.

Just check for httplib and httplib2.

http://code.activestate.com/recipes/146306/

or from Python documentation in http://docs.python.org/library/httplib.html

>>> import httplib, urllib
>>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> headers = {"Content-type": "application/x-www-form-urlencoded",
..."Accept": "text/plain"}
>>> conn = httplib.HTTPConnection("musi-cal.mojam.com:80")
>>> conn.request("POST", "/cgi-bin/query", params, headers)
>>> response = conn.getresponse()
>>> print response.status, response.reason
200 OK
>>> data = response.read()
>>> conn.close()

Hope it helps!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Authentication with LDAP

2009-02-18 Thread Antoni Aloy

2009/2/18 João Olavo Baião de Vasconcelos :
> Hi all,
>
> I'd like to login in Admin site and authenticate with LDAP. Is there a "most
> used LDAP authentication backend"?
> I found the backend ldapauth.py [1], that seems to be the one. Is this the
> best solution?
>
> I see that in [2] that are many patches. Is the file in [1] updated, or do I
> have to apply the patches?
>
> [1] http://code.djangoproject.com/attachment/ticket/2507/ldapauth.py
> [2] http://code.djangoproject.com/ticket/2507
>

This is a quite nice tutorial, perphaps it would help you.

http://www.carthage.edu/webdev/?p=12

The LDAP backend is quite simple, as it Active Directory backend, so
perhaps you can debug it and tell where is your problem. On the other
hand, remember that the ldap backend would be begore the default
backend.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Authentication with LDAP

2009-02-19 Thread Antoni Aloy

2009/2/19 João Olavo Baião de Vasconcelos :
> On Wed, Feb 18, 2009 at 7:17 PM, Antoni Aloy  wrote:
>>
>> This is a quite nice tutorial, perphaps it would help you.
>> http://www.carthage.edu/webdev/?p=12
>
> Thanks for the advice, Antoni.
>
> I tried authenticating with LDAP using the python interpreter, and I got
> this error:
>
>>>> import ldap
>>>> l = ldap.initialize('ldap://SERVER.DOMAIN.biz:389'
>>>> l.simple_bind_s('USER', 'PASSWD')
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 176, in
> simple_bind_s
> return self.result(msgid,all=1,timeout=self.timeout)
>   File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 405, in
> result
> res_type,res_data,res_msgid = self.result2(msgid,all,timeout)
>   File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 409, in
> result2
> res_type, res_data, res_msgid, srv_ctrls =
> self.result3(msgid,all,timeout)
>   File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 415, in
> result3
> rtype, rdata, rmsgid, serverctrls =
> self._ldap_call(self._l.result3,msgid,all,timeout)
>   File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 94, in
> _ldap_call
> result = func(*args,**kwargs)
> INVALID_CREDENTIALS: {'info': '80090308: LdapErr: DSID-0C090334, comment:
> AcceptSecurityContext error, data 525, vece', 'desc': 'Invalid credentials'}
>
> I didn't find any help googleing for the error (DSID-0C090334). I'm using
> simple_bind_s() as my LDAP server does not allow anonymous queries. (I also
> tried using bind_s(), with my real LDAP user, but also didn't work).
>
> Do I have to setup anything else before do a simple_bind_s(), as the
> ldap-group?
>
At least in our LDAP configuration, there are restrictions about the
kind of queries that a user can do. So check also this. Use your
account to see if you can log in, and try to run the function step by
step inside the shell.

I you don't have restrictions on your LDAP the most commont issue is
with the LDAP base tree. That is where the user tree resides in your
organization. Use the step by step debugger to know if you can connect
to LDAP and check if there is aproblem just with LDAP configurations.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Django MPTT Admin

2009-02-26 Thread Antoni Aloy

2009/2/26 Matthias Kestenholz :
>
> Hey,
>
> A topic which comes up on this list from time to time is an automatic
> admin interface for django-mptt. I'd like to advertise a piece of code
> we have written at our company a little bit, and I'd also like to invite
> everyone to give comments and feedbacks. I do have many more ideas
> floating around, and there are a couple of issues still open, but I think
> the code is ready for wider review and maybe usage, who knows?
>
>
> The current version of the code generates an interface with drag/drop
> capabilities for managing mptt-based trees. It's still very clear that the
> code was extracted from a `classical' page cms. All you need to do
> is the following:
>
>
> -- 8< --
>
> from django.db import models
>
> class Category(models.Model):
>    title = models.CharField(max_length=200)
>    parent = models.ForeignKey('self', related_name='children',
> blank=True, null=True)
>
> -- 8< --
>
> from django.contrib import admin
> from feincms.admin import editor
>
> class CategoryAdmin(editor.TreeEditorMixin, admin.ModelAdmin):
>    pass
>
> admin.site.register(Category, CategoryAdmin)
>
> -- 8< --
>
> The generated admin interface looks like that:
>
> http://spinlock.ch/pub/feincms/category_tree_admin.png
>
> The page cms feeling is still very much there, but we'll see.
>
> In any case, you'll find the code on github:
> http://github.com/matthiask/feincms/tree/master
>
>
> Thanks,
> Matthias
>
>

It seems very nice. I'm going to give it a try. :)

Thank you!



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: i'm use first time how to use it

2009-02-28 Thread Antoni Aloy

2009/2/28 NK B :
>
> hello
>     i 'm use first  time. so don't know about DJango so u help me how
> installed it and  develop it
>
>
Just follow the Django tutorial and the ask in the list any problems you have.

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Should I use Django?

2009-03-08 Thread Antoni Aloy

2009/3/8 Wiiboy :
>
> Hi guys,
> I'm making a small site (small for now, at least), that isn't quite
> finished yet.  I'm the only one who is writing server-side code.
> Presently, I'm writing straight Python code, through CGI, on a shared
> hosting provider.  Is there any reason why I should use Django on my
> site, on the Google App Engine?
> --~--~-~--~~~---~--~~
Is there any reason you should'nt? Plain CGI code sounds quite old
even for me ;)

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Should I use Django?

2009-03-08 Thread Antoni Aloy

2009/3/8 Wiiboy :
>
>> Is there any reason you should'nt? Plain CGI code sounds quite old
>> even for me ;)
>
> I'd have to rewrite everything. :(
It depens on your code. Perhaps you can reuse the logic and just write
the urls and views. Just check Django, I think it's worth as it could
make the project more maintenable in the future.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: trouble w/images

2009-06-20 Thread Antoni Aloy

Look at:

http://code.google.com/p/appfusedjango/

You'll find some examples of uploading images both as an application
and batch mode.

2009/6/20 django_jedi :
>
> Hi Folks,
>
> I'm having a devil of a time trying to get image uploading to work.
> What I'd like to do is simply upload and image.
>
> This works with:
>
> my_object = ImageTest.objects.create()
>
> ...but if  not with:
>
> my_object = ImageTest.objects.get_or_create(user_id=7,
> image=imagepath)
>
> Any ideas?
>
> Alternatively, if anyone out there has a *simple* example of how to
> upload an image, I would appreciate knowing.  Just want to get things
> off the ground.
>
> My views.py is below.  (The model is a simple 2-field model w/t/fields
> in question.  "user_id" is not a Foreign Key to "User").  There is
> some hard-coding as I'm just testing right now.
>
> Thanks in advance for any help you can offer.
>
> =
> from PIL import Image
>
> try:
>    import cStringIO as StringIO
> except ImportError:
>    import StringIO
>
> #from django import newforms as forms
> from django import forms
> from django.conf import settings
>
> from models import ImageTest
>
> from django.shortcuts import get_object_or_404, render_to_response
> from django.http import HttpResponseRedirect
> from django.views.generic.simple import direct_to_template
> from django.core.urlresolvers import reverse
> from django.template import RequestContext
> from myproject.uploadtest.models import ImageTest
>
> from django.core.files import File
>
> import os
>
> class ImageTestForm(forms.Form):
>    """
>    Profile image upload form.
>    """
>    image = forms.ImageField(widget=forms.FileInput())
>
>
> def my_view(request):
>    if request.method == 'POST':
>        form = ImageTestForm(request.POST, request.FILES)
>        if form.is_valid():
>                handle_uploaded_image(request.FILES['image'])
>                return HttpResponseRedirect('/')
>
>    else:
>        form = ImageTestForm()
>
>    return direct_to_template(request, 'uploadtest/image_upload.html',
> {'image_upload_form': form})
>
>
>
> def handle_uploaded_image(i):
>    # resize image
>    imagefile  = StringIO.StringIO(i.read())
>    imageImage = Image.open(imagefile)
>
>    # (width, height) = imageImage.size
>    # (width, height) = imageImage.scale_dimensions(width, height,
> longest_side=240)
>
>    width = 200
>    height = 200
>
>    resizedImage = imageImage.resize((width, height))
>
>    imagefile = StringIO.StringIO()
>    resizedImage.save(imagefile,'JPEG')
>    filename = 'foo5.jpg'
>
>    # #save to disk
>    imagefile = open(os.path.join('/tmp',filename), 'w')
>    resizedImage.save(imagefile,'JPEG')
>    imagefile = open(os.path.join('/tmp',filename), 'r')
>    content = File(imagefile)
>
>
>    path = 'img/testupload/2009/06/20/'
>    imagepath = path + filename
>
>    #my_object = ImageTest.objects.all()
>
>    #my_object = ImageTest.objects.get_or_create(user_id=7,
> image=imagepath)
>    my_object = ImageTest.objects.create()
>    my_object.image.save(filename, content)
> =
>
> >
>



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Sessions Not working.

2009-06-25 Thread Antoni Aloy

2009/6/25 lc :
>
> Production Box spec: mandrake 10.1.1,  python2.3,
> libmysql15-5.0.1,   MySQL1.0,  Django 1.0.
>
> can't get sessions to work. My site (and sessions) works on my
> development box with a more or less current version of ubuntu, when I
> copy over the project to the production box it does not work. I have
> run "python manage.py syncdb" and the database is created correctly, I
> have made sure the settings.py is correct, but Djangos debug page
> states there is "No Cookie Data" when I navigate to the site.


Are your working with sessionss? That is, are your working with the
session object and saving there some information? On the afirmative
case check the object you're using, perhaps is a lazy object or a non
serializable one.

You can check also where are saving your sesion data. Are you sure
you're saving it in the database?

>From your configuration I just see python2.3 too old for my
preferences. You should also use Django 1.0.2 as its the last estable
version (if you don't want to work in the cutting edge of course).

Hope it helps!
-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Password-protecting PDF downloads?

2009-06-29 Thread Antoni Aloy

2009/6/29 Rajesh Dhawan :
>
>
>
> bax...@gretschpages.com wrote:
>> This is probably more of a python question, but here goes: Can anyone
>> point me to a method of dynamically attaching a password to a PDF and
>> protecting the file before it's downloaded?

Take a look at 
http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/
to port to Django or http://www.djangosnippets.org/snippets/491/

On this way you can control who has the rights to download a file
without password protecting it.

Hope it helps!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: dynamic inserting items to template

2009-08-10 Thread Antoni Aloy

2009/8/10 elminio :
>
> Hello,
> Is it possible to insert to the template for example 10 checkboxes
>
> I know syntax of iterating through objects in list and do some task
> for each item but Im interested in normal for loop
> like
>
> for i in xrang(10):
>    insert checkbox
>
> thanks for reply
>
>
You can create a template tag to do the work for you and pass the
number of items you want as a parameter. You can also create using
javascript and use a django template variable to set the counter.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: is Django a good choice for a LAN app?

2009-08-11 Thread Antoni Aloy

2009/8/11 snfctech :
>
> I'm about to start a fairly large project for a mid-sized business
> with a lot of integration with other systems (POS, accounting,
> website, inventory, purchasing, etc.) The purpose of the system is to
> try to reduce current data siloing and give employees role-based
> access to the specific data entry and reports they need, as well as to
> replace some manual and redundant business processes. The system needs
> to be cross-platform (Windows/Linux), open source and is primarily for
> LAN use.
>
> My experience is mostly PHP/web/app development, but I have developed
> a few LAN apps using Java/Servoy (like Filemaker). I am leaning
> towards Python/Django - but wondering whether this may be
> unnecessarily web-specific. I really felt Servoy development was very
> rapid, and it was cross-paltform, but it was not open source (not to
> mention that anything custom needed to be Java which I find too
> verbose/ slow to develop in). Or maybe Open Office Base and some
> scripting is sufficient to handle my needs.
>
> So, my main question is: Does a web framework like Django sound like a
> reasonable platform to build a LAN Dashboard for a mid-sized company?
> Or am I thinking too much like a web developer?
>

Well, in my oppinion web application has sense because you are going
to forget about upgrading the application each time there is a new
version of windows, and makes the updates a pleasure. You can make the
applications as complicated as you want, you can use Django and add a
javascript front end (Dojo, Extjs, jQuery UI, Qoodoxx, etc) or just
give the users a simple  interface to do they work, you have both
options.

Python means you can make a rapid development and that you have lots,
tons of libraries and routines that are goint to help you. Actually
developing web applications for internal use has lot of sense and
protects your inversion, as the actual application you're making today
for internal use, coud be accessible from outside the company with
nearly no effort.

Just my two cents.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: i18n javascript problem

2009-08-18 Thread Antoni Aloy

2009/8/18 caiobos :
>
> Hello!
> My project is alredy working with i18n, but the i18n js doesnt work.
> I have created my dir locale at the root of the project, have run
> makemessages and it create the djangojs.po correcty. With compile
> messages I get the djangojs.mo ok.
> The problem is how i confgure it in URLconf, if i make:
>
> js_info_dict = {
>    'packages': ('project',),
> }
> urlpatterns += patterns('',
>    (r'^jsi18n/$', 'django.views.i18n.javascript_catalog',
> js_info_dict),
> )
>
> It doesnt work, but if I do:
> js_info_dict = {
>    'packages': ('django.conf',),
> }
>
> I get the traduction from the django package(but I dont want it, I
> want my package).
> So how i get it? How can it works with my traduction?
>
> Thanks a lot.
> Caio
>
>
project is the name of your project, isn't it? You have to remember to
include the url for the translation javascript as 

the documentatios is well explained.


On the other hand, I have experienced some problems getting the
javascript keys from the templates. The workarround I have found is to
have all the javascript (or nearly all) in external js files, a best
practice anyway.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Django and ZSI

2009-08-31 Thread Antoni Aloy

2009/8/31 Julián C. Pérez :
>
> Anyone has experience with using web services in Django??
> I mean, not necessarily with ZSI but others methods...
>

Yes, we have many of the working. But this is no a Django issue is
more a Python programming one. You can access to Soap web services
using ZSI, SUDS, Soappy or whatever you like to use.

Isolate the web service client and use the parts you need. We have
worked with ZSI mainly, but actually we're moving to Suds.

To act a a server we prefer to simplify and we're using xml over http
or REST services. Both live perfectly with Django.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Showng the primary key in admin view

2009-09-01 Thread Antoni Aloy

2009/9/2 Mike Dewhirst :
>
> Joakim Hove wrote:
>> Hello,
>>
>> I have a (simplified) model like this
>>
>> class Customer(models.Model):
>>      name  =   models.CharField(max_length = 100)
>>      date    =   models.DateTimeField()
>>      email  =   models.EmailField()
>>
>>
>> When showing this in the (100 % default) admin view I get up nice
>> entry boxes for the fields 'name', 'date' and 'email'. In addition I
>> would very much like to display the 'id' field which django has
>> automatically added (preferably as readonly). Any tips on how to
>> achieve this?
>
>     @property
>     def id_field(self):
>         return self.pk
>
>     def __unicode__(self):
>         return u'%s : %s' % (self.id_field, self.name)
>

Why not just

def __unicode__(self):
 return u'%s : %s' % (self.id, self.name)

On the other hand it you can use also list_display, but requires to
create an admin.py file.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Django, Blueprintcss and a data array

2009-09-05 Thread Antoni Aloy

2009/9/5 adelaide_mike :
>
> I (newbie) am looking at using Blueprintcss to display a 7 column
> array of data. The data is passed to the template in "dataarray".  I
> have tested the code below without the  section and the column
> headings display correctly.
>
> Adding the  section to the code causes an error at {% for row
> in dataarray %}:
>   Caught an exception while rendering: 'int' object is not iterable
>
> Very similar code in a template that uses a simple table (without
> Blueprint) does not throw an error.
>
> {% extends "base.html" %}
> {% block content %}
>
> 
> 
>            Agent summary report
>        The most recent listing for each property listed within the
> past 12 weeks
>       
>               Address
>               Date
>               Price
>               Method
>               Agent
>                 
>               Mobile
>       
>
>       
>           {% for row in dataarray %}
>
>                
>                    {% for item in row %}
>                        {{ item }}
>                    {% endfor %}
>                 
>
>           {% endfor %}
>        
> 
>
> 
>
> {% endblock %}
>
I would add  surronding the table code, but I can't see
any problem. Please post the error. In my oppinion you'll have to
check the dataarray as it seems that one of the rows in now a list.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Django / Postrges problem

2009-03-25 Thread Antoni Aloy

2009/3/25 Szymon :
>
> Hello Django users,
>
> I have big problem. For a few days my site isn't working properly. We
> have two interfaces. First connected to Apache, second is cron job
> running every 10 minutes (using Django ORM etc.). The problem is when
> that job is running, there is some ExclusiveLock on postgres and web
> interface have some lags, big lags. It's just like site stops working
> for 1-2 minutes when there is cron job running. Any hints?
>

The obvious one: check your cron job .. Log your queries in postgres
to see which querie consumes more time, it should be the cron job one.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Fulltext searching

2009-03-27 Thread Antoni Aloy

2009/3/26 Malcolm Tredinnick :
>
> On Thu, 2009-03-26 at 14:37 -0700, TheIvIaxx wrote:
>> So i have been trying to get a solid search going in django.  I have
>> seen things liek Whoosh and Solr or Lucene(sp?) which all add fulltext
>> searching to your models.  Are these better than the mysql fulltext
>> searches?

I prefer to stay away from database indexing so the application is
database agnostic. I have integrated xapian successfully in some
projects using django-xapian, and it works quite well. You can see it
in action in trespams.com.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: multiple django versions in mod_python

2009-04-04 Thread Antoni Aloy

2009/4/4 pault :
>
>  I have one version 1.02 installed in /var/lib/python-support/
> python2.5/django/ (i am on a debian machine)
>  and one version 0.96 in the folder of my project.
>
> I read the post from Graham but it doesn't seem to work for me it uses
> the 1.02 version.
> http://groups.google.com/group/django-users/browse_thread/thread/1c5c461a49c28e41/5c61b32e99325dde?lnk=gst&q=multiple+versions#5c61b32e99325dde
>
>  "/">
> PythonInterpreter
> django.blabla
> SetHandler python-
> program
> PythonHandler
> django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE
> blabla.settings
> PythonDebug
> On
> PythonPath "['/home/paul','/home/paul/blabla/django'] +
> sys.path"
> 
>
> How can I get my old sites working through mod_python

we use virtualenv for that
http://blog.ianbicking.org/2007/10/10/workingenv-is-dead-long-live-virtualenv/,
that allows us to mantain diferent versons of applications with their
own dependencies.

Best regards,


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Novice. - _unicode_(self) not working. :(

2009-04-05 Thread Antoni Aloy

2009/4/5 Nandha :
>
> Hi,
>
> I just started trying out Django. I am new to python too.!!
>
> I started with poll app in the tutorial.
>
> Adding _unicode_(self):  does not seem to change anything. I saw that
> it could be because i am using older version so i followed the
> installation guide and installed the development version.
>
> Did not help!!
>
> This is the models.py
> class Poll(models.Model):
>        question = models.CharField(max_length=200)
>        pub_date = models.DateTimeField('date_published')
>        def  _unicode_(self):

__unicode__(self)

with two underscores

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: How to get session data from template

2009-04-05 Thread Antoni Aloy

2009/4/5 Joshua Partogi :
>
> Dear all,
>
> I'd like to get session object because I would like to figure out
> whether a user is still logged in or not. I tried searching the
> documents but could not find a way to do it.
> Using {% if user.is_authenticated %}, the user object is only
> available in one request but will be dissapeared in the next request.

In your render_to_response don't forget to add
context_instance=RequestContext(request)

Hope it helps!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: how to redirect to previous page

2009-04-21 Thread Antoni Aloy

2009/4/21 Margie :
>
> Can anyone advise me on what is the best way in the views.py code to
> return an HttpResponse that simply returns the user to the previous
> page they were on?
>
> For example, let's say that multiple different pages have a button
> that executes some code in views.py, but is not intended to actually
> take the user to a new page.  So after executing that code, I just
> want to redisplay the previous page they were looking at.
>
> On a slightly more complicated note, say multiple different pages have
> a button that executes some code and then does redirect the user to
> page 'foo'.  Now when the user clicks a 'submit' button on page
> 'foo',  I would like to take them back to wherever they were before
> they got to page 'foo'.
>
> How do others deal with this?
>
> Thanks
>

You can save the previous page in a session variable before making the
redirect and then use it in the foo page.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Category list in Django

2009-05-10 Thread Antoni Aloy

2009/5/10 Bro :
>
> How to create a correct Tree of category ?
>
Take a look at django-mptt at http://code.google.com/p/django-mptt/ it
would help you a lot.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Category list in Django

2009-05-10 Thread Antoni Aloy

2009/5/10 Bro :
>
> Thanks, I try to use django-mptt.
> I've installed it but how do you use it ?
>
You have the documentation at:

http://django-mptt.googlecode.com/svn/trunk/docs/models.txt

mptt will give you lots of extra messages to deal with the category tree.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Parsing the arguments in HTTP GET

2009-05-15 Thread Antoni Aloy

2009/5/15 MohanParthasarathy :
>
> Hi,
>
> I am very new to django. I am following along the tutorial. But I want
> to be able to parse the URL which has the following form:
>
> http://example.com/data/?ui=2&shva=1#label&name=/fetch
>
> From what I can tell, i can't match the whole thing using the url
> pattern. I can parse up till "http://example.com/data"; and the rest in
> the code. Where can i find examples/tutorials for the above format ?

You can capture the parameters in your  view with request.GET (see
http://docs.djangoproject.com/en/dev/ref/request-response/)
or you can rethink your application urls so they could be as:
http://example.com/data/2/1#label//fetch
so they could match
^data/(?P\d+)/(?P\w+)/(?P\w+)/(?P)/$

hope it helps.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Trouble using pdb with manage.py runserver

2009-05-16 Thread Antoni Aloy

2009/5/15 Joshua Russo :
>
> I'm starting the debugger like so:
>
> (from the dir containing manage.py) python -m pdb manage.py  runserver
>
> it starts just fine, showing it paused at the first line. I set my
> break points using "b filename: line#". This reports that the
> breakpoint is set, and it seems as though it's in the right file
> because I had modified the file at one point and the previous line
> number I was using was then a blank line when I went to set the break
> point.
>
> The files I'm trying to set the breakpoints in are only called on a
> page request. So I tell the debugger to just continue and start the
> server. When I request a page it doesn't stop at my breakpoints.
>
> I'm thinking that the debugger is loosing context when the server is
> started, or something to that effect. I've been using NetBeans but the
> system I'm using is fairly old and I believe its speed is exacerbating
> bugs in the Python plug-in.
>
> I've seen some posts that have mentioned using pdb and I really want
> to try it out. What am I doing wrong here?
>
Hav wyou test it with the noreload parameter?

On the other hand I prefer to use

import pdb; pdb.set_trace()

in my code to set the breakpoint.

You can also use winpdb, or even the Eclipse+pyDev debugger, but you
have to run manager with the noreload option.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Counting pageviews

2009-05-16 Thread Antoni Aloy

2009/5/15 Oleg Oltar :
> Hi!
>
> I am writing simple article manager application. Is there a way I can store
> pageviews number for my articles in database (want to display them in
> future, and use for rating on site)
>
> Thanks in advance,
> Oleg
>
You can use google analytics for that.
You can store it also in your views before displaying the page or you
can use your own javascript method.

Perhapts I don't understand the question, but if you own the site you
can do whatever you want. If you use the view method you can't use
cache and this could have a great impact in performance. It depends on
your needs and application.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: how to refer a foreign key to a non primary column from other model

2009-05-16 Thread Antoni Aloy

2009/5/16  :
>
> Hi All,
>
> Need help in creating foreign key column in a table.
>
> In the below model I would like to create a foreign key for the field
> 'new_foreign_col' which should refer to 'username' column (non primary
> column) from auth_user table.
>
> class details(models.Model):
>   new_foreign_col = 
>

http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey
Check: ForeignKey.to_field

Hope it helps!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: parsing data from fileupload

2009-05-17 Thread Antoni Aloy

2009/5/17 Patrick :
>
> How do I add data from a fileupload to a database?
> For example, if I have a Book model that is for names of books and a
> FileNames model that is used on a form, how do I populate Book.title.
>
> class FileNames(models.Model):
>    title = models.FileField(upload_to='tmp', blank=False)
>
>
> class Book(models.Model):
>    title = models.CharField(max_length=30)
>
> I'm able to upload and parse the file.  I'm just not sure how to add
> the parsed data to Book.
>
So FileNames is not a real table? I'm confused ...

Please check http://docs.djangoproject.com/en/dev/topics/http/file-uploads/
it would help you a lot to deal with file uploads.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Free eBook: Django 1.0 Website Development

2009-05-22 Thread Antoni Aloy

2009/5/22 leveille :
>
> I'm doing my best to give away a few books, however, due to my very
> poor site traffic, I'm not having much luck.  So, if you are new to
> Django and you are interested a free book (Django 1.0 Website
> Development, published by Packt), or if you know someone who could
> benefit from a good Django book, than visit:
> http://jasonleveille.com/2009/05/free-web-development-ebooks and leave
> a comment.

Perhaps I'm confused and you have the rights to publish and distribute
that book but if this is not the case you should avoid this kind of
posts.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: image upload

2009-06-05 Thread Antoni Aloy

2009/6/5 Dhruv Adhia :
>
> I am new to django and was searching for thorough tutorial for image
> upload.
>
> What I want to do is add image upload field in backend and after
> uploading image from admin section it shows in frontend
>
like this 
http://code.google.com/p/appfusedjango/source/browse/#svn/trunk/thumbs_prj?


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: View arguments via url are not being passed to the view.

2009-06-13 Thread Antoni Aloy

2009/6/13 wilby :
>
> Hi group,
>
> I am having a problem getting text in the url to be passed as
> arguments to my view.
>
> My defined urls are:
>
> 
> (r'^notes/', 'notes'),
Shoud be
(r'^notes/$', 'notes'),

if you mantain as it is it matches also notes/a/0/ so the second url
never captures the parameters.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Complex global footer

2009-06-14 Thread Antoni Aloy

2009/6/14 Alex Gaynor :
>
>
> On Sun, Jun 14, 2009 at 3:46 PM, compbry15  wrote:
>>
>> Hey all,
>>
>> I am working on a website in which we want the same footer to display
>> on all pages.  This normally wouldn't be a problem with django, in
>> fact it would be really easy.  The catch here is that we want certain
>> objects to be available on this footer.  So no matter what page you
>> were on, if you went down to the footer it would show like the 3
>> latest blog posts, latest picture, etc etc.
>>
>> So far I have the footer code in the base.html template, and have
>> abstracted out a helper function that gets all the necessary records
>> and puts them in a dictionary to be passed into a template.  The
>> display works fine for pages that I have manually changed the views to
>> call the helper function and pass in the necessary dictionary values,
>> but i'll have to do this for all pages... And that just seems wrong.
>>
>> I am having trouble finding a proper way to phrase this question for
>> searching the django docs and google, so was wondering if anyone had
>> any ideas for doing this in a DRY sort of fashion.
>>
>> Thanks!
>>
>
> The best way to solve this would either be a template inclusion tag, or a
> template context processor.


Other way could be to create your own template tag. Write it and use
it in the footer. Remember that is just Python code, so you can use
the Django cache API. Use the template tag in the base.html and
inherit the other templates from base.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Running Django on Tornado's HTTP server

2009-09-13 Thread Antoni Aloy

2009/9/13 Bret Taylor :
>
> I am one of the authors of Tornado (http://www.tornadoweb.org/), the
> web server/framework we built at FriendFeed that we open sourced last
> week (see http://bret.appspot.com/entry/tornado-web-server).
>
> The underlying non-blocking HTTP server is fairly high performance, so
> I have been working this weekend to get other frameworks like Django
> and web.py working on Tornado's server so existing projects could
> potentially benefit from the performance. To that end, I just checked
> in change to Tornado that enables you to run any WSGI-compatible
> framework on Tornado's HTTP server. You can find it in a class called
> WSGIContainer in our wsgi.py:
>
> http://github.com/facebook/tornado/blob/master/tornado/wsgi.py#L188
>
> You will have to check out Tornado from github to get the change; it
> is not yet included in the tarball distribution.
>
> Here is a template for running a Django app on Tornado's server using
> the module:
>
>    import django.core.handlers.wsgi
>    import os
>    import tornado.httpserver
>    import tornado.ioloop
>    import tornado.wsgi
>
>    def main():
>        os.environ["DJANGO_SETTINGS_MODULE"] = 'myapp.settings'
>        application = django.core.handlers.wsgi.WSGIHandler()
>        container = tornado.wsgi.WSGIContainer(application)
>        http_server = tornado.httpserver.HTTPServer(container)
>        http_server.listen()
>        tornado.ioloop.IOLoop.instance().start()
>
>    if __name__ == "__main__":
>        main()
>
>
> I have only done very basic tests using the new module, so if any of
> you are interested and start using Tornado with your Django projects,
> please let us know what bugs you find so we can fix them. Any and all
> feedback is appreciated.
>

We're acually using Cherrypy, so it would be quite easy to test and
check the performance. We'll post any issues we found.


Thank you!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Running Django on Tornado's HTTP server

2009-09-14 Thread Antoni Aloy

2009/9/13 Antoni Aloy :
> 2009/9/13 Bret Taylor :
>>
>> I am one of the authors of Tornado (http://www.tornadoweb.org/), the
>> web server/framework we built at FriendFeed that we open sourced last
>> week (see http://bret.appspot.com/entry/tornado-web-server).
>>
>> The underlying non-blocking HTTP server is fairly high performance, so
>> I have been working this weekend to get other frameworks like Django
>> and web.py working on Tornado's server so existing projects could
>> potentially benefit from the performance. To that end, I just checked
>> in change to Tornado that enables you to run any WSGI-compatible
>> framework on Tornado's HTTP server. You can find it in a class called
>> WSGIContainer in our wsgi.py:
>>
>> http://github.com/facebook/tornado/blob/master/tornado/wsgi.py#L188
>>
>> You will have to check out Tornado from github to get the change; it
>> is not yet included in the tarball distribution.
>>
>> Here is a template for running a Django app on Tornado's server using
>> the module:
>>
>>    import django.core.handlers.wsgi
>>    import os
>>    import tornado.httpserver
>>    import tornado.ioloop
>>    import tornado.wsgi
>>
>>    def main():
>>        os.environ["DJANGO_SETTINGS_MODULE"] = 'myapp.settings'
>>        application = django.core.handlers.wsgi.WSGIHandler()
>>        container = tornado.wsgi.WSGIContainer(application)
>>        http_server = tornado.httpserver.HTTPServer(container)
>>        http_server.listen()
>>        tornado.ioloop.IOLoop.instance().start()
>>
>>    if __name__ == "__main__":
>>        main()
>>
>>
>> I have only done very basic tests using the new module, so if any of
>> you are interested and start using Tornado with your Django projects,
>> please let us know what bugs you find so we can fix them. Any and all
>> feedback is appreciated.
>>
>
> We're acually using Cherrypy, so it would be quite easy to test and
> check the performance. We'll post any issues we found.
>
>
Just few numbers:

ab -c 10 -t 60 http://localhost:8088/
Executing Django with Cherrypy with 3 threads on a PPC Computer 2 CPU 2 GHz

With Tornado WSGI:
ab -c 10 -t 60 http://localhost:/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 5000 requests
Completed 1 requests
Completed 15000 requests
Completed 2 requests
Completed 25000 requests
Finished 25022 requests


Server Software:TornadoServer/0.1
Server Hostname:localhost
Server Port:

Document Path:  /
Document Length:266 bytes

Concurrency Level:  10
Time taken for tests:   60.019 seconds
Complete requests:  25022
Failed requests:0
Write errors:   0
Total transferred:  9333206 bytes
HTML transferred:   6655852 bytes
Requests per second:416.90 [#/sec] (mean)
Time per request:   23.987 [ms] (mean)
Time per request:   2.399 [ms] (mean, across all concurrent requests)
Transfer rate:  151.86 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.1  0   6
Processing: 3   24   1.9 24  68
Waiting:0   24   1.9 23  68
Total:  7   24   1.9 24  68

Percentage of the requests served within a certain time (ms)
  50% 24
  66% 24
  75% 24
  80% 24
  90% 25
  95% 26
  98% 27
  99% 28
 100% 68 (longest request)


Using CherryPy with 3 threads (the best configuration for my computer
in my tests)


ab -c 10 -t 60 http://localhost:8088/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 5000 requests
Completed 1 requests
Completed 15000 requests
Completed 2 requests
Finished 21500 requests


Server Software:CherryPy/3.0.3
Server Hostname:localhost
Server Port:8088

Document Path:  /
Document Length:266 bytes

Concurrency Level:  10
Time taken for tests:   60.001 seconds
Complete requests:  21500
Failed requests:0
Write errors:   0
Total transferred:  8299000 bytes
HTML transferred:   5719000 bytes
Requests per second:358.33 [#/sec] (mean)
Time per request:   27.907 [ms] (mean)
Time per request:   2.791 [ms] (mean, across all concurrent requests)
Transfer rate:  13

Re: Running Django on Tornado's HTTP server

2009-09-19 Thread Antoni Aloy

2009/9/19 Kenneth Gonsalves :
>
> On Monday 14 Sep 2009 1:56:32 am Bret Taylor wrote:
>> he module:
>>
>>     import django.core.handlers.wsgi
>>     import os
>>     import tornado.httpserver
>>     import tornado.ioloop
>>     import tornado.wsgi
>>
>>     def main():
>>         os.environ["DJANGO_SETTINGS_MODULE"] = 'myapp.settings'
>>         application = django.core.handlers.wsgi.WSGIHandler()
>>         container = tornado.wsgi.WSGIContainer(application)
>>         http_server = tornado.httpserver.HTTPServer(container)
>>         http_server.listen()
>>         tornado.ioloop.IOLoop.instance().start()
>>
>>     if __name__ == "__main__":
>>         main()
>
> cool - this worked out of the box - but no css and js - can I serve media from
> tornado, and if so, a pointer as to how?
> --

Have you properly configured your  MEDIA_URL to point to your Tornado
server instead of localhost:8000. I haven't made any test about
Tornado performance on serving statig files, but on production our
actual configuration with CherryPy in WSGI mode involves a nginx
server acting as a reverse proxy and serving the media files.

I use the configuration without nginx pointing directly to the WSGI
server just to make sure that all the media points to right server.
That is, that I have write all my media files as
{{MEDIA_URL}}/img/.jpg and so on.

Hope it helps!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Breakpoints in NetBeans

2009-09-21 Thread Antoni Aloy

2009/9/21 Kevin Bache :
> Thanks for both of your ideas.
>
> Joshua: It is stopping on the first line of code, and I can step through the
> manage.py module and if I recall (I'm not in front of my computer at the
> moment) it catches breakpoints in other files (ex: settings.py) in the
> initial load.  What I can't seem to get is breakpoints triggered by the
> browser.  Have you ever had success with that?  Is it possible using
> Django's development server?  Using any server?
>
I have tried to use the Netbeans debugger with Django withou success,
even running with parameters as "python manage.py runserver
--noreload"
without success. PyDev debugger works very well with this feature.

Anyway, Netbeans is a good ide and runs much better than Netbeans in
my computer, so I use import pdb; pdb.set_trace()  and  usuall ipdb,
to set the breakpoint in the code. When I really need a visual
debugger and more advanced features I run python manage.py runserver
--noreload with winpdb, a nice graphical debugger which has nearly
everithing I like to have in Netbeans IDE.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Running Tornado instead of modwsgi apache

2009-10-15 Thread Antoni Aloy

2009/10/16 Graham Dumpleton :
>
>
>
> On Oct 16, 4:59 am, Ramdas S  wrote:
>> On Thu, Oct 15, 2009 at 11:11 PM, Christophe Pettus wrote:
>>
>>
>>
>> > On Oct 15, 2009, at 10:36 AM, Ramdas S wrote:
>>
>> > > I am currently running all my sites on modwsgi apache! Though I
>> > > cannot complain that the performance is bad, I would like to have
>> > > more.
>>
>> > Are you certain that the web server is the performance bottleneck?  In
>> > my experience, it rarely is.
>>
>> That argument aside, can we get an answer?
>
> But what he states is very important and shouldn't just be ignored.
>

I agree with Grahan if you're looking for performance first you have
to look at your own code, tune your database, then your web server and
then perhaps you have to consider other server options.

In our case our reason to move from apache+wsgi configuration to a
ngnix + WSGI CherryPy/Tornado configuration not was performace but
resources. Even loosing some performance the relation between the
number of requests per second and the memory and CPU consumed in the
computer was good enougth to justify the change.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Building a form to write one of two models

2009-10-16 Thread Antoni Aloy

2009/10/16 Luke Sneeringer :
>
> Good morning,
> I have two models that have mostly-similar fields (they both inherit
> from a single, abstract model in Django) and one different field. I'd
> really like it to be two separate tables in the database for
> normalization (each has a separate, one-to-many relationship with
> another table and the two are of distinct type and do not intersect).
>
> However, I would like to make a form that will seamlessly create (or
> edit) a row in one of these two tables. So, at first I set out to make
> a generic form (extending django.forms.Form) that displayed the
> fields, as well as a "type" ChoiceField that determined whether to
> save an instance of the first model or the second. Then, for editing,
> I simply have straight, unrelated django.forms.ModelForm classes that
> are instantiated.

You can create a factory for the form. That is, given the information
from the html, you choose wicht form to instantiate.

def get_form(param):
  if param == 'op1':
 return Form1
  elif param =='op2':
return Form2
...

On the view file

MyForm = get_form(param_from_request)

Form1 and Form2 are Modelforms


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: using ajax with django

2009-10-19 Thread Antoni Aloy

2009/10/19 neetu :
>
> Hi All
>
> I want to use ajax for my website.I am new to ajax.The backend code
> for my website uses django.
> I want to know the what are the things i need to install before using
> ajax for my website.should i download and install ajaxcontroltoolkit.
>
To use ajax you need to be able to make AJAX connections through
javascript and make your view.py code to return the right format
depending on the request (html, xml, json). So theres nothing special
you need to install.



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: "can't adapt" - mod_python, multiple interpreters, psycopg2

2009-10-21 Thread Antoni Aloy

2008/3/5 Pigletto :
>
>> > Problem is possibly with multiple interpreters and psycopg2 again,
>>
>> Why do you say that? The thread you refer to above doesn't talk about
>> mod_python, so do you have any extra evidence that support this claim?
> There was a bug in psycopg2 with Decimal data type that sometimes
> caused
> error like that:
> unsupported operand type(s) for *: 'Decimal' and 'Decimal'
>
> It was discussed on the list:
> http://groups.google.com/group/django-users/browse_thread/thread/091aa6c088f6c090
>
> Similarly to "can't adapt" it was raised sometimes, after apache was
> running for few days, etc.. When error appears, restarting apache
> causes everything to work fine but only for some time and then again,
> errors are appearing. It was said that Decimal problem is caused by
> running psycopg2 with multiple interpreters, so thats why I think
> "can't adapt" might be the same thing.
> Exactly same place, same data entered in the form and after submit
> sometimes I get "can't adapt" and sometimes (after apache restart)
> everything works.
>

Sorry for opening an old thread but this is exactly the problem we
have had today with an application that has been running for nearly
two years. We're using mod_python and we run two different sites. We
have the can't adapt error at random basis. Once is produced in one
site the other site gives the same error.

I don't know if is related or not, but the only thing we have done is
to update to the security patch of 1.0 version. Actually we have
updated to the 1.1.2 version but the error still happens.

Restarting Apache makes everythink running again, but after some time
the error appears. The request involves making a query that Django
converts to a Decimal number (a request between 0 and 9), I
have refactored to make a different query so It seems this kind of
error is not solved.

Traceback follows:

Traceback (most recent call last):

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/core/handlers/base.py",
line 92, in get_response
response = callback(request, *callback_args, **callback_kwargs)

  File "/var/pywww/trobacasaweb/trobacasa/views.py", line 502, in buscar
resultado['page'] = paginator.page(actual_page)

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/core/paginator.py",
line 37, in page
number = self.validate_number(number)

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/core/paginator.py",
line 28, in validate_number
if number > self.num_pages:

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/core/paginator.py",
line 60, in _get_num_pages
if self.count == 0 and not self.allow_empty_first_page:

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/core/paginator.py",
line 48, in _get_count
self._count = self.object_list.count()

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/db/models/query.py",
line 292, in count
return self.query.get_count()

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 376, in get_count
number = obj.get_aggregation()[None]

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 348, in get_aggregation
result = query.execute_sql(SINGLE)

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 2369, in execute_sql
cursor.execute(sql, params)

ProgrammingError: can't adapt



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: syntax error what am i doing wrong???

2009-10-26 Thread Antoni Aloy

2009/10/26 jon...@cox.net :
>
> SyntaxError at /
>
> ('invalid syntax', ('c:\\Users\\Vincent\\Documents\\django_bookmarks\
> \..\\django_bookmarks\\bookmarks\\views.py', 15, 20, 'return Http
> Response(output)\n'))
>
> SCRIPT FROM VIEWS.PY
>
> from django.http import HttpResponse
> def main_page(request) :
>   output = '''
>  
>     %s
>     
>        %s%s
>     
>  
> ''' % (
>      'Django Bookmarks',
>      'Welcome to Django Bookmarks',
>      'Where you can store and share bookmarks!'
> )
> return HttpResponse(output)
>
> >
>

At first sight: you need triple quote string not single.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: debug toolbar problem

2009-11-01 Thread Antoni Aloy

2009/11/1 bax...@gretschpages.com :
>
> I finally installed the django debug toolbar, which looks like a very
> nice piece of work, but it's not reporting sql queries for me. Every
> page: 0 queries, 0 seconds.
>
> Any suggestions on where the problem may lie?

Are you caching your pages?
Are you using Django ORM?



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Migrating a Wordpress website to Django

2009-11-02 Thread Antoni Aloy

2009/11/2 John K :
>
> Hey thanks for the links. It would be great to discuss personal
> experiences with the group.
>
> On Nov 2, 1:47 pm, creecode  wrote:
>> Hello John,
>>
>> A quick search on Google shows some folks have done WP to Django
>> migrations.  Following are a few links.
>>
>> http://www.nbrightside.com/blog/2007/10/14/how-to-migrate-a-wordpress...
>>
>> http://code.google.com/p/django-wordpress-admin/
>>
>> http://www.eriksmartt.com/blog/archives/306
>>
I migrated my own blog (trespams) from Wordpress to Django. The main
difficult was to take care of tags and html conversions. You can
mantain url with Django Redirect and hardcondig some of the others in
urls.py.

I had to create a migration script but this was just a matter of hours
with a little bit of manual work.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: language switching in admin

2009-11-07 Thread Antoni Aloy

2009/11/7 Kenneth Gonsalves :
>
> hi,
>
> I have an app in two languages. Until now I was asking the users to change the
> language in their browser. I have now implemented setlang in the web
> interface, so that they can view in the language of their choice by choosing
> the language. I now want to do this in admin - a custom form should do it, but
> has anyone done this? Or is it going to come to admin? Or maybe it is there
> and I have not noticed it?

And letting the users to change their language modifiying the main
admin template and giving them a change language form?


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: The job of a django web designer

2009-11-15 Thread Antoni Aloy
2009/11/15 gnoze5 :
> Hello,
>
> I am new to django and I am having a little issue in understanding the
> expected role of a designer during the development a django website.
> Is the point of the django template system to allow a designer to not
> have to worry about any code, and only need to deliver let's say, a
> pure html+css template to a coder who in turn will input the whole
> blocks and logic into that template? or is the designer expected to
> learn the django template system?
>
Learning django template does not going to hurt you :)

In the team I lead the designer sometimes creates the design and
sometimes just converts it to html+css. But she's able to work
understand and work with inheritance and filters.

The whole team is much more productive when everyone uses subversion,
can run the project application in their own computers and understands
the underlying technology. The designer can fine tune the final aspect
of the site, understands about compression and subversion diff. I have
heard that this is quite uncommon but in my opinion it's the right
way.

I'm proud to have the designers as a true member of the development
team and for that she must understand the django template system as
well as subversion and to be able to code without Dreamweaver.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--

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




Re: Django i18n

2009-11-16 Thread Antoni Aloy
2009/11/16 Carlos Ricardo Santos :
> Hi:
> I tried all the ways possible and impossible to make my Django project have
> i18n...
> Put all settings (INSTALLED_APPS, CONTEXT_PROCESSORS), generated languages,
> compiled messages, edited the ".po" files, setted the ugettext to "_", in
> views all the strings are like this: toSend= _("Hello"), but so far... only
> the Administrator panel is translated cause I checked (put a post form to
> change the language in the backoffice).
> I found that changing language only works for POST requests... Ok, DONE.
> But even with a post... only the backoffice seems to be responding to my
> language change request...
> I use to folders at app/locale:
> pt-PT
> en-GB
> Any ideas? Someone has implemented a foreign language before?
> Thanks in advance.
Hi Ricardo,

Just have a look at
http://code.google.com/p/appfusedjango/source/browse/#svn/trunk/appagenda,
you'll find an agenda example with different languages.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--

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




Re: style guide/autoformatter/linter for Django templates?

2009-12-01 Thread Antoni Aloy
2009/12/1 Tom Evans :
> On Tue, Dec 1, 2009 at 4:13 PM, Steve Howell  wrote:
>>
>> On Dec 1, 3:33 am, Tom Evans  wrote:
>>> On Tue, Dec 1, 2009 at 7:33 AM, Steve Howell  wrote:
>>> > Just following up on this a few days later, in case it got lost in the
>>> > shuffle due to the weekend and U.S. holiday.
>>>
>>> > On Nov 27, 2:18 pm, Steve Howell  wrote:
>>> >> I am wondering if there is a style guide anywhere for writing Django
>>> >> templates.  Also, are there programs to automatically format your
>>> >> templates...to indent block tags, for example?  I

I have been playing with Ulipad editor,
http://code.google.com/p/ulipad/, it has Django template syntax
support as well as Django project support.

It's a nice and fast editor, and it has one of the best autocomplete
feature for Python and Django that I have seen so far.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--

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




Re: Rails-style form value deserializer?

2009-12-19 Thread Antoni Aloy
2009/12/19 Todd Blanchard :
> How does this solve the problem of having two related objects that have the
> same attribute name (like "name") on the same html form?  As I see it, it
> doesn't.  There will be a conflict and it will be impossible to keep them
> separate.
> IOW,
> 
> {{ account_form }}
> {{ contact_form }}
> 
> 
> def update_account_and_contact
> if(request.POST)
> account_form = AccountForm(request.POST, instance=get_object_or_404(Account,
> id=request.POST['id'])
> contact_form = ContactForm(request.POST, instance=get_object_or_404(Contact,
> id=request.POST['id'])
> if(account_form.is_valid() && contact_form.is_valid())
> account_form.save()
> contact_form.save()
> .
>
> The rails solution is much superior.
>

Thi is clearly explained in the Django documentation about forms
http://docs.djangoproject.com/en/dev/ref/forms/api/#ref-forms-api

Django documentation us much superior :-P


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--

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




Django 1.1.2?

2010-05-17 Thread Antoni Aloy
Hello,

On the main Django page the official version is 1.1.1 but there is a
new 1.1.2 version even documented if you make a search on the Django
site. Is the 1.1.2 officialy supported?

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Django 1.1.2?

2010-05-17 Thread Antoni Aloy
2010/5/17 Russell Keith-Magee :
> On Mon, May 17, 2010 at 6:56 PM, Antoni Aloy  wrote:
>> Hello,
>>
>> On the main Django page the official version is 1.1.1 but there is a
>> new 1.1.2 version even documented if you make a search on the Django
>> site. Is the 1.1.2 officialy supported?
>
> Unofficially, yes it is officially supported :-)
>
:-P

In fact the 1.1.2 version is on Pypi
http://pypi.python.org/pypi/Django my fear was that was a fake package
until I have searched the documentation.

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: How to serve a static html file instead of rendering it as a template.

2010-06-11 Thread Antoni Aloy
Just modify your server configuration to directly serve the folder and
do not sent it to django. It's the same you'll do for media files.

Hope it helps!


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: i18n variable string translation

2010-06-16 Thread Antoni Aloy
Try to use lazy translation.

El 16/06/2010 23:09, "Aaron"  escribió:

Well what happened was I have a forms.py

which has

CONSTANT = _("Hello World")
x = {'var': CONSTANT }

and in the django.po, I do have a translation

msgid "Hello World"
msgstr "xxx"

But it doesn't show up on the website, all the other translations
work, so I am wondering what am I missing

-Aaron



On Jun 16, 1:35 pm, Baurzhan Ismagulov  wrote:
> On Wed, Jun 16, 2010 at 01:00:3...
> Baurzhan Ismagulovhttp://www.kz-easy.com/


-- 
You received this message because you are subscribed to the Google Groups
"Django users" group

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



Re: Deployment hesitation after James Bennett's post, WSGI or ...?

2010-06-25 Thread Antoni Aloy
Hi,

WSGI is the best option. For that we're using ngnix+cherrypy (just the
wsgi adapter) and it works like a charm. Recently we've start testing
gunicorn as well, as the deployment is really easy.

This kind of configuration allows you to reduce drastically the memory
consumption, so you can deploy small applications on cheap vps. But
programing Django is addictive and for sure you'll finish with a
dedicated server :)

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: News on every page

2010-07-08 Thread Antoni Aloy
I would use a custom template tag with cache

El 08/07/2010 18:17, "Andy McKay"  escribió:

On 2010-07-08, at 9:07 AM, Martin Tiršel wrote:
> 1.) Where is the right place to place news loader?...
Middleware is not the appropriate place, a context processor is the
appropriate place.
--
 Andy McKay, @andymckay
 Django Consulting, Training and Support


-- 
You received this message because you are subscribed to the Google Groups
"Django users" group

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



Re: Most common uses of Django templates

2010-07-16 Thread Antoni Aloy
2010/7/15 fabiofz :
> Hi All,
>
> I'm currently working on providing an editor for django templates in
> Pydev (http://pydev.org).
>
> Now, while I do work with django templates sometimes, my experience is
> a bit limited with it -- so far I used it only for .html files,
> sometimes with some javascript in it, so, that's what I'm covering in
> the first step (mostly an html editor which knows about django
> templates and acts accordingly, giving syntax highlighting and code-
> completion for the common django constructs -- besides the code-
> completion for html).
>
> So, my doubt is: what are the other common use cases that a django
> templates editor should support? (is css common in django templates?
> Any other format?)
>
> Another thing: would the django structures be expected to be shown in
> the outline (or mostly just the language structure -- in this case
> html)?
>
> Thanks,
>
> Fabio
>

Hi Fabio!

These  are very good news. Perhaps with the title the question hasn't
given the right attention. In my oppinion you should remade it to
something like "RFC Django support in Eclipse using PyDev". Even with
the high memory comsumtion of Eclipse, the combination Eclipse + pyDev
is my first recommended option for Python and Django development IDE.
I have to confess my actual IDE is Vim and one of the reason that
makes me to made the editor change was the lack of support of Django
templates and (the biggest one) the high machine requisites of
Eclipse.

Django templates shoud support Django tags and filters, HTML, CSS and
Javascript, This is enougth. Code completion on Django tags would be a
nice add on, but Eclipse templates is usually enought.

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Django IDE

2010-07-18 Thread Antoni Aloy
Actually the best productive "IDE" for me, and I'd like to remark the
for me, is Vim/gVim with lots of plugins. I mantein my .vimrc and
plugins in http://code.google.com/p/trespams-vim/ if you wan't to see
how it looks.

Vim takes longer to master, in fact you can learn something new each
day, but it's a great tool.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: about some ideas for our very largest project

2010-07-21 Thread Antoni Aloy
2010/7/21 RNGLAB :
> hi django peoples
>
> i m rıdvan from turkey and working in a web based big project for now
> this project about web based healthcare and hospital systems.
> and the project is realty big.. we have a team for this.
>
> we are searching a different tech. from .net or java. than we find and
> develop some ideas about pyton and django.
> i wanna ask you about that.. first i must say, i m not enough in
> django and pyton. so i m asking in this level :)
>
> how is django and pyton about this project? this subjects? it can do
> very institutional applications?
> django tech. can support very big web based applications realty ? if
> it supports what can we do with django and pyton?  what is djangos
> differents from .net or java?
>
> if you can share information about this very works for us..
>

The main problem you'll have with instaitutional application with
Django, Python, PHP, Ruby, etc. is the deployment. Some IT departments
does not allow nothing but the technologies they know, and they can be
as old as cobol or j2ee 1.4 + EJB, so ask first your potential
institution clients what they have.

Django and Python can support really big projects. In fact one of the
thinks I like best in Django and Python is that they are scalable in
hardware but also in people, compared with PL/SQL or other languages
where the layer separation is not as clear than the Django one.

It's really difficult to say if Django is the right technology for
your project, but at least you can do your first prototype rally fast
and test for yourself.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Demonstrate Development Server

2010-07-25 Thread Antoni Aloy
2010/7/25 Nikhil Somaru :
> That should work, I don't think it's a django problem
>
> On Sun, Jul 25, 2010 at 12:00 AM, kostia  wrote:
>>
>> How to open my web site on development server to others?
>> I use python manage.py runserver 0.0.0.0:8000
>>
>> But something stops others to visit my site. I use Linux Fedora, maybe
>> I should shot down SE Linux?
>>

Using your computer IP should work for an internal LAN. Using
development server in a production enviroment is highly discouraged.
If nobody can access throught your IP check your firewall rules.

Best regards,




-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: 404.html error

2010-07-25 Thread Antoni Aloy
You have not added the admin urls in urls.py so you can't access to it.

Regards,

2010/7/25 yalda.nasirian :
> hi
> i'm new at django code .
> i have a problem with 404.html page .
> i can't see mypage http://127.0.0.1:8000/admin/ , i see error  not found >
> can you guide me ? and i have another question , where i write this
> command :
> handler404 = 'mysite.views.my_custom_404_view'
> and another question before this error , i can't  see vote , results
> in my page , just poll has seen .
> please help !
> tanx
>
> my setting.py :
>
> DEBUG = False
> TEMPLATE_DEBUG = DEBUG
>
> ADMINS = (
>    # ('Your Name', 'your_em...@domain.com'),
> )
>
> MANAGERS = ADMINS
>
> DATABASES = {
>    'default': {
>        'ENGINE': 'sqlite3',
>        'NAME': 'db.dev',
>
>
> SITE_ID = 1
>
> USE_I18N = True
>
> USE_L10N = True
>
> MEDIA_ROOT = ''
>
> MEDIA_URL = ''
>
> ADMIN_MEDIA_PREFIX = '/media/'
>
> TEMPLATE_LOADERS = (
>    'django.template.loaders.filesystem.Loader',
>    'django.template.loaders.app_directories.Loader',
> #     'django.template.loaders.eggs.Loader',
> )
>
> MIDDLEWARE_CLASSES = (
>    'django.middleware.common.CommonMiddleware',
>    'django.contrib.sessions.middleware.SessionMiddleware',
>    'django.middleware.csrf.CsrfViewMiddleware',
>    'django.contrib.auth.middleware.AuthenticationMiddleware',
>    'django.contrib.messages.middleware.MessageMiddleware',
> )
>
> ROOT_URLCONF = 'mysite.urls'
>
> TEMPLATE_DIRS = (
>         '/home/yalda/mytemplates'
> )
>
> INSTALLED_APPS = (
>    'django.contrib.auth',
>    'django.contrib.contenttypes',
>    'django.contrib.sessions',
>    'django.contrib.sites',
>    'django.contrib.messages',
>    'django.contrib.admin',
>    'polls'
>
> )
>
> view.py :
>
> from django.template import Context, loader
> from mysite.polls.models import Poll
> from django.http import Http404
>
>
> def index(request):
>    latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
>    t = loader.get_template('polls/index.html')
>    c = Context({
>        'latest_poll_list': latest_poll_list,
>    })
>    return HttpResponse(t.render(c))
>
>
> def detail(request, poll_id):
>    try:
>        p = Poll.objects.get(pk=poll_id)
>    except Poll.DoesNotExist:
>        raise Http404
>    return render_to_response('polls/detail.html', {'poll': p})
>
>
> def results(request, poll_id):
>    return HttpResponse("You're looking at the results of poll %s." %
> poll_id)
>
> def vote(request, poll_id):
>    return HttpResponse("You're voting on poll %s." % poll_id)
>
> urls.py :
>
> from django.conf.urls.defaults import *
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('mysite.polls.views',
>    (r'^polls/$', 'index'),
>    (r'^polls/(?P\d+)/$', 'detail'),
>    (r'^polls/(?P\d+)/results/$', 'results'),
>    (r'^polls/(?P\d+)/vote/$', 'vote'),
> )
>
> models.py :
>
> from django.db import models
>
> class Poll(models.Model):
>    question = models.CharField(max_length=200)
>    pub_date = models.DateTimeField('date published')
>    def __unicode__(self):
>        return self.question
>
> class Choice(models.Model):
>    poll = models.ForeignKey(Poll)
>    choice = models.CharField(max_length=200)
>    votes = models.IntegerField()
>    def __unicode__(self):
>        return self.choice
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Trying to customize a form and make it look like my design

2010-07-26 Thread Antoni Aloy
2010/7/26 reduxdj :
> for instance, i need to nest certain form-fields inside divs... The
> automatic form {{form as p}}, seems to be a little too constraining.
> How can I create a form and customize the template. I just need to see
> a simple example of how to use a customized form template with fields
> and labels already there.
>

This is explained in the docs
http://docs.djangoproject.com/en/dev/topics/forms/, see Customizing
the form template

Hope it helps!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Django doesn't load css

2010-07-28 Thread Antoni Aloy
the css should be {% MEDIA_URL %} but you have to be sure you pass the
RequestConext on your render_to_response method.
If you're are on the development server you have to add additional
urls to urls.py to serve static content.

Is explained in the docs, but I suppose some examples you'll be
better. I created some startup and example projects that I think they
would help you.

http://code.google.com/p/appfusedjango/

Check project and agenda, they are a good start. The examples are not
updated for 1.2.1 but they work.

2010/7/28 kostia :
> I use in settings.py:
>
> MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'main',
> 'templates', 'static').replace('\\', '/')
>
>
> MEDIA_URL = '/static/'
>
>
> And then simply in an html file:
>
> 
>
> Where the full folder path is the ../project_name/main/templates/
> static/styles/nav.css
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Django doesn't load css

2010-07-28 Thread Antoni Aloy
2010/7/28 Andreas Pfrengle :
> Hello Kostia,
>
> I get a template syntax error with your method, since I haven't
> defined a "static" view. How does your static-view look like?
> I've already tried it like described here -->  docs.djangoproject.com/en/dev/howto/static-files/> but I don't get it
> work either, I get a TypeError: bad operand type for unary +: 'list'
> for the urlpattern that the docs suggest to include.
>
> Antoni, we've tried it already with the {{ MEDIA_URL }} variable, but
> to make it braindead simple we've hardcoded the paths.
> On the example you've linked: There is only a picture in the download
> section, no code.

Use subversion Luke :)

Sorry I can't resist. ;)

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Django error can't adapt

2010-08-01 Thread Antoni Aloy
2010/8/1 Daniel França :
> Hi,
> I just migrated from Linux to Mac OS, and I'm getting an error message
> when I try register a new user of my django site, (at my page)
> I get the error: can't adapt type 'US/Eastern'
> I'm using Postgresql and psycopg2, I tried to change the TIME_ZONE to
> 'America/Sao_Paulo'(I'm in Brazil), but the error still happens.
>
> I tried anothers possibilities of TIME_ZONE but no success.
>
> Anyone know how to solve that?
>
> Best Regards,
> Daniel França
>
Do you have more than one django instance on mod_python? If this is
the case it's a bug with mod_python and Postgres. Change to wsgi and
the problem would dissapear.

Hope it helps!


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Flexigrid

2010-08-02 Thread Antoni Aloy
Hi Ramesh,

I haven't work with Flexigrid in my projects, but I did it with jqgrid
and as far I can see is quite the same:

In the Flexigrid sample you have:

$("#flex1").flexigrid
(
{
url: 'post2.php',
dataType: 'json',
colModel : [
{display: 'ISO', name : 'iso', width : 40, 
sortable : true, align:
'center'},
{display: 'Name', name : 'name', width : 180, 
sortable : true,
align: 'left'},
{display: 'Printable Name', name : 
'printable_name', width : 120,
sortable : true, align: 'left'},
{display: 'ISO3', name : 'iso3', width : 130, 
sortable : true,
align: 'left', hide: true},
{display: 'Number Code', name : 'numcode', 
width : 80, sortable :
true, align: 'right'}
],
buttons : [
{name: 'Add', bclass: 'add', onpress : test},
{name: 'Delete', bclass: 'delete', onpress : 
test},
{separator: true}
],
searchitems : [
{display: 'ISO', name : 'iso'},
{display: 'Name', name : 'name', isdefault: 
true}
],
sortname: "iso",
sortorder: "asc",
usepager: true,
singleSelect: true,
title: 'Countries',
useRp: true,
rp: 15,
showTableToggleBtn: true,
width: 700,
height: 200
}
);

So the idea is to replace the php url with a django one. ex. /ajax/countries/

That url must map to a view and on that view you have to obtain
(Country.objects.all() if you have such a model) and then return the
json that Flexigrid wants. You can see the json in
http://www.flexigrid.info/post2.php

So the real problem is to know how to map urls to views, and that is
clearly explained in the Django tutorial, and how to return json data
instead of html, which is covered in :

http://docs.djangoproject.com/en/dev/topics/serialization/
http://chronosbox.org/blog/jsonresponse-in-django?lang=en
http://stackoverflow.com/questions/414543/django-serialize-to-json

etc.

With jqrid I was able to map the Django model response directly to the
grid (well almost), but I don't know if this is possible in Flexigrid.
Anyway, you can create your own structure, fill it from the model and
then dump it to json.


Hope it helps!


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Splitting LONGTEXT column to its own table?

2010-08-02 Thread Antoni Aloy
2010/8/2 Nick Arnett :
> I'm thinking that I could get a pretty good performance improvement on a
> couple of tables by moving their LONGTEXT columns into their own tables.
> Just wondering if there's anybody here who has done something like that - is
> there a way to do this transparently to Django, so I don't have to re-write
> every piece of code that uses those tables.
>
> In other words, I'm looking at vertical partitioning, but only across
> tables, not databases, as transparently as possible to the code that I've
> already written.
>
My first thought would be to backup the database, then put the project
under South control. Then create a one-to-one relation between models
and the possible create a upgrade script.
Then, if necessary, you could create properties in the original model
to map the names you have in your application.

Just my 2 cents.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: djangoproject.com inaccessible?

2010-08-02 Thread Antoni Aloy
2010/8/2 creecode :
> Hello all,
>
> djangoproject.com appears to be inaccessible to me.  Is anyone else
> having problems?  Is anyone able to access it?
>
> Toodle-looo...
> creecode
>

http://downforeveryoneorjustme.com/

works for me!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Django template compilation

2010-08-13 Thread Antoni Aloy
Hello!

Today I have been benchmarking a Django template to PHP compilar
called Haanga http://github.com/crodas/Haanga/ a development sponsored
by meneame.net a Digg like spanish site. Ricardo has made some sort of
benchmark http://gallir.wordpress.com/2010/08/13/haanga-vs-django-vs-h2o.
With my own benchmarks, using just the template part, Haanga it's
about 80% faster than Django. The post is in Spanish but you can see
the results.

I know template speed is not a real problem in most sites but I'm
quite impressed abut Haanga speed. My feelings are that the examples
as most benchmarks tends to show where the product shines (samples are
using lots of loops) but I haven't found any similar project for
Django or reasons about why Django does not uses the same approach.

I can guess some of the reasons: maitanibility, work split between
developers and designers, custom template filters, ... But I'd like to
know other's thoughts.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: How to troubleshoot path and permission problems?

2010-08-23 Thread Antoni Aloy
2010/8/23 vishy :
> Hi,
>
> I am having issues with production server.Everything is running fine
> on my local development server.On production site(using apache), CSS
> files related to admin section are not being loaded.I have a feature
> where admin can add products and upload images for the
> product.But,when admin hits save,I get permission denied message.How
> can I figure out what path problems are existing and how to fix them?
> Thanks
>

on linux ls -l will givve you the perisions of each file and folder.
You can check what each letter means on
http://www.comptechdoc.org/os/linux/usersguide/linux_ugfilesp.html.

To server files the Apache server has to have read permisions. To
create files it has to have write permisions.

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



[Announcement] Vim for Python and Django

2010-09-26 Thread Antoni Aloy
Hello all!

In this list we have a recurrent thread: "What'ts the best IDE for
Django and Python development?" trespams-vim is my try to answer this
question for people who likes to have a very powerful editor and needs
to have an editor which is able to run in the desktop as well as in a
remote session. I have updated the previous version with delimMate and
easytags, so actually you'll find:

* Syntax highlight
* Python autocompletion
* Smart tabbing
* Templates for Python, Django, js, html, ... (just try to edit a
python file and press sbu + tab as an example)
* Add/remove comments on multiple lines
* Tabs
* Surround
* marks

etc. etc. :

This is a list of my favorite shortcuts

http://code.google.com/p/trespams-vim/wiki/readme

So, you'll find a collection of plugins and .vimrc settings that I
have found very useful in my day-by-day work in Python and Django.

http://code.google.com/p/trespams-vim/

Happy coding!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Where do you put your business logic in django? Organizing big projects in django.

2010-09-27 Thread Antoni Aloy
2010/9/27 MrMuffin :
> Where do you put your business logic in django? In my project I`ve put
> it into the models.py, but that file soon become huge and hard to
> maintain. Of course I can just stuff it into whatever file I like, but
> I`d like to have some standard way of doing this. There seems to be
> something missing in django when it comes to business logic. It`s all
> model, views and templates and that`s all great for small projects,
> but both the models.py and views.py very soon gets huge and how do you
> re-organize your project when that happens? Splitting views and models
> into seperate files is only a partial solution and that requires some
> hackish code in __init__.py to make syncdb etc work. And then there`s
> urls.py.
>
> Should there be a better and standardized way to organize huge
> projects in django?
>
> Thanks for your time.
>

Django allows you to split your project in applications, and Django
applications are quite linked to models. But you can create your own
libraries, this is Python. As an example, we create applications to
connect to different web services and we use Django in the project.
Each web service mapping is in its own Python packages. The Django
urls and views just uses that package.

Hope it helps!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: IDE for Python/django

2010-09-27 Thread Antoni Aloy
>>
>> 2010/9/27 João Rodrigues 
>>>
>>> http://code.google.com/p/trespams-vim/

Well I'm a little biased towards vim after all I try to mantain the
trespams-vim, but I have tested nearly all the IDEs that have been
posted in this thread, and my conclusion is that no exists such a
thing as the perfect IDE. It would depend on your work.

For me vim is perfect as I have to write code in the desktop and also
have to edit code in remote shells, so having just one common editor
is perfect for me, as it allows me to master in just one editor. If
you just need a desktop editor just try the one that fits better in
your daily work, it could be as simlpe as gedit o kate or as bloated
as Aptana. Just try and you'll find the best IDE *for you*.



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: What is the correct way to copy an object from one model to a similar model?

2010-09-29 Thread Antoni Aloy
You can use also introspection if the number of attributes is high.
http://stackoverflow.com/questions/3818825/python-what-is-the-correct-way-to-copy-an-objects-attributes-over-to-another

2010/9/29 Yo-Yo Ma :
> I have two models that are identical in structure except one has 2
> extra fields. The second one is used for record keeping and is never
> edited by users. The system takes the first model and copies it to the
> second model, adding some extra meta information, all when a certain
> action is performed against the first model.
>
> What is the best practice for this?
>
> spam.attribute_one = foo.attribute_one
> spam.attribute_two = foo.attribute_two
>
> Or, is there a pattern that works well?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



  1   2   >