Re: django 1.4 memory issues

2012-06-14 Thread francescortiz
You could create a bug report:

https://code.djangoproject.com/newticket

On Tuesday, June 12, 2012 4:59:08 PM UTC+2, Greg Donald wrote:
>
> Over the weekend I upgraded my project to Django 1.4.  After the 
> upgrade my Apache/mod_wsgi setup began running out of memory.  I 
> increased the memory capacity of my virtual servers, but that only 
> extended the time until they began to swap again.  I found a blog 
> article that suggested setting Apache's MaxRequestsPerChild to 
> something other than 0.  After setting it to 25, Apache seems to be 
> releasing memory again. 
>
> My question is, why did I have to do that?  The only thing that 
> changed is my Django version from 1.3 -> 1.4.  I have Debug=False in 
> settings.py, so I don't think I'm experiencing the SQL memory buildup 
> described on a couple of blogs.  I do have some long running scripts 
> that use Django outside of Apache, so I implemented db.reset_queries() 
> in those, but it had no noticeable effect.  They didn't appear to be 
> using any more memory than normal, but I figured it couldn't hurt. 
>
> So everything is running fine again, but something changed in Django 
> 1.4 that causes my same project code to leak memory.  I'd sure like to 
> figure it out. 
>
> Thanks. 
>
>
> -- 
> Greg Donald 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/QvpMw9Ra7AcJ.
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: Webservice return pdf

2012-05-29 Thread francescortiz
a search for

python write file

migh help

On Monday, May 28, 2012 9:51:59 AM UTC+2, Madhu wrote:
>
> Hi! all
> I create client & through client i call the web service.
> which returns pdf file, i want to stored that file directly.
> I use this
> response['Content-Disposition'] = 'attachment; filename= 'demo.pdf'
> but it will ask the user to store the file, but i want to store it 
> automatically on server.
> can anybody please suggest me, how it should be done?
>
> Thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/XbqKGUxAiKwJ.
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: Httprequest with xml body - how to parse with elementtree?

2012-05-27 Thread francescortiz
This link could help:
http://lmgtfy.com/?q=python+parse+xml


On Saturday, May 26, 2012 4:24:29 PM UTC+2, Benjamin Carlson wrote:
>
> I'm new to django, and am trying to write a web service. 
>
> The request will have xml in the body. How can I parse that into 
> elementtree root node?
>
> Thanks in advance!
>
> -Ben
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/x_1kgvUaZPwJ.
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 popup a window from admin site from the admin table's cell html content?

2012-05-25 Thread francescortiz
You need to be more specific, because the code you have already seems to do 
what you ask. What is your problem?

On Monday, May 21, 2012 5:51:21 AM UTC+2, Aditya Sriram M wrote:
>
> Help please! :-|
>
> On Saturday, 19 May 2012 18:31:05 UTC+5:30, Aditya Sriram M wrote:
>>
>> I have a function like this..
>>
>> list_display = (..,get_link_to_users, ..)
>>
>>def get_link_to_users(self, obj):
>> html_table = '> href="JavaScript:window.open(''../user/?q=%s'');"> My Users ' % 
>> (obj.customer_id)
>> print html_table
>> return html_table
>> get_link_to_fortress_users.short_description = 'Fortress Users'
>> get_link_to_fortress_users.allow_tags = True
>>
>> Question: user and customer are my models. In Customer model, I would 
>> like to put just the link. And on clicking this link, a new popup should 
>> come up with the related users. How to do this?
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/dH1ybdjbGhcJ.
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 need a django application to embed a chat javascript in admin site

2012-05-24 Thread francescortiz
Implementing a simple global chat is pretty straightforward:

1- Don't use database
2- Implement filesystem based locking (multithread safe)
3- if there user wrote a new line, acquire lock and append the new line to 
the file.
4- releaase lock
5- send the last lines to the users. I recommend you to make a system call 
to "tail -n ??? [filename]", but you can implement you own last lines 
reading algorithm, much harder than it appears because you have stay 
friendly with kernel's readahead and disk cache.

You can have your chat log file in any format that fits you, (html, json, 
etc).

Then, for user based chat, just make the chatlog named after 
[user1]-[user2].chatlog, having user1 and user2 sorted alfabetically.

The hardest part is all the html an javascript needed, specially in 
multiuser chat, because you have to handle list of users and window opening.



On Wednesday, May 23, 2012 4:37:42 PM UTC+2, Ariel wrote:
>
> Hi everybody,
>
> I need a django application to embed a chat javascript in the admin app of 
> my web site, I would like when the users are authenticated be able to 
> contact by chat any other user authenticated in the admin site.
>
> How could I do this ???
> Is there an application to make this ???
>
> Regards,
> Ariel
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/dXCODutfzXgJ.
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: where do you host your django app and how to you deploy it?!

2012-05-18 Thread francescortiz
I use django europe, cheap shared hosting with a good setup with lighttpd 
by default, but you can set up any server you want compiling it.

On Monday, April 2, 2012 12:48:24 PM UTC+2, fix3d wrote:
>
> Where do you host your django app and how to you deploy it?! 
>
> Please share personal exp.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/isJWANfbG8oJ.
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: Model reversion

2012-05-10 Thread francescortiz
Well, creation and deletion should be tracket. Also, binary items should be 
purged once versions are purged, not before.

On Thursday, May 10, 2012 8:19:51 AM UTC+2, Alireza wrote:
>
> Thanks for your reply and the link.
>
> But what about binary items, i mean files. should we keep eyes on them, 
> and if user delete them we should not delete them and just hide them?
> Or reversion is just about text and text ?
>
> And something else, reversion model shoulda trace the creator of the 
> changes or no it shoulda just keep model's changes?
>
>
> On Wednesday, May 9, 2012 11:37:10 PM UTC+4, francescortiz wrote:
>>
>> Json and difflib won't work well together, unless you make a diff per 
>> field, which will add overhead. Look at 
>> http://stackoverflow.com/questions/4599456/textually-diffing-json
>>
>> Reverting is returning to a previous state. Just run all diffs from the 
>> first commit until you reach the desired state.
>>
>> It would be great that it showed side by side the older an newer values 
>> of each field in a table view and let you choose what you want to revert. 
>> Maybe text fields on the left, values on the right and a copy button on 
>> each side.
>>
>> Don't forget about foreign keys. A reversion might imply restoring a 
>> deleted item.
>>
>>
>> On Wednesday, May 9, 2012 3:15:06 PM UTC+2, Alireza wrote:
>>>
>>> Hi
>>> First of all i know there is a plugable app called *django-reversion*, 
>>> leave it now!
>>>
>>> I like to discus about some idea to implement a simple reversion app. i 
>>> have couple of thoughts about it, all i need is just another people's ideas 
>>> about it.
>>>
>>> If i'm wrong correct me!
>>> The model that used to keep history|changes, is a generic model and of 
>>> course powered by *ContentType *[framework|app], and revision should be 
>>> done in tracking the changes in git way, not svn-like which make a copy of 
>>> the changed file.
>>> And of course data should be saved in JSON format, thanks to simple 
>>> json! ( using django signals to keep eyes on model changes )
>>> Different between the models can be handled by *difflib*!
>>> Okay yet theoretically is not a big implementation!
>>> But the main point and important step is reverting, which i don't have 
>>> clear idea about it!
>>> And i know i probably missed couple of things there.
>>>
>>> i like to know your [idea|suggestion|advice]!
>>> Thanks!
>>>
>>
> On Wednesday, May 9, 2012 11:37:10 PM UTC+4, francescortiz wrote:
>>
>> Json and difflib won't work well together, unless you make a diff per 
>> field, which will add overhead. Look at 
>> http://stackoverflow.com/questions/4599456/textually-diffing-json
>>
>> Reverting is returning to a previous state. Just run all diffs from the 
>> first commit until you reach the desired state.
>>
>> It would be great that it showed side by side the older an newer values 
>> of each field in a table view and let you choose what you want to revert. 
>> Maybe text fields on the left, values on the right and a copy button on 
>> each side.
>>
>> Don't forget about foreign keys. A reversion might imply restoring a 
>> deleted item.
>>
>>
>> On Wednesday, May 9, 2012 3:15:06 PM UTC+2, Alireza wrote:
>>>
>>> Hi
>>> First of all i know there is a plugable app called *django-reversion*, 
>>> leave it now!
>>>
>>> I like to discus about some idea to implement a simple reversion app. i 
>>> have couple of thoughts about it, all i need is just another people's ideas 
>>> about it.
>>>
>>> If i'm wrong correct me!
>>> The model that used to keep history|changes, is a generic model and of 
>>> course powered by *ContentType *[framework|app], and revision should be 
>>> done in tracking the changes in git way, not svn-like which make a copy of 
>>> the changed file.
>>> And of course data should be saved in JSON format, thanks to simple 
>>> json! ( using django signals to keep eyes on model changes )
>>> Different between the models can be handled by *difflib*!
>>> Okay yet theoretically is not a big implementation!
>>> But the main point and important step is reverting, which i don't have 
>>> clear idea about it!
>>> And i know i probably missed couple of things there.
>>>
>>> i like to know your [idea|suggestion|advice]!
>>> Thanks!
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/1sWbZKe7PSkJ.
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: Model reversion

2012-05-09 Thread francescortiz
Json and difflib won't work well together, unless you make a diff per 
field, which will add overhead. Look at 
http://stackoverflow.com/questions/4599456/textually-diffing-json

Reverting is returning to a previous state. Just run all diffs from the 
first commit until you reach the desired state.

It would be great that it showed side by side the older an newer values of 
each field in a table view and let you choose what you want to revert. 
Maybe text fields on the left, values on the right and a copy button on 
each side.

Don't forget about foreign keys. A reversion might imply restoring a 
deleted item.


On Wednesday, May 9, 2012 3:15:06 PM UTC+2, Alireza wrote:
>
> Hi
> First of all i know there is a plugable app called *django-reversion*, 
> leave it now!
>
> I like to discus about some idea to implement a simple reversion app. i 
> have couple of thoughts about it, all i need is just another people's ideas 
> about it.
>
> If i'm wrong correct me!
> The model that used to keep history|changes, is a generic model and of 
> course powered by *ContentType *[framework|app], and revision should be 
> done in tracking the changes in git way, not svn-like which make a copy of 
> the changed file.
> And of course data should be saved in JSON format, thanks to simple json! 
> ( using django signals to keep eyes on model changes )
> Different between the models can be handled by *difflib*!
> Okay yet theoretically is not a big implementation!
> But the main point and important step is reverting, which i don't have 
> clear idea about it!
> And i know i probably missed couple of things there.
>
> i like to know your [idea|suggestion|advice]!
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/MlKUCZ4hkisJ.
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 text of a ChoiceField populated with ajax

2012-05-08 Thread francescortiz
You have to make sure that the javascript code that populates the second 
select box sets the value properly, or create a custom form validation 
(custom form/field clean methods).

On Tuesday, May 8, 2012 5:59:19 AM UTC+2, HDayi wrote:
>
> hi people, 
> i am new to all of this. 
> i have a form which has several selcet boxes. one is a 
> ModelChoiceField gets school list from database. the other is only a 
> ChoiceField and it's empty. when school   is chosen i populate the 
> ChoiceField using dajax. it works perfectly but... 
>
> while validating the form when calculating the cleaned_data value 
> returns index of the selected item and django does not validate the 
> form. 
>
> can you help me on this? 
> thx 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ezZh3lD2mRcJ.
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: Customizing Django Admin Site

2012-05-07 Thread francescortiz
You can create pseudo fields in the admin

class CarAdmin(admin.ModelAdmin)
list_display = ('name','custom_field')
def custom_field(srlf, obj):
return mark_safe('http://www.google.com";>Link')
custom_field.short_description = 'Link to Google'
custom_field.allow_tags = True

I am not sure if this is what you look for, and I am not sure if allow_tags 
is needed




On Monday, May 7, 2012 12:41:59 PM UTC+2, Aditya Sriram M wrote:
>
> Hi All,
>
> I could successfully try the Django framework on my Oracle DB. I never 
> thought programming would be this easy!!!
> Thanks for the wonderful framework.
>
> Now, I want to have an Admin Site with 'another such admin site in its 
> row'. Is it possible?
>
> Example: Take the models Customers, Users and Devices. Customers are 
> unique and they can have 'n' Users and/or 'm' Devices.
> I will want to display the rows in Admin Site for the Customer Model and 
> initially provide 'Click for Users' and 'Click for Devices' buttons in the 
> last two rows.
> On clicking them another admin site for limited (say 10 rows) 
> users/devices should be opened in an inner table with its own search box. 
>
> Is this possible? Any workarounds will be much appreciated.. Thnx..
>
> Regards,
> Aditya
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/B9rRUTFSS3EJ.
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: Instalación en centOs 6.2

2012-05-07 Thread francescortiz
Para centos debes seguir los mismos pasos que en cualquier otro lugar. 
Apache con fastcgi, o con wcgi, o nginx, o lighttpd, o cherokee... tu 
mismo. Hay guias por todos lados. Solo debes tener en cuenta que 
dependiendo del servidor que escojas, tu eres responsable de rearrancar las 
instancias de django cuando se reinicia el servidor.

También te recomiendo que mires el tema del los virtual envs, porqué sale 
una versión de django más o menos cada año i poco, y no te interesa tener 
que revisar todos los sitios antiguos cuando actualizes el sistema y te 
suba la versión de django. Es mejor que cada instancia de django use su 
propia versión de django y sus propias librerias.

On Thursday, May 3, 2012 9:45:30 PM UTC+2, Segundo Acosta Delgado wrote:
>
> Como es la instalación en centOS 6.2 de 64 bits 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/lHMy8LfgZpIJ.
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: Compare List

2012-05-06 Thread francescortiz
If I am not mistaken, the same way that you would construct a SQL query 
like 

SELECT * FROM table1 t1
INNER JOIN table2 t2 ON t2.t1_id = t1.id
INNER JOIN table3 t3 on t2.t3_id = t3.id
WHERE t3.id = '1'
AND t3.id = '2'
AND t3.id = '3'
AND t3.id = '4'
AND t3.id = '5'

(many AND t3.id = 'X')

you will have to set many Q instances or many filters, one for each id.

also, I believe that if you use Q instances only with & operations, you can 
just use filter and forget about Q.



On Saturday, May 5, 2012 6:22:43 PM UTC+2, Adriano Costa dos Reis wrote:
>
> Hey guys, I'm having a problem that I don't know if there is any 
> feature that I can use to filter a list in django. 
> What I'm trying to do is to use a manual get_or_create. I have the 
> following models: 
> class STREAM(models.Model): 
> stream_inds = models.ManyToManyField('STREAM_Ind') 
> Type = models.CharField(max_length = 5) 
> Throughput = models.DecimalField(max_digits = 15, 
> decimal_places = 3) 
>
> class STREAM_Ind(models.Model): 
> Port = models.IntegerField() 
> Throughput = models.DecimalField(max_digits = 15, 
> decimal_places = 3) 
>
> What I've tried to do so far is this: 
>try: 
> qset = ( 
>   
> Q(stream_inds__pk__iexact = ids) & 
>   
> Q(Type__iexact = type) & 
>   
> Q(Throughput__iexact = throughput) 
> ) 
> streams = 
> STREAM.objects.select_related().filter(qset).distinct().get() 
> except 
> STREAM.DoesNotExist: 
> fields = { 
>   
> 'Type': type, 
>   
> 'Throughput': throughput, 
> } 
> form = 
> STREAMForm(fields) 
> streams = 
> form.save() 
> The third line is where I think the problem is, ids is a variable that 
> contains a list of id that are supposed to match with all the primary 
> keys of the STREAM_Ind model. So I can be sure that the data is 
> already in the database, but the first Q object i think always return 
> false. Is there some way to do it? (I thought about using the "in" 
> feature, but I need to make sure all pk are matched in order to 
> retrieve the object, not just one of them). Is there a feature that 
> allow me to do that? If not can you guys give me a hint of what am I 
> supposed to do?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/hpl0YkcKZkEJ.
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: A problem with a solution, but is it the right one?

2012-01-20 Thread francescortiz
I would pass bound data instead of calling from_request:
https://docs.djangoproject.com/en/dev/ref/forms/api/#ref-forms-api-bound-unbound

This way you don't have to worry about forms logic, but just about
filling the default data.

Francesc

On Jan 18, 8:42 pm, Jeff Heard  wrote:
> My basic problem is this: I have multiple kinds of requests that come in,
> and some of them share parameters and valid values and default values. I
> cannot expect my users to pass all form values on the URL line, but
> unpassed parameters must be set to appropriate defaults, not merely None.
>
> These shared parameter sets are broken out into separate RequestForm
> classes, but I also wanted to put the parsing and default values into those
> classes. So I came up with the "from_request" method, which I put into each
> RequestForm subclass and created a class method called "create" in
> RequestForm that class every class in cls.mro()'s from_request method
> independently, then calls .clean() on the form to validate it.
>
> Another caveat is that I must shadow the request.GET dictionary with a
> case-insensitive dictionary, which I take care of in the
> django.views.generic.View.dispatch() method.
>
> The code for my proposed solution is here:
>
> http://dpaste.com/hold/689872/
>
> Does this make sense to people?  Sorry to kind of flood the list with this
> problem all day in different forms, but i think I'm close to having
> something I like.
>
> -- Jeff

-- 
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: Staticfiles on shared hosting using FCGI

2012-01-15 Thread francescortiz
You can place the static files in the public html directory via
symlink if allowed or copying them, and have rewrite rules that
redirect to your django fcgi instance only in case a a file doesn't
exist.

On Jan 14, 8:06 am, Tundebabzy  wrote:
> I am stuck after running collectstatic. I don't know how to point the
> server to STATIC_ROOT.
> Can someone give assistance.

-- 
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: Url rewrite for search engines

2012-01-07 Thread francescortiz
For example, in urls.py:

('^entry/?P(.*)/', 'entry'),

and in your models you have an slug field

On Jan 7, 1:13 am, Lie Ryan  wrote:
> On 01/07/2012 11:04 AM, Barış Bilgiç wrote:
>
> > Hi,
>
> > I am looking for how to implement URL rewrite in Django which is
> > explained inhttp://en.wikipedia.org/wiki/Rewrite_engine.
>
> > For example,I would like to convert
>
> > |http://127.0.0.1:8000/employer/details/20/|to|http://127.0.0.1:8000/employername-20.htm|
>
> > How can I implement this in Django? could suggest me a document or give
> > an example ?
>
> you write your url to view mapping in urls.py, note that in django, you
> don't need to do a crude hack like "rewriting url" instead you specify
> that an url is to be specified by certain views.

-- 
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: Model for images with thumbnails

2012-01-06 Thread francescortiz
you can try https://github.com/francescortiz/image

On 6 ene, 12:35, MeME  wrote:
> Hello,
>
> I'm new to Django. I started to write something for personal
> purposes.
> I have doubts about writing model for media files, especially images.
> In my app thumbnails should be automatically created when image is
> uploaded. Each such image can have thumnails with different
> dimensions. Images can be attached to posts.
>
> The question is how to store such information in database?
>
> Should it be separate records for each thumbnail and main image? And
> how to keep relationship?
>
> Or maybe I could store everything in one record as a serialized data
> (as in Wordpress)? Then I could as well store there HTML for image and
> metadata.
>
> --
> Regards
> MM

-- 
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 STATIC_URL in CSS/JS files?

2012-01-05 Thread francescortiz
The only case in which you can have issues with double brackets is
when a '{{' appears in the same line and before than a '}}'.

On Jan 4, 10:18 pm, Bill Freeman  wrote:
> Good point.  But you can run into double braces in JS.
>
>
>
>
>
>
>
> On Tue, Jan 3, 2012 at 3:29 PM, Christophe Pettus  wrote:
>
> > On Jan 3, 2012, at 11:18 AM, Bill Freeman wrote:
>
> >> This will be even morepainful if you use Django templates as the
> >> templating engine, since you will have to quote all those braces that you 
> >> need
> >> in CSS and Javascript.
>
> > I don't believe this is correct; Django's templating engine doesn't choke 
> > on single braces.
>
> > --
> > -- Christophe Pettus
> >   x...@thebuild.com
>
> > --
> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.

-- 
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: UnicodeDecodeError

2012-01-05 Thread francescortiz
Also, don't forget about the magic functions provided by django:
smart_unicode and smart_str

On Jan 5, 2:27 pm, Karen Tracey  wrote:
> On Thu, Jan 5, 2012 at 8:16 AM, César Frias  wrote:
> > I guess you have some files without the # -*- coding: utf-8 -*- on the top
> > of the file
>
> > You will need this if you want to use some letters like é or ç...
>
> No, you get a different exception if you are missing the encoding
> declaration in a Python file that contains non-ASCII characters. In that
> case you get a SyntaxError that complains specifically about the missing
> encoding declaration.
>
> Getting an error from the utf8 codec attempting to transform a bytestring
> to unicode implies you've got some bytestring data that is assumed to be
> encoded in utf8 but is in fact using some other encoding. Since this is
> happening when rendering a template, my guess would be the template file's
> encoding is something other than utf8. Django has a setting 
> (https://docs.djangoproject.com/en/1.3/ref/settings/#file-charset) that
> controls what encoding is assumed for files read from disk, it defaults to
> utf8. Either fix the encoding of the template file to be utf8 or change
> that setting to match whatever encoding is being used for all your template
> files on disk.
>
> Karen

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



Re: Thread synchronization

2012-01-04 Thread francescortiz
http://stackoverflow.com/questions/1123200/how-to-lock-a-critical-section-in-django

On Jan 3, 7:28 pm, Pawel Rzeczewski  wrote:
> It won't work in forked processes.
>
>
>
>
>
>
>
> > Tried Google.
> >http://effbot.org/zone/thread-synchronization.htm

-- 
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 STATIC_URL in CSS/JS files?

2012-01-03 Thread francescortiz
Appart of using relative paths when I want to use STATIC_URL in
javascript I define a global javascript variable in my base.html
template, so it is available in my javascript files.


window.STATIC_URL = '{{STATIC_URL}}';


On Jan 3, 4:38 am, Andres Reyes  wrote:
> If you're serving your media from the same domain as your CSS i'd use
> relative paths
>
> 2012/1/2 Christophe Pettus :
>
>
>
>
>
>
>
>
>
>
>
> > On Jan 2, 2012, at 5:56 PM, Victor Hooi wrote:
> >> E.g. I have a CSS file that points to a PNG sprite, and I'd like a way to 
> >> get it to point to {{ STATIC_URL}} without hardcoding the URL/path - any 
> >> way?
>
> > You can use Django to serve your CSS file if you want to, although you'll 
> > want to cache the heck out of it for performance reasons.  There are also a 
> > wide variety of tools which generate CSS from various input files to allow 
> > for various kind of template expansion, and those might be a suitable 
> > alternative.
>
> > --
> > -- Christophe Pettus
> >   x...@thebuild.com
>
> > --
> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Andrés Reyes Monge
> armo...@gmail.com
> +(505)-8873-7217

-- 
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: Need help in renaming template tags

2012-01-02 Thread francescortiz
Why are you using two thumbnail providers?

On Dec 26 2011, 3:01 pm, CareerDhaba tech 
wrote:
> Hey everyone,
>
> I am running into an issue where two third party apps easy_thumbnail and
> sorl_thumbnail are using the custom template tag called thumbnail. Hence, I
> am actually unable to use the tag at all. I would like to change it so that
> the template tag from sorl_thumbnail is renamed as sorl_thumbnail. A
> similar issue has cropped up before over on SO, but it hasn't been
> resolved. See here:http://bit.ly/sE64Tb
>
> I have created a templatetags module within one of my apps, and have tried
> a simple way to rename a registered tag as such:
>
> from django import template
> from sorl.thumbnail.templatetags import thumbnail
>
> register = template.Library()
>
> def do_sorl_thumbnail(parser, token):
> return thumbnail(parser, token)
> register.tag('sorl_thumbnail', do_sorl_thumbnail)
>
> Do I need to write a compile function and a render function for this? Any
> help on this would be great.
>
> Thanks,
> Harshil

-- 
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 access to static data

2012-01-01 Thread francescortiz
If you are sending a 2mb json on every action and there are only about
40 nutrients per food, either I am missing a point or something is
really wrong about your logic.

On Dec 3 2011, 12:34 pm, mf  wrote:
> I'm building an application and I'm having trouble making a choice
> about how is the best way to access multiple times to static data in a
> django app. My experience in the field is close to zero so I could use
> some help.
>
> The app basically consists in a drag & drop of foods. When you drag a
> food to a determined place(breakfast for example) differents values
> gets updated: total breakfast calories, total day nutrients(Micro/
> Macro), total day calories, ...That's why I think the way I store and
> access the data it's pretty important performance speaking.
>
> This is an excerpt of the json file I'm currently using:
>
> foods.json
>
> {
> "112": {
>     "type": "Vegetables",
>     "description": "Mushrooms",
>     "nutrients": {
>         "Niacin": {
>             "unit": "mg",
>             "group": "Vitamins",
>             "value": 3.79
>         },
>         "Lysine": {
>             "units": "g",
>             "group": "Amino Acids",
>             "value": 0.123
>         },
>         ... (+40 nutrients)
>     "amount": 1,
>     "unit": "cup whole",
>     "grams": 87.0 }
>  }
>
> I've thought about different options:
>
> 1) JSON(The one I'm currently using):
>
> Every time I drag a food to a "droppable" place, I call a getJSON
> function to access the food data and then update the corresponding
> values. This file has a 2mb size, but it surely will increase as I add
> more foods to it. I'm using this option because it was the most
> quickest to begin to build the app but I don't think it's a good
> choice for the live app.
>
> 2) RDBMS with normalized fields:
>
> I could create two models: Food and Nutrient, each food has 40+
> nutrients related by a FK. The problem I see with this is that every
> time a food data request is made, the app will hit the db a lot of
> times to retrieve it.
>
> 3) RDBMS with picklefield:
>
> This is the option I'm actually considering. I could create a Food
> models and put the nutrients in a picklefield.
>
> 4) Something with Redis/Django Cache system:
>
> I'll dive more deeply into this option. I've read some things about
> them but I don't clearly know if there's some way to use them to solve
> the problem I have.
>
> Thanks in advance, Mariano.

-- 
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: Internationalization and localization

2012-01-01 Thread francescortiz
I always create multilingual sites. What I do is inspired by django-
modeltranslation, but I find awkward that it leaves a "default"
language field and I prefer to have all my fields defined inside my
models.

1. Create a field for each language and a function that returns the
field corresponding to the client language:

class MyModel(models.Model):
title_ca = models.CharField(max_length=255)
title_en = models.CharField(max_length=255)
title_es = models.CharField(max_length=255)
def title(self):
return getattr(self, 'title_%s' % get_language())

2. In templates call the fuction that detects the language:
{{object.title}}

2. Then, urls.py looks like this:
   (r'^$', 'home'),
(r'^(?P\w{2})/$', 'home'),

3. And views.py:

from myapp.utils import enable_language

def home(request, language=None):

# We don't want urls without language prefix in order to prevent
duplicate content
if language is None:
return
HttpResponseRedirect(reverse('isaweb.views.home',kwargs={'language':get_language()})
 )

enable_language(request, language)

return render_to_response('home.html',
{},context_instance=RequestContext(request))

4. This goes into utils.py:

def enable_language(request, language):
# Language only gets updated if it changed or is not set.
try:
if request.session['django_language'] != language:
request.session['django_language'] = language
translation.activate(language)
request.LANGUAGE_CODE = translation.get_language()
except KeyError:
request.session['django_language'] = language
translation.activate(language)
request.LANGUAGE_CODE = translation.get_language()




On Dec 7 2011, 3:14 am, kenneth gonsalves 
wrote:
> On Mon, 2011-12-05 at 19:00 -0800, rentgeeen wrote:
> > What I want to how to translate stuff from DB, all at django official
> > say is about static content, what I have only found is this:
>
> django-modeltranslation
> --
> regards
> Kenneth Gonsalves

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



django e-commerce logic

2012-01-01 Thread francescortiz
I've been looking around for django commerce sollutions for a while
and they all seem to work with predefined database models. For
instance, you always have a name field and a slug field that come with
the product. While this could seem fine if you are creating a store
form scratch, it makes it very uncomfortable if you already have a
model structure on a site and you just want to start selling one of
your models.

What I would feel more comfortable is to add a commerce layer to the
site and tell this layer how to obtain the product information, client
information, etc, or fallback to provided defaults, so it can fit in
any existing project without having to run data migrations of any
kind.

Do you know any django commerce that works like this?

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



Re: Need help for using easy_thumbnails

2012-01-01 Thread francescortiz
I wrote a thumbnailing app myself:

https://github.com/francescortiz/image

The main advantages of this are:
- You set the center of attention for images through the admin
section. This way, when you crop your image it looks properly aligned,
whatever crop you do. This is the reason why I created it.
- Video thumbnails through ffmpeg
- Cached images can be exposed to public http docs, so you can have
rewrite rules to skip django when serving them.

Also:
- maks
- overlays
- thumbnails from urls (i.e: handle thumbnails for youtube videos)

On Dec 7 2011, 6:41 am, "Nibil M.S"  wrote:
> I am using Django Development trunk version on Fedora 15. I tried to enable
> the thumbnails option on my project followed by the instructions given 
> inhttps://github.com/SmileyChris/easy-thumbnails. But the thumbnail is not
> working. Only the image is loading. Please help to fix the problem.
> Attaching the bookpage.html file which uses this thumbnails. I have added
> the 'easy_thumbnails' in INSTALLED_APPS of settings.py
> --
> Nibil M.S
> 'Needam'
> Trithala.
>
>  bookpage.html
> < 1KViewDownload

-- 
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: Maintain server-initiated FTP connection between client requests?

2011-12-29 Thread francescortiz
You will have to create a connection pool as a resident thread.
Briefly, a connection pool will take care of:
- Create a new connection if there is no connection available.
- Reuse a connection if possible.
- Remove connections that are no longer being used or that commanded
to close.

Then, your code will have have to communicate with the connection
pool. Example code:

# The connection_pool is smart enough to reuse a connection if it is
in the pool
ftp_connection = connection_pool.get_connection(server, user, pass)

current_dir = ftp_connection.getcwd()
dir_contents = ftp_connection.ls()
ftp_connection.rm(file)


You have a similar implementation here:
http://forum.codecall.net/python-tutorials/41844-object-pooling-python.html



On Dec 29, 2:51 am, Jordon Wing  wrote:
> Hey,
> I'm going to use ftplib to open up an FTP connection to an FTP server
> provided by the user.  The client will be sending FTP commands to my django
> server via Ajax, which will then be forwarded to the FTP server the user
> provided. However, I'd like to not have to create a new FTP server
> connection every time the client sends an FTP command. In other words, I
> want to keep the FTP connection alive between requests by the client.
>
> How would I do this? Would some sort of comet implementation be best? I was
> initially planning to use WebSockets until I discovered my host won't allow
> it. =\

-- 
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: Drag and drop functionality?

2011-08-26 Thread francescortiz
By your comment it seems that your question is more about browser
capabilities than django. If this is the case, check HTML5 to see what
can be used for drag and drop, like files in gmail.

On Aug 24, 7:22 pm, glenn hafstrom  wrote:
> Hi Reinout
>
> Thanks for your input.
> I've googled a lot but I haven't found anything where I can drag from
> another application to my django-site
>
> Regards
> glenn
>
> On 24 Aug, 13:30, Reinout van Rees  wrote:
>
>
>
>
>
>
>
> > On 24-08-11 13:19, glenn hafstrom wrote:
>
> > > I'm new to this and I have just started with django.
> > > I would like to have some kind of container for example I would like
> > > to drag and drop a webaddress
> > > to the container and then save them in my django application.
> > > Is there any Javscript or anything else that I can use to handle
> > > this?
>
> > Best way is to do it in two steps:
>
> > - First make a regular django form with one input field for the url and
> > a submit button. Get that working.
>
> > - Second step: google for some javascript that handles it. "jquery ui"
> > has some drag/drop support, but I don't know if that also works for
> > items dragged from outside the browser window.
>
> > But get step 1 working first. Step 2 will need that functionality in
> > place to be able to do something :-)
>
> > Reinout
>
> > --
> > Reinout van Rees                    http://reinout.vanrees.org/
> > rein...@vanrees.org            http://www.nelen-schuurmans.nl/
> > "If you're not sure what to do, make something. -- Paul Graham"

-- 
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: ANN: django-socketio 0.1.0 released

2011-08-15 Thread francescortiz
Looks really good. Thank you.

On Aug 13, 6:06 am, Stephen McDonald  wrote:
> Hi all,
>
> Our Django Dash entryhttp://drawnby.jupo.orgmade extensive use of
> Socket.IO (cross-browser websockets) and born out of that I've created a new
> django-socketio package which is now available:
>
> Github:https://github.com/stephenmcd/django-socketio
> Bitbucket:https://bitbucket.org/stephenmcd/django-socketio
> PyPI:http://pypi.python.org/pypi/django-socketio/
>
> Here's an overview from the docs:
>
> django-socketio is a BSD licensed Django application that brings together a
> variety of features that allow you to use WebSockets seamlessly with any
> Django project. django-socketio was inspired by Cody Soyland's introductory
> blog post on using Socket.IO and gevent with Django, and made possible by
> the work of Jeffrey Gelens' gevent-websocket and gevent-socketio
> packages. The features provided by django-socketio are:
>
> - Installation of required packages from PyPI
> - A management command for running gevent's pywsgi server with
> auto-reloading capabilities
> - A channel subscription and broadcast system that extends Socket.IO
> allowing WebSockets and events to be partitioned into separate concerns
> - A signals-like event system that abstracts away the various stages of a
> Socket.IO request
> - The required views, urlpatterns, templatetags and tests for all the above
>
> Cheers,
> Steve
>
> --
> Stephen McDonaldhttp://jupo.org

-- 
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 save inlines?

2011-08-09 Thread francescortiz
The django documentation about ModelAdmin.save_model seems to be what
you look for. The example they give does almost what you want:

https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model

On Aug 8, 11:32 pm, galgal  wrote:
> I need to override save method of inlines in admin. While saving photos, I
> need to add user id to DB column. I cant make it in model because there is
> no request data there. How can I do it in admin, to somehow get nad set user
> id?

-- 
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 there a way to use a tree control in my template

2011-08-09 Thread francescortiz
What part are you missing? How to write the django template, how to
access the data or the what is the related HTML?

On Aug 8, 9:43 pm, Hayyan Rafiq  wrote:
> Hi i wanted to know is there a way through which i could use a tree control 
> in my template
> I wanted to add something like
>
>    Student
>       |_Name
>            |_Address
>            |_Contact No
>
> I think you guys get the picture...How can i add something like that in my 
> template...Thanks

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



Re: Using Form Elements Widgets direclty in HTML

2011-08-09 Thread francescortiz
You can have a look to the as_p method of django Form class and create
your own renderer based on that.

On Aug 9, 4:09 pm, Hayyan Rafiq  wrote:
> Could you please give an example.. say of a simple input box
> in html its done like
> 
>
> How would i replace the default input box with the one from Django widgets??
>
> Date: Tue, 9 Aug 2011 18:34:56 +0800
> Subject: Re: Using Form Elements Widgets direclty in HTML
> From: changjia...@gmail.com
> To: django-users@googlegroups.com
>
> Since you don't want to use forms class, you can write elements in your 
> templates directly.
>
> 2011/8/9 Hayyan Rafiq 
>
> Hi I wanted to know if there was a way in which we could use widget directly 
> in an HTML file
> By widget i mean elements of a form such as input boxes,calendars,Buttons etc 
> without using the forms class.
>
> For example A default normal html input box is :
>
> 
> I wanted to replace it with a fancier (more interesting and professional) 
> input box..
> any suggestions on how i could do that would be appreciated..
>
> I  also wanted to use a table in my HTML to display contents from my DB. Do 
> you guys have anything in mind which might be useful for me...
> I currently am generating the table dynamically using  tag
>
> --
>
> 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 
> athttp://groups.google.com/group/django-users?hl=en.
>
> --
>
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
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: Google AppEngine vs. dedicated hosting (Pros/cons)

2011-08-08 Thread francescortiz
Hi,

I have dedicated server sites and django hosting sites. Personally, I
prefer that someone else takes care of the server and focus myself on
development. So, unless you need to use a lot of resources for some
reason, dedicated django hostings are ok to me.

About google apps, I never used it.

Regards,

Francesc

On Aug 5, 1:48 pm, Herman Schistad  wrote:
> Hello.
>
> I'm developing a site with approx. 500 visits per day, mainly from
> Norway (Europe).
>
> Now I'm trying to find the best possible way to host this site.
> Earlier I've used dedicated hosts like WebFaction and Djangoeurope,
> and this has worked pretty well.
> However Google AppEnginge is free and provides a really reliable
> server (as far as I can tell). But I'm no expert on this matter and
> therefore come to you guys.
>
> What is the tradeoff between using Google AppEngine (with
> django-nonrel [1]), learning this, and writing my application for the
> Google datastore versus using a traditional host.
> Are there any big challanges by using AppEngine?
>
> A third alternative would to maybe invest in e.g. dedicated virtual
> machine at MediaTemple[2] or something.
>
> So what it all boils down to: which is your preffered hosting method,
> and why/why not?
> - Google AppEngine
> - Dedicated django hosting (e.g. WebFaction[3])
> - Virtual server/dedicated server (e.g. MediaTemple)
>
> tl;dr: pros/cons with Google AppEngine, and which hosting method is
> your preferred method?
>
> [1]:http://code.google.com/appengine/articles/django.html
> [2]:http://mediatemple.net/webhosting/dv/
> [3]:http://www.webfaction.com/
>
> --
> With regards, Herman Schistad

-- 
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-php 0.1

2011-08-08 Thread francescortiz
The FAQ section is awesome!

On Aug 5, 5:51 pm, rei  wrote:
> I accidentally PHP support for the Django template language.
>
> No support yet for cookies, headers or event GET / POST, but otherwise
> functional. See the source code for usage examples.
>
> Link:http://animuchan.net/django_php/

-- 
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 use less css in mac?

2011-08-08 Thread francescortiz
For the javascript part, the last thing they say before the footer in
lesscss.org is that you can embed javascript variables inside the css:

It is also possible to access the JavaScript environment:

@height: `document.body.clientHeight`;

I don't know how they handle it, but I don't find appropiate to mix
css and javascript.

And about being based on an older version of sass, i didn't use the
appropiate words. What I meant is that less was written because by
that time sass wasn't css compatible, but now the sass people created
scss, which is fully css compatible.

So, since the motivation that pushed the less people to create the
language (sass not being css compatible) does not apply today and
since they mix css and javascript, I find a more interesting option to
uses scss.

Regards,

Francesc

On Aug 6, 6:16 am, Eugene Lazutkin  wrote:
> Inline.
>
> On 08/03/2011 08:21 AM, francescortiz wrote:
>
> > LESS combines CSS and javascript which I think that goes beyond the
>
> What does it mean? Care to give an example? Like textually combining
> both languages? Or does it produces both JavaScript and CSS files?
>
> Last time I checked (today) it is a simple preprocessor, which produces
> pure CSS files. It can be run statically, or dynamically in a browser.
>
> > safe line, so I vote for SCSS (http://sass-lang.com/) that also has
> > a python version (http://github.com/Kronuz/pyScss).
>
> > LESS is based on an "older" version of SCSS that didn't follow CSS
> > syntax (SASS).
>
> LESS follows CSS rules, in fact any CSS is a valid LESS --- that was the
> whole idea of LESS as a superset of CSS.
>
> And could you give me a reference for my own education on "LESS is based
> on older version of SCSS"?
>
> Cheers,
>
> Eugene
>
>
>
>
>
>
>
>
>
> > On Aug 3, 1:52 pm, Tom Evans  wrote:
> >> On Wed, Aug 3, 2011 at 10:10 AM, Jithin Emmanuel  
> >> wrote:
> >>> Can some one please point out how to use less css along with compressor
> >>> extension?
> >>> I use mac 10.6.8 and I am trying to use an existing project which was
> >>> initially setup in windows.
> >>> I am trying to figure out what I should give here.
> >>> COMPRESS_PRECOMPILERS = (
>
> >>>     ('text/less',""),
> >>> )
> >>> Any help appreciated.
>
> >> Hadn't come across less css before, looks interesting - well, looks
> >> how I wanted CSS to behave 10 years ago.
>
> >> Does this help? Seems to have examples for less
>
> >>http://django_compressor.readthedocs.org/en/latest/settings/#compress...
>
> >> Cheers
>
> >> Tom

-- 
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 use less css in mac?

2011-08-03 Thread francescortiz
LESS combines CSS and javascript which I think that goes beyond the
safe line, so I vote for SCSS ( http://sass-lang.com/ ) that also has
a python version ( http://github.com/Kronuz/pyScss ).

LESS is based on an "older" version of SCSS that didn't follow CSS
syntax (SASS).

On Aug 3, 1:52 pm, Tom Evans  wrote:
> On Wed, Aug 3, 2011 at 10:10 AM, Jithin Emmanuel  wrote:
> > Can some one please point out how to use less css along with compressor
> > extension?
> > I use mac 10.6.8 and I am trying to use an existing project which was
> > initially setup in windows.
> > I am trying to figure out what I should give here.
> > COMPRESS_PRECOMPILERS = (
>
> >     ('text/less',""),
> > )
> > Any help appreciated.
>
> Hadn't come across less css before, looks interesting - well, looks
> how I wanted CSS to behave 10 years ago.
>
> Does this help? Seems to have examples for less
>
> http://django_compressor.readthedocs.org/en/latest/settings/#compress...
>
> Cheers
>
> Tom

-- 
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: Crop feature in django application

2011-07-29 Thread francescortiz
¿Why cropping on upload when you can let the system keep the center of
attention centered?

https://github.com/francescortiz/image

On Jul 29, 10:50 am, jaspreet kaur  wrote:
> I want to add crop option in Django application
> i followed the link:http://code.activestate.com/pypm/django-image-cropper/
> By following the steps given in the link, it doesnot give any effect
> on application
> Is there more steps to do for adding crop feature
> Thanks
>
> --
> Jaspreet

-- 
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: download-list app

2011-07-06 Thread francescortiz
I don't want to be rude, but your question is so bague that I think
that you should start by reading some python and django books/
documentation.

On Jul 6, 11:44 am, Gour-Gadadhara Dasa  wrote:
> Hello!
>
> I'm starting with Django trying to migrate all my sites from PHP apps to 
> Django
> apps...
>
> I'd like to have Download page to display list of available (mp3) files for 
> download:
>
> Filename | Size | Number of downloads | Last updated
>
> Is there some django apps providing similar functionality and/or what would be
> the starting points to implement it?
>
> Sincerely,
> Gour
>
> --
> “In the material world, conceptions of good and bad are
> all mental speculations…” (Sri Caitanya Mahaprabhu)
>
> http://atmarama.net| Hlapicina (Croatia) | GPG: 52B5C810
>
>  signature.asc
> < 1KViewDownload

-- 
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: Many user profiles

2011-06-20 Thread francescortiz
Try doing this in your models.py:

def get_profile(self):
...your code to get the profile for a the user...

User.get_profile = get_profile



On Jun 20, 9:54 am, gontran  wrote:
> Hello evreybody,
>
> I wonder how to deal with many user profiles.
> I need to store different informations depending on the status of my
> users.
>
> I have a generic UserProfile class:
>
> class UserProfile(models.Model):
>     user = models.OneToOneField(User, primary_key=True)
>     role = models.CharField(max_length=1, choices=USER_ROLE)
>
> and other classes for different profiles:
> CustomerProfile, EmployeProfile, ...
>
> For the admin part, I managed to separate each category of users with
> proxy models.
> I know that I can override get_profile() on each proxy model based on
> the User class.
>
> What I want to do:
> u = User.objects.get(pk=x)
> u.get_profile() ---> return the profile associated depending on the
> status of the user. If u is a customer, return a CustomerProfile
> instance, if u is an employe, return à EmployeProfile instance and so
> on.
>
> Is it possible to do it?
>
> Thanks in advance for your help.
>
> Regards,
>
> Gontran

-- 
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: registering unzipped files on the local disk

2011-06-19 Thread francescortiz
Well, I run the test:

code used:

http://pastebin.com/9FNT82ym

results (second result is stream copy):

$ python2 cp.py
8.55721712112
5.28589200974

$ python2 cp.py
8.5057990551
6.55976104736

$ python2 cp.py
6.88285589218
8.86908006668

$ python2 cp.py
5.8047721386
8.57982397079

$ python2 cp.py
8.38824915886
7.2968108654

$ python2 cp.py
5.52904415131
5.24869608879

$ python2 cp.py
7.50472903252
7.09118294716

So, stream copy seams to faster most of the times, what allows us to
conclude that it is fine to use stream copy.

Regards,

Francesc


On Jun 17, 10:37 pm, Faheem Mitha  wrote:
> Hi,
>
> Can anyone help me with
>
> http://stackoverflow.com/questions/6386062/django-registering-unzippe...
>
> ?
>
> If you reply via email, please cc me. Thanks.
>
>                               Regards, Faheem.

-- 
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: registering unzipped files on the local disk

2011-06-19 Thread francescortiz
Faheem,

In your post you write:

"This works, but I traced through the code, and found that the code
was using streaming, when clearly the optimal thing to do in this case
would be to just copy the file from the temporary location to the
permanent location"

In java copying files is performed by redericting data from a file
input stream to a file ouput stream, so your sentence sounded to me
like "Instead of copying a file I want to just copy a file" :P

Though I am no python expert, I suspect that using streams in python
is fine as well.

You could do some performance tests of stream copy vs copyfile
function in python. If you do, please share results!

Hope I help,

Francesc

On Jun 17, 10:37 pm, Faheem Mitha  wrote:
> Hi,
>
> Can anyone help me with
>
> http://stackoverflow.com/questions/6386062/django-registering-unzippe...
>
> ?
>
> If you reply via email, please cc me. Thanks.
>
>                               Regards, Faheem.

-- 
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: Moving Away from if/else Template Logic

2011-06-15 Thread francescortiz
you could try something like

{% with x.message|regtest as value %}
{% include "messages/"|add:value|add:".html" %}
{% endwith %}


On 15 Juny, 05:04, Greg Corradini  wrote:
> Hello All,
>
> I'm try to get away from doing if/else in a template:
>
> {% if x.message|regtest == "True" %}
>     do something cool
> {% else %}
>     do something less cool
> {% endif %}
>
> given this template filter:
>
> @register.filter(name='regtest')
> def regtest(value):
>     regex = re.compile(r'^\*\*(?P.*)\*\*')
>     m = regex.match(value)
>     if m != None:
>         return "True"
>     return "False"
>
> I would like to move to something like this in the template:
>
> {{ x.message|regtest }}
>
> given this template filter:
>
> def regtest(value):
>     regex = re.compile(r'^\*\*(?P.*)\*\*')
>     m = regex.match(value)
>     if m != None: return "%s"%value
>     else: return value
>
> However, the html tags returned from the filter becomes part of the
> element's text value instead of tags. So that's not working.
>
> I'm sure there's way better ways to side-step ugly if/else logic in
> the templates. What types of things can people recommend for a Django
> new guy.

-- 
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: headcut

2011-06-12 Thread francescortiz
Cal,

Thank you for your feedback. I really appreciate it. I will be
implementing what you say as soon as I can. Everything you said was
pretty clear except the part from including a RequestContext. Where is
the RequestContext missing?

Also, about using a template instead of embedding HTML in the code, I
don't think I will be doing that unless it comes to be necessary (or
someone demands that), in order to save some function calls, like they
do in django widgets source code (if I didn't guess wrongly why they
do it this way).

Your comments are great. I will be fixing the race condition this next
week, and the rest of what you comment ASAP.

Regards,

Francesc



On 12 Juny, 19:19, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> Sorry, one last thing.
>
> In relation to the resp html stuff, you should have actually used a template
> for that, loaded the variables into a request context, then rendered the
> template directly.
>
> Cal
>
> On Sun, Jun 12, 2011 at 6:18 PM, Cal Leeming [Simplicity Media Ltd] <
>
>
>
>
>
>
>
> cal.leem...@simplicitymedialtd.co.uk> wrote:
> > First, the good feedback.
>
> > Good use of exception blocks, code style, built-ins, standard libs etc..
> > Although I can't comment on the implementation on the end product, you have
> > clearly made an effort to use as many of the features offered by Django (and
> > python) as possible in this project. The fact you are using a decent code
> > repo (imo), is also a good sign. Though you still have a long way to go
> > (it's a never ending road lol), this is exceptionally good work for
> > a beginner.
>
> > And here's the criticisms / a few things that stand out..
>
> > Firstly:
>
> >    path = path.replace("..", "")
> >    path = path.replace("..", "")
> > (repeated 20 odd times)
>
> > Try replacing the above with os.path.basename() and os.path.abspath(), I
> > think a combination of both is what you are looking for (unless I've
> > mistaken what you were doing)
>
> > Secondly,
>
> >             resp = ''
> >             resp += ' > src="'+reverse('image.views.image',args=(value.image_path,'width=150&height=150&mode=scale'+extra_parms))+'"
> >  onclick=""/>'
> >             resp += ' > src="'+reverse('image.views.crosshair')+'" style="position:absolute; 
> > left:0; top:0;" />'
>
> > It is *extremely* bad practise to use string concatenation (even when
> > casting in-line). You should instead be using a sprintf style:
>
> > Example:
>
> > """ >     class_name
> > )
>
> > or
>
> > "
> > etc
>
> > Also, instead of using string appending (+=),you should instead append
> > them to a list, then do a string join on the list ("\n".join(resp))
>
> > Thirdly, I'm seeing a lack of RequestContext(), you should always include
> > it (even if you don't use it), makes life easier in the future.
>
> > Forthly, you are using a global within your code (global COUNTER). Using
> > globals within a multi-threaded application is extremely bad, and can/will
> > introduce undesirable race conditions. And believe me, this won't be the
> > first or last time a race condition screws you over :)
>
> > I see you are also using os.system(cmd), I would recommend looking into
> > using popen instead.
>
> > It might also be worth revisiting the code in a few days/weeks/months,
> > looking over it, and making a list of things you dislike about it. As ones
> > experience with any language progresses, their style changes slightly and
> > they find better ways of doing things. The key to a great programmer, is not
> > about making mistakes, but about recognising that you made one :) *imo
> > anyway!*
>
> > Hope this helps
>
> > Cal
>
> > On Sun, Jun 12, 2011 at 2:26 PM, francescortiz 
> > wrote:
>
> >> Hi,
>
> >> I developed a django app and I would like to know what you think about
> >> it. I am relatively new to python and django so I expect more
> >> criticism than enything else.
>
> >> Description:
> >> Django application that provides resizing and thumbnailing for images
> >> and videos with the ability to set the center of attention, heads
> >> won't get cut anymore.
>
> >> Link:
> >>https://github.com/francescortiz/image
>
> >> I am thinking of calling it "django-headcut"
>
> >> Thank you,
>
> >> Francesc
>
> >> --
> >> 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.

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



headcut

2011-06-12 Thread francescortiz
Hi,

I developed a django app and I would like to know what you think about
it. I am relatively new to python and django so I expect more
criticism than enything else.

Description:
Django application that provides resizing and thumbnailing for images
and videos with the ability to set the center of attention, heads
won't get cut anymore.

Link:
https://github.com/francescortiz/image

I am thinking of calling it "django-headcut"

Thank you,

Francesc

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