File Download

2009-01-03 Thread Sparky

Hello. This is probably a silly question but I have files being stored
onto a server and strangely getting them there was very easy but how
can I get them back down?

Thank you for your patience in advance,
Sam

--~--~-~--~~~---~--~~
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 community, is it active?

2012-12-18 Thread sparky
I'm hoping this is the right place to ask such questions, please forgive me 
if not.

I'm making a real time investment in learning another server side language. 
I have 10 years ColdFusion, 5 years  PHP, JAVA. Having never touched Python 
let alone the framework Django, for the past 4 weeks I have been testing 
Django out. Darn, Raspberry Pi started me with my blog 
(http://www.glynjackson.org/blog/) I have to say its nice, however my 
concerns are now to do with the community and not so much with the 
framework itself.

No one likes to back a loser and every time I search for Django community 
I'm faced with a host of negative posts. for example: 
http://news.ycombinator.com/item?id=2777883  

Unlike other languages I'm active in and still use, I'm also finding it 
hard to find any user groups locally in the UK (I'm based in Manchester, 
UK).

So from the community itself how alive is Django? Should I really invest 
the time to learn? Does it have a real future and please be honest.

other questions

1) is this worth going? --- http://2013.djangocon.eu
2) who are the top blogs people within the Django community who should I be 
following, blogs feed etc.

Sorry for the stupid questions, but and just want a new skillset that I can 
use for many years to come. Django is really cool









-- 
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/-/njMLaUXa0yQJ.
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 community, is it active?

2012-12-18 Thread sparky
thanks Nik,

On Tuesday, December 18, 2012 9:36:42 PM UTC, sparky wrote:
>
> I'm hoping this is the right place to ask such questions, please forgive 
> me if not.
>
> I'm making a real time investment in learning another server side 
> language. I have 10 years ColdFusion, 5 years  PHP, JAVA. Having never 
> touched Python let alone the framework Django, for the past 4 weeks I have 
> been testing Django out. Darn, Raspberry Pi started me with my blog (
> http://www.glynjackson.org/blog/) I have to say its nice, however my 
> concerns are now to do with the community and not so much with the 
> framework itself.
>
> No one likes to back a loser and every time I search for Django community 
> I'm faced with a host of negative posts. for example: 
> http://news.ycombinator.com/item?id=2777883  
>
> Unlike other languages I'm active in and still use, I'm also finding it 
> hard to find any user groups locally in the UK (I'm based in Manchester, 
> UK).
>
> So from the community itself how alive is Django? Should I really invest 
> the time to learn? Does it have a real future and please be honest.
>
> other questions
>
> 1) is this worth going? --- http://2013.djangocon.eu
> 2) who are the top blogs people within the Django community who should I 
> be following, blogs feed etc.
>
> Sorry for the stupid questions, but and just want a new skillset that I 
> can use for many years to come. Django is really cool
>
>
>
>
>
>
>
>
>
>

-- 
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/-/_dUN6Su5roIJ.
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 save method in infinite loop, code review?

2013-03-01 Thread sparky
Django newbie :) I'm wondering if you *kind people* could help me work out 
how to solve a little issue I'm having :) I'm using *S3 storage* via the 
package django-storages .

The following code gets stuck in an endless loop. I know  just enough to 
know why, but not how to solve...

*Remembering I'm a newbie*


This is what the the code I have written does so far

1) profile gets saves and image uploaded *(without the resize of course)*to S3 
- 
*PERFECT*
2) the full size image is then read from S3 in the image_resize function 
and resized and renamed in the database - *PERFECT*
3) old large image get deleted from S3 - - *PERFECT*
4) it is then saved on this line   *self.image.save *and continues it all 
over again in a *infinite* loop! - ERROR  


def save(self, *args, **kwargs):
# delete old file when replacing by updating the file
try:
this = Profile.objects.get(id=self.id)
if this.image != self.image:
this.image.delete(save=False)
except: pass # when new photo then we do nothing, normal case
super(Profile, self).save(*args, **kwargs)
if self.image:
image_resize(self)


def image_resize(self):
import urllib2 as urllib
from cStringIO import StringIO
from django.core.files.uploadedfile import SimpleUploadedFile

'''Open original photo which we want to resize using PIL's Image 
object'''
img_file = urllib.urlopen(self.image.url)
im = StringIO(img_file.read())
resized_image = Image.open(im)


'''Convert to RGB if necessary'''
if resized_image.mode not in ('L', 'RGB'):
resized_image = resized_image.convert('RGB')

'''We use our PIL Image object to create the resized image, which 
already
has a thumbnail() convenicne method that constrains proportions.
Additionally, we use Image.ANTIALIAS to make the image look better.
Without antialiasing the image pattern artificats may reulst.'''
resized_image.thumbnail((100, 100), Image.ANTIALIAS)

'''Save the resized image'''
temp_handle = StringIO()
resized_image.save(temp_handle, 'jpeg')
temp_handle.seek(0)


''' Save to the image field'''
suf = 
SimpleUploadedFile(os.path.split(self.image.name)[-1].split('.')[0],
 temp_handle.read(), 
content_type='image/jpeg')
self.image.save('%s.jpg' % suf.name, suf, save=True)



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




Re: Django save method in infinite loop, code review?

2013-03-01 Thread sparky
I did actually try that but if I do this...


# Resize if we have an image.
> if self.image:
> image_resize(self)
>
> super(Profile, self).save(*args, **kwargs)
>

then inside image_resize 'self' is the old image and I get a 404 error on 
the line...

 img_file = urllib.urlopen(self.image.url)
>


 

On Friday, March 1, 2013 2:52:23 PM UTC, Sergiy Khohlov wrote:
>
>  move your super up 
>
> Many thanks,
>
> Serge
>
>
> +380 636150445
> skype: skhohlov
>
>
> On Fri, Mar 1, 2013 at 4:48 PM, sparky >wrote:
>
>> Django newbie :) I'm wondering if you *kind people* could help me work 
>> out how to solve a little issue I'm having :) I'm using *S3 storage* via 
>> the package 
>> django-storages<http://django-storages.readthedocs.org/en/latest/>
>> .
>>
>> The following code gets stuck in an endless loop. I know  just enough to 
>> know why, but not how to solve...
>>
>> *Remembering I'm a newbie*
>>
>>
>> This is what the the code I have written does so far
>>
>> 1) profile gets saves and image uploaded *(without the resize of course)*to 
>> S3 - 
>> *PERFECT*
>> 2) the full size image is then read from S3 in the image_resize function 
>> and resized and renamed in the database - *PERFECT*
>> 3) old large image get deleted from S3 - - *PERFECT*
>> 4) it is then saved on this line   *self.image.save *and continues it 
>> all over again in a *infinite* loop! - ERROR  
>>
>>
>> def save(self, *args, **kwargs):
>> # delete old file when replacing by updating the file
>> try:
>> this = Profile.objects.get(id=self.id)
>> if this.image != self.image:
>> this.image.delete(save=False)
>> except: pass # when new photo then we do nothing, normal case
>> super(Profile, self).save(*args, **kwargs)
>> if self.image:
>> image_resize(self)
>> 
>> 
>> def image_resize(self):
>> import urllib2 as urllib
>> from cStringIO import StringIO
>> from django.core.files.uploadedfile import SimpleUploadedFile
>> 
>> '''Open original photo which we want to resize using PIL's Image 
>> object'''
>> img_file = urllib.urlopen(self.image.url)
>> im = StringIO(img_file.read())
>> resized_image = Image.open(im)
>> 
>> 
>> '''Convert to RGB if necessary'''
>> if resized_image.mode not in ('L', 'RGB'):
>> resized_image = resized_image.convert('RGB')
>> 
>> '''We use our PIL Image object to create the resized image, which 
>> already
>> has a thumbnail() convenicne method that constrains proportions.
>> Additionally, we use Image.ANTIALIAS to make the image look 
>> better.
>> Without antialiasing the image pattern artificats may reulst.'''
>> resized_image.thumbnail((100, 100), Image.ANTIALIAS)
>> 
>> '''Save the resized image'''
>> temp_handle = StringIO()
>> resized_image.save(temp_handle, 'jpeg')
>> temp_handle.seek(0)
>> 
>> 
>> ''' Save to the image field'''
>> suf = SimpleUploadedFile(os.path.split(self.image.name
>> )[-1].split('.')[0],
>>  temp_handle.read(), 
>> content_type='image/jpeg')
>> self.image.save('%s.jpg' % suf.name, suf, save=True)
>>
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

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




Re: Django save method in infinite loop, code review?

2013-03-01 Thread sparky
right *OK* now I get it. see, just needed a little push in the right 
direction...


so I moved super up
I then changed to use  resized_image = Image.open(self.image)
I then changed *self.image.save('%s.jpg' % suf.name, suf, save=False)

*and* BOOM! *all working!*

Thanks so much, this is so fun!
*

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




Good tutorials on celeryd as a daemon needed?

2013-04-08 Thread sparky
Hi Django people,

I'm finding it difficult to get my head around running celeryd as a daemon 
from the docs on Ubuntu. Does anyone know of any good tutorials or reading 
to help me along?

Thanks

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




django-sagepay example

2013-04-09 Thread sparky
 

I want to use 
django-sagepay.
 
However, it doesn't  seem to have any examples or test.py that I can learn 
from. being a newbie I need docs! 

Does anyone know of any examples of use? I'm very familiar with sagepay, 
just need to know how to implement this application into my app.

For example, any app I can look at that makes use of this 
django-sagepay
?


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




Re: django-sagepay example

2013-04-10 Thread sparky
wow  a million times thank you! just what I needed to get going. :))) 

On Tuesday, April 9, 2013 5:27:12 PM UTC+1, sparky wrote:
>
> I want to use 
> django-sagepay<https://github.com/timetric/django-sagepay/tree/master/django_sagepay>.
>  
> However, it doesn't  seem to have any examples or test.py that I can learn 
> from. being a newbie I need docs! 
>
> Does anyone know of any examples of use? I'm very familiar with sagepay, 
> just need to know how to implement this application into my app.
>
> For example, any app I can look at that makes use of this 
> django-sagepay<https://github.com/timetric/django-sagepay/tree/master/django_sagepay>
> ?
>
>
>

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




Re: django-sagepay example

2013-04-10 Thread sparky
@ke1g thats a very sweeping generalisation.

personally, we are PCI DSS level 2 compliant, have scans and all data is 
transmitted using SSL. we are resellers
we also NEVER store card details EVER only transmit! I'm a newbie to Django 
but have implemented 
sagepay on 3 other languages on sites which takes thousands a day over the 
last 5 years (when it was Protx) 

have you ever used sagepay? you don't need to store card details they also 
offer VSP form and server.


On Wednesday, April 10, 2013 1:15:17 PM UTC+1, ke1g wrote:
>
> An please, indicate on your site that the credit card number will go 
> through your site, so that I can know to never buy anything there.
>
> I suspect that I can count on my fingers and toes the number of web 
> developers in the world who have the knowledge, patience, and diligence to 
> securely handle credit card information.
>
> Services like Authorize.Net are the way to go.
>
>
> On Tue, Apr 9, 2013 at 7:54 PM, Mario Gudelj 
> > wrote:
>
>> Hey sparky,
>>
>> I hope this helps:
>>
>> Create your checkout form and if the form is valid populate the following 
>> dict with the form data:
>>  
>> data = {
>> 'VPSProtocol': settings.VPS_PROTOCOL,
>> 'TxType': settings.TXTYPE,
>> 'VendorTxCode': 
>> b32encode(uuid.uuid4().bytes).strip('=').lower(),  # Generate a new 
>> transaction ID
>> 'Vendor': settings.SAGEPAY_VENDOR,
>> 'Amount': order.totalAmountAsString(),
>> 'Currency': 'GBP',
>> 'Description': 'BC Order ID: %s' % order.orderId,
>> 'CardHolder': clean_checkout_form['card_name'],
>> 'CardNumber': clean_checkout_form['card_number'],
>> 'ExpiryDate': 
>> clean_checkout_form['card_expiry'].strftime('%m%y'),
>> 'CV2': clean_checkout_form['card_CVV'],
>> 'CardType': clean_checkout_form['card_type'],
>> 'CustomerEMail': clean_checkout_form['email'].lower(),
>> 'BillingSurname': clean_checkout_form['lastname'],  # 20 
>> Chars
>> 'BillingFirstnames': clean_checkout_form['firstname'], # 
>> 20 Chars
>> 'BillingAddress1': 
>> clean_checkout_form['billing_address'],  # Truncate to 100 Chars
>> 'BillingCity': clean_checkout_form['billing_city'],  # 
>> Truncate to 40 Chars
>> 'BillingPostCode': 
>> clean_checkout_form['billing_postcode'],  # Truncate to 10 Chars
>> 'BillingCountry': clean_checkout_form['billing_country'], 
>>  # 2 letter country code
>> 'DeliverySurname':  clean_checkout_form['lastname'],  # 
>> 20 Chars
>> 'DeliveryFirstnames': clean_checkout_form['firstname'], 
>>  # 20 Chars
>> 'DeliveryAddress1': 
>>  clean_checkout_form['shipping_address'],  # 100 Chars
>> 'DeliveryCity': clean_checkout_form['shipping_city'], # 
>> 40 Chars
>> 'DeliveryPostCode': 
>> clean_checkout_form['shipping_postcode'],  # 10 Chars
>> 'DeliveryCountry': 
>> clean_checkout_form['shipping_country'],  # 2 letter country code
>> 'CreateToken': 1
>> }
>>
>> Your field names will be different.
>>
>> Encode it:
>>
>>
>>
>> On 10 April 2013 02:27, sparky > wrote:
>>
>>> I want to use 
>>> django-sagepay<https://github.com/timetric/django-sagepay/tree/master/django_sagepay>.
>>>  
>>> However, it doesn't  seem to have any examples or test.py that I can learn 
>>> from. being a newbie I need docs! 
>>>
>>> Does anyone know of any examples of use? I'm very familiar with sagepay, 
>>> just need to know how to implement this application into my app.
>>>
>>> For example, any app I can look at that makes use of this 
>>> django-sagepay<https://github.com/timetric/django-sagepay/tree/master/django_sagepay>
>>> ?
>>>
>>>
>>>  -- 
>>> You received

Re: django-sagepay example

2013-04-10 Thread sparky
@ke1g also there are very high compliance standards in the UK. You have to 
be complaint or the merchants 
get on your case. 
you have to have port scans, SSL and some level of PCI DSS to take cards on 
your site with sagepay. 


just my 2p


On Wednesday, April 10, 2013 1:15:17 PM UTC+1, ke1g wrote:
>
> An please, indicate on your site that the credit card number will go 
> through your site, so that I can know to never buy anything there.
>
> I suspect that I can count on my fingers and toes the number of web 
> developers in the world who have the knowledge, patience, and diligence to 
> securely handle credit card information.
>
> Services like Authorize.Net are the way to go.
>
>
> On Tue, Apr 9, 2013 at 7:54 PM, Mario Gudelj 
> > wrote:
>
>> Hey sparky,
>>
>> I hope this helps:
>>
>> Create your checkout form and if the form is valid populate the following 
>> dict with the form data:
>>  
>> data = {
>> 'VPSProtocol': settings.VPS_PROTOCOL,
>> 'TxType': settings.TXTYPE,
>> 'VendorTxCode': 
>> b32encode(uuid.uuid4().bytes).strip('=').lower(),  # Generate a new 
>> transaction ID
>> 'Vendor': settings.SAGEPAY_VENDOR,
>> 'Amount': order.totalAmountAsString(),
>> 'Currency': 'GBP',
>> 'Description': 'BC Order ID: %s' % order.orderId,
>> 'CardHolder': clean_checkout_form['card_name'],
>> 'CardNumber': clean_checkout_form['card_number'],
>> 'ExpiryDate': 
>> clean_checkout_form['card_expiry'].strftime('%m%y'),
>> 'CV2': clean_checkout_form['card_CVV'],
>> 'CardType': clean_checkout_form['card_type'],
>> 'CustomerEMail': clean_checkout_form['email'].lower(),
>> 'BillingSurname': clean_checkout_form['lastname'],  # 20 
>> Chars
>> 'BillingFirstnames': clean_checkout_form['firstname'], # 
>> 20 Chars
>> 'BillingAddress1': 
>> clean_checkout_form['billing_address'],  # Truncate to 100 Chars
>> 'BillingCity': clean_checkout_form['billing_city'],  # 
>> Truncate to 40 Chars
>> 'BillingPostCode': 
>> clean_checkout_form['billing_postcode'],  # Truncate to 10 Chars
>> 'BillingCountry': clean_checkout_form['billing_country'], 
>>  # 2 letter country code
>> 'DeliverySurname':  clean_checkout_form['lastname'],  # 
>> 20 Chars
>> 'DeliveryFirstnames': clean_checkout_form['firstname'], 
>>  # 20 Chars
>> 'DeliveryAddress1': 
>>  clean_checkout_form['shipping_address'],  # 100 Chars
>> 'DeliveryCity': clean_checkout_form['shipping_city'], # 
>> 40 Chars
>> 'DeliveryPostCode': 
>> clean_checkout_form['shipping_postcode'],  # 10 Chars
>> 'DeliveryCountry': 
>> clean_checkout_form['shipping_country'],  # 2 letter country code
>> 'CreateToken': 1
>> }
>>
>> Your field names will be different.
>>
>> Encode it:
>>
>>
>>
>> On 10 April 2013 02:27, sparky > wrote:
>>
>>> I want to use 
>>> django-sagepay<https://github.com/timetric/django-sagepay/tree/master/django_sagepay>.
>>>  
>>> However, it doesn't  seem to have any examples or test.py that I can learn 
>>> from. being a newbie I need docs! 
>>>
>>> Does anyone know of any examples of use? I'm very familiar with sagepay, 
>>> just need to know how to implement this application into my app.
>>>
>>> For example, any app I can look at that makes use of this 
>>> django-sagepay<https://github.com/timetric/django-sagepay/tree/master/django_sagepay>
>>> ?
>>>
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@google

How many workers do you run on one machine using django celery?

2013-04-20 Thread sparky
Quick question, just so I can compare, I would really like to hear other 
devs experience. 

*How many workers do you run on one machine using django celery?*

I'm running 3 workers on an EC2 small instance. It takes around 5 seconds 
to complete 1 task running all 3 workers, does this sound right to you?

My issue is I could have 100,000 tasks very soon... scale wise I'm unsure 
what I'm going to need to do this. Bigger CPU, RAM and X workers, 5 seconds 
is far too long for me. All the task is doing is sending a SMS message HTTP 
thats it.

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




Re: IDE to practice django template language

2013-04-20 Thread sparky
I second PyCharm, I'm new to Django too it works well for me :)

On Friday, April 19, 2013 2:03:19 AM UTC+1, Srinivasa Rao wrote:
>
> Hi, I am new to this djnago, can you suggest any 
> development environment to practice template language. thanks,Srini

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




Re: How many workers do you run on one machine using django celery?

2013-04-21 Thread sparky
Thanks for the responses it's very helpful.

You are right, I won't have 100,000 tasks every seconds it's just a huge 
batch I have to send which at the moment would be 100,000 tasks.

But just to be clear:

Loop each contact in my DB:
   TASK: SEND 1 SMS FOR CONTACT

I'm use Amazon SQS for the broker. 

Each task currently takes around 5 seconds to complete, If I remove the 
task it's less that a second per SMS. meaning it would take 100+ hours to 
send all my messages, far, far to long!




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




Re: How many workers do you run on one machine using django celery?

2013-04-21 Thread sparky
One last thing to add, the task it's self does not seems to be the issue, 
'got message from broker'  is the 3-4 second wait I can see.

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




Re: How many workers do you run on one machine using django celery?

2013-04-21 Thread sparky
Maybe SQS is the issue here have a read: 
http://dataexcursions.wordpress.com/2011/12/15/amazon-sqs-vs-rabbitmq/

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




Re: How many workers do you run on one machine using django celery?

2013-04-21 Thread sparky
wow, some good advice here thanks. I tested with RabbitMQ and its fast, all 
I can say is it seems to be SQS. My advice don't use it!

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




I have searched and searched for a CSV Importer that does the following.

2013-04-22 Thread sparky
I have searched and searched for a CSV Importer that does the following...
*
Imports a CSV
Allows users to then select the header that corresponds to the model.*

But, honest nothing exists I can find, anyone know of any app out there in 
Django that does this I could have missed?

As close as I have gotten is with 
http://django-csv-importer.readthedocs.org/en/latest/ but this has one big 
draw back, the user has to know what the fields they need  to start with 
and cannot config after upload.

Thanks   

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




Django Python Understanding Classes with an example

2013-04-22 Thread sparky
I'm just learning Python and Django.

**Could someone tell me where I'm going wrong with below?** 

What I want to do is something like this

csvobject = CSVViewer(file)
rows = csvobject.get_row_count()


This is what I have so far. Remember this is all new to me so I'm looking 
for a an explanation. Thanks. 

class CSVViewer:


def __init__(self, file=None):
self.file = file

def read_file(self):
data = []
file_read = csv.reader(self.file)
for row in file_read:
data.append(row)
return data


def get_row_count(self):

 
return len(read_file(self))


Any experts or pointer or reading is welcome. Thanks again

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




Django confusing issues DRIVING ME MAD. Please someone help?

2013-06-14 Thread sparky
Hi, I'm wondering if anyone can help me with the following issues it's 
really confusing me *(and others who have tried to help)*

The question is here: 
http://stackoverflow.com/questions/17113479/django-get-absolute-url-empty-in-production

*But the summery is. *

I'm using {{ item.get_absolute_url }} in a template. Within development the 
rendered HTML looks like this:

*http://127.0.0.1:8002/contacts/group/edit/36/*  - correct!

On live production it's empty:

*http://domain.com/*  - empty!

Meaning I get a 'NoneType' error on ayhting that uses 
self.get_absolute_url() function (only on production)  the code is 100% the 
same on both machines I promise. Both on Django 1.5.1 and it 100% works in 
dev (runserver) but on on Apache. 

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




Re: Django confusing issues DRIVING ME MAD. Please someone help?

2013-06-14 Thread sparky
Hi Nikolas,


 - Guessing from the stack trace you provided, either "reverse" or "str" 
are None (since those are the only two function calls on that line).

yes that will be the issue, but why is it none in production and works (has 
a value) in django server?

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




Re: Django confusing issues DRIVING ME MAD. Please someone help?

2013-06-14 Thread sparky
Ok I have no idea whats happening, I took your advice and added the code 
below. then on production get_absolute_url starting working. I took it out 
and it stopped again. get_delete_url does not work either until I add in 
your debugging again WTF!

def get_absolute_url(self):
import logging
from django.core.urlresolvers import reverse
logging.debug(reverse)
logging.debug(str)
return reverse('contacts.views.group', args=[str(self.id)])

def get_delete_url(self):
return reverse('contacts.views.group_delete_confirm', 
args=[str(self.id)])

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




Re: Django confusing issues DRIVING ME MAD. Please someone help?

2013-06-14 Thread sparky
*thanks Nikolas!!!* you help me resolve the issue. no idea why it effects 
reverse but my log file show an error with some middleware and resloved 
that issue and for some reason all urls started working again!

On Friday, June 14, 2013 6:45:08 PM UTC+1, sparky wrote:
>
> Hi, I'm wondering if anyone can help me with the following issues it's 
> really confusing me *(and others who have tried to help)*
>
> The question is here: 
> http://stackoverflow.com/questions/17113479/django-get-absolute-url-empty-in-production
>
> *But the summery is. *
>
> I'm using {{ item.get_absolute_url }} in a template. Within development 
> the rendered HTML looks like this:
>
> *http://127.0.0.1:8002/contacts/group/edit/36/*  - correct!
>
> On live production it's empty:
>
> *http://domain.com/*  - empty!
>
> Meaning I get a 'NoneType' error on ayhting that uses 
> self.get_absolute_url() function (only on production)  the code is 100% the 
> same on both machines I promise. Both on Django 1.5.1 and it 100% works in 
> dev (runserver) but on on Apache. 
>

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




File Upload, form issue

2008-04-16 Thread sparky

Hello all,

I have a slightly unusual requirement: I want to use a FileField in a
form but with a TextField in the model. (The content being uploaded is
a big bit of flat text, but I want to store it in the database, not as
a file.)

The problem is that with the code that I have together the
request.FILES parameter is empty, so the form fails validation, any
suggestions as to where I'm going wrong, thanks.

sparky

the form:
class SubmissionForm(forms.Form):
title = forms.CharField(max_length=100)
description = forms.CharField(widget=forms.Textarea)
content = forms.FileField(widget=forms.FileInput)


the model:

class Submission(models.Model):
"""
Submission model
"""
creator = models.ForeignKey(User)
created_datetime  = models.DateTimeField(auto_now_add=True)
title = models.CharField(max_length=100)
description = models.TextField()
content = models.TextField()


The view code:
if request.method == 'POST':
form = SubmissionForm(request.POST, request.FILES)
if form.is_valid():
s = Submission(creator=request.user,
created_datetime=datetime.datetime.now(),
title=form.cleaned_data['title'],
description=form.cleaned_data['description'],
content=form.cleaned_data['content'])


the template:



{{ form.as_p }}




--~--~-~--~~~---~--~~
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: File Upload, form issue

2008-04-16 Thread sparky

Thank you for your help.

I'm baffled. The validation error is:

contentThis field
is required.

which is fair enough... but it is in the form and I've selected a
file, clicked open, and clicked submit...


I'm probably doing something mind-meltingly stupid.

hmmm.

Glad the rest of it seems ok, though.

On Apr 16, 1:41 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Apr 16, 2008 at 6:55 AM, sparky <[EMAIL PROTECTED]> wrote:
>
> > Hello all,
>
> > I have a slightly unusual requirement: I want to use a FileField in a
> > form but with a TextField in the model. (The content being uploaded is
> > a big bit of flat text, but I want to store it in the database, not as
> > a file.)
>
> > The problem is that with the code that I have together the
> > request.FILES parameter is empty, so the form fails validation, any
> > suggestions as to where I'm going wrong, thanks.
>
> I do not see any reason why what you have posted below would fail form
> validation.  request.FILES will be populated, assuming you actually choose a
> file before you click "Submit".  Are you really seeing a problem with form
> validation failing?  If so, what exactly is the validation error message ?
> "This field is required." or "The submitted file is empty" or ...?
>
> The problem I do see in your code below is that you do not put the content
> of the uploaded file in your model as you state you want to.  When your form
> is validated, cleaned_data['content'] will be an UploadedFile.  If you want
> to access the content of the UploadedFile, you need to use
> cleaned_data['content'].content.  As you have coded it below I believe you
> will get the name of your uploaded file put into your model's content field.
>
> Karen
>
> > sparky
>
> > the form:
> > class SubmissionForm(forms.Form):
> >title = forms.CharField(max_length=100)
> >description = forms.CharField(widget=forms.Textarea)
> >content = forms.FileField(widget=forms.FileInput)
>
> > the model:
>
> > class Submission(models.Model):
> >"""
> >Submission model
> >"""
> >creator = models.ForeignKey(User)
> >created_datetime  = models.DateTimeField(auto_now_add=True)
> >title = models.CharField(max_length=100)
> >description = models.TextField()
> >content = models.TextField()
>
> > The view code:
> >if request.method == 'POST':
> >form = SubmissionForm(request.POST, request.FILES)
> >if form.is_valid():
> >s = Submission(creator=request.user,
> >created_datetime=datetime.datetime.now(),
> >title=form.cleaned_data['title'],
> >description=form.cleaned_data['description'],
> >content=form.cleaned_data['content'])
>
> > the template:
>
> >
> >
> >{{ form.as_p }}
> >
> >
> >
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Formwizard Initial Data

2008-04-21 Thread sparky

Hello All,

I am writing an app that includes Messaging and I would like to give
users the ability to attach other system objects to the messages that
they send. The FormWizard stuff is fabulous, but I would like to limit
a queryset used in one of the forms here are my Mail forms:

class MailFormP1(forms.Form):
subject = forms.CharField(max_length=100)
recipient = forms.ModelChoiceField(queryset=User.objects.all())
body = forms.CharField(widget=forms.Textarea)
draft = forms.BooleanField()

class MailFormP2(forms.Form):
attachments =
forms.ModelMultipleChoiceField(queryset=Submission.objects.all())

how can I make the queryset use Submission.objects.filter rather than
objects.all ?

Any suggestions?

thanks,

mjj


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



Initial Querysets forms, validation

2008-05-01 Thread sparky

Hello All,

I have an app that implements messaging between users, and I want to
offer the ability to attach objects to messages. I also want the
message recipients to be restricted (it is a ModelChoice Field, and
should exclude the current user, rather than be Users.objects.all()).

I can get the initial data restricted as I want it:
form.py:

class MailFormP3(forms.Form):
subject = forms.CharField(max_length=100)
recipient = forms.ModelChoiceField(queryset=User.objects.none())
body = forms.CharField(widget=forms.Textarea)
draft = forms.BooleanField()
attachments =
forms.ModelMultipleChoiceField(queryset=Slushpile.objects.none())

def __init__(self, query=None, *args, **kwargs):
super(MailFormP3, self).__init__(*args, **kwargs)
if query is not None:
self.fields['recipient'].queryset = query['recipient']
self.fields['attachments'].queryset = query['attachments']

view.py

on request.GET

recipient_list =
User.objects.exclude(id__exact=request.user.id)
attachment_list =
Slushpile.objects.filter(creator__exact=request.user)
form = MailFormP3(query={'recipient':recipient_list,
'attachments':attachment_list})

so far so good.

However, when the request.POST processing is happening, the form is
not valid (the ModelChoice Fields are apparently missing) and so no
database save is done.

form = MailFormP3(request.POST)
if form.is_valid():
form.save()

Any suggestions would be very welcome indeed.

PS I am not doing it with a ModelForm because I cannot get the
filtered querysets to work when I use ModelForm, but can when I use
Forms.form

Thanks

mjj

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



PIL 1.1.6, jpeg decoder error, going insane...

2008-06-25 Thread sparky

Hello all.

I am writing a site that has profile functionality which uses the
sorl.thumbnail app. When I try to view a single user profile the image
(a jpeg using sorl.thumbnail) works, beautifully.

However, when I try to view all user profiles I get the following
error:

IOError at /profile/all/
decoder jpeg not available
Request Method: GET
Request URL:http://www.theslushpile.com/profile/all/
Exception Type: IOError
Exception Value:decoder jpeg not available
Exception Location: /usr/lib/python2.3/site-packages/PIL/Image.py in
_getdecoder, line 375
Python Executable:  /usr/bin/python
Python Version: 2.3.4
Python Path:['', '/home/default/theslushpile.com/user/htdocs', '/usr/
lib/python2.3/site-packages/django', '/usr/lib/python2.3/site-packages/
MySQL_python-1.2.2-py2.3-linux-i686.egg', '/usr/lib/python2.3/site-
packages/setuptools-0.6c8-py2.3.egg', '/usr/lib/python2.3/site-
packages/pysqlite-2.4.1-py2.3-linux-i686.egg', '/usr/lib/
python23.zip', '/usr/lib/python2.3', '/usr/lib/python2.3/plat-linux2',
'/usr/lib/python2.3/lib-tk', '/usr/lib/python2.3/lib-dynload', '/usr/
lib/python2.3/site-packages', '/usr/lib/python2.3/site-packages/PIL']

Bizarrely, if I run selftest.py from PIL, I get:

Failure in example: _info(Image.open("Images/lena.jpg"))
from line #24 of selftest.testimage
Exception raised:
Traceback (most recent call last):
  File "./doctest.py", line 499, in _run_examples_inner
exec compile(source, "", "single") in globs
  File "", line 1, in ?
  File "./selftest.py", line 22, in _info
im.load()
  File "PIL/ImageFile.py", line 180, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
  File "PIL/Image.py", line 375, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available
1 items had failures:
   1 of  57 in selftest.testimage
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.

So how is it working for the single jpeg image? I believe that the
jpeg library is present, (in /usr/local/lib , libjpeg.a -  the single
jpeg test works...)although I am unsure how to force PIL setup.py to
pick it up and use it.

Any help much appreciated. I am going insane.

mjj


--~--~-~--~~~---~--~~
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: PIL 1.1.6, jpeg decoder error, going insane...

2008-06-26 Thread sparky

Evert,

Thank you for your help, I REALLY appreciate anyone giving me their
time, like this. I have fixed it. The issue was to do with the library
path and the way that Linux (Fedora Core 3) runs and is
configured.I've been running a Linux dedicated server for a while but
had no previous experience of Linux - quite a learning curve.

PIL was not finding the libjpeg in /usr/local/lib, so I added it to /
etc/ld.so.conf (a common Fedora gotcha apparently), ran ldconfig (to
rebuild the library cache), re-ran PIL setup.py, and Bob's yer uncle!

I had tried the JPEG_ROOT thing before, but obviously not got it
right.

Thanks again.

If you ever get to DJUGL (Django Users, London), I'll buy you a beer!

mjj
--~--~-~--~~~---~--~~
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: newforms: MultiValueField and MultiWidget

2007-04-19 Thread sparky



On Feb 19, 10:18 pm, "Justin Findlay" <[EMAIL PROTECTED]> wrote:
> On Jan 25, 1:16 pm, "canen" <[EMAIL PROTECTED]> wrote:
>
> > Answering my own question:
> Thanks for the example!

I created another, but it uses initial data, and an object
representing the info.

class Postal(object):
def __init__(self, line1='', line2='', line3='', code=''):
self.line1 = line1
self.line2 = line2
self.line3 = line3
self.code = code

class PostalWidget(django.newforms.widgets.MultiWidget):
def __init__(self, attrs=None):
widgets = (django.newforms.widgets.TextInput(),
django.newforms.widgets.TextInput(),
django.newforms.widgets.TextInput(),
django.newforms.widgets.TextInput())

super(PostalWidget, self).__init__(widgets, attrs=attrs)

def decompress(self, value):
if value:
return [value.line1, value.line2, value.line3, value.code]
return [None, None, None, None]


class PostalField(django.newforms.fields.MultiValueField):
widget = PostalWidget
def __init__(self, required=True, widget=None, label=None,
initial=None):
fields = (django.newforms.fields.CharField(),
django.newforms.fields.CharField(),
django.newforms.fields.CharField(),
django.newforms.fields.CharField())
super(PostalField, self).__init__(fields=fields,
widget=widget, label=label, initial=initial)

def compress(self, data_list):
if data_list:
return Postal(data_list[0], data_list[1], data_list[2],
data_list[3])
return None



class EnrolmentForm(django.newforms.Form):
name = django.newforms.fields.CharField(label='Name')
surname = django.newforms.fields.CharField(label='Surname')
postalField = PostalField()

data= {'name':'piet', 'surname':'plesier', 'postalField_0' : 'cs',
'postalField_1' : 'pretoria', 'postalField_2' :
'Hatfield' ,'postalField_3' : '0084'}
#initial= {'name':'piet', 'surname':'plesier', 'postalField' :
Postal(line1='pompies')}
initial= {'name':'piet', 'surname':'plesier'}

f = EnrolmentForm(initial=initial)
print f.as_p()
f = EnrolmentForm(data=data)
print f.is_valid()
print f.errors
print f.clean_data
> > The widget can be declared as part of the field, e.g.
>
> > # Field
> > class MoneyField(MultiValueField):
> > def __init__(self, currency=(), amount=(), required=True,
> > widget=None, label=None, initial=None):
> > widget  = widget or MoneyWidget(currency=currency,
> > amount=amount)
> > .
>
> Canen, do you have the time to work out a full example?  After much
> trying I'm still not able to repeat the example without having to use
> the double tuple values.
>
> Justin


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