Re: Image Field Issue

2011-10-23 Thread Swaroop Shankar V
Thanks Kurtis, I figured out that was the issue. I downloaded a copy of PIL
from their official site. Installed the devel libraries for libjpeg and then
did a setup.py install and now its fixed :)

Regards,
Swaroop Shankar V



On Mon, Oct 24, 2011 at 11:32 AM, Kurtis Mullins
wrote:

> Django relies on Python Imagine Library to check if an image is valid or
> not. Make sure that PIL was compiled w/ the libjpeg. I'm not sure on exact
> directions on how to do that, but you can find them available online. When
> you compile PIL, it will tell you what extensions are supported or missing
> due to dependencies. Good luck!
>
> On Mon, Oct 24, 2011 at 1:33 AM, Swaroop Shankar V wrote:
>
>> Hello All,
>> An update to my previous question. The error occurs only if I try to
>> upload jpeg images, other formats like gif, png do not have this issue.
>> Please let me know if there is any extension that i need to install to
>> support jpeg. Please note that mine is a linux machine (Opensuse 11.3).
>> Thanks
>>
>> Regards,
>>
>> Swaroop Shankar V
>>
>>
>>
>>
>> On Mon, Oct 24, 2011 at 7:07 AM, Swaroop Shankar V 
>> wrote:
>>
>>> Hello All,
>>>
>>> I am having a trough time with the Image Field. I am trying to upload an
>>> image and even if i upload a valid image, the form validator throws an error
>>> "Upload a valid image. The file you uploaded was either not an image or a
>>> corrupted image.". I have verified that PIL is installed in my system, even
>>> then its showing this validation error. I have not done any processing as
>>> such. In my models.py i have the following statement:
>>> avatar =
>>> models.ImageField(_('Avatar'),upload_to=settings.IMAGE_UPLOAD_PATH,
>>> null=True)
>>>
>>> where IMAGE_UPLOAD_PATH is set to 'uploads/images' which i guess should
>>> be in my MEDIA_URL. Then in my forms.py i have the following statment:
>>> avatar = forms.ImageField(label=_('Avatar'))
>>>
>>> I am not sure if i have done something wrong. Please guide me. Thanks
>>>
>>> Regards,
>>>
>>> Swaroop Shankar V
>>>
>>>
>>  --
>> 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.
>

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



Re: Image Field Issue

2011-10-23 Thread Kurtis Mullins
Django relies on Python Imagine Library to check if an image is valid or
not. Make sure that PIL was compiled w/ the libjpeg. I'm not sure on exact
directions on how to do that, but you can find them available online. When
you compile PIL, it will tell you what extensions are supported or missing
due to dependencies. Good luck!

On Mon, Oct 24, 2011 at 1:33 AM, Swaroop Shankar V wrote:

> Hello All,
> An update to my previous question. The error occurs only if I try to upload
> jpeg images, other formats like gif, png do not have this issue. Please let
> me know if there is any extension that i need to install to support jpeg.
> Please note that mine is a linux machine (Opensuse 11.3). Thanks
>
> Regards,
>
> Swaroop Shankar V
>
>
>
>
> On Mon, Oct 24, 2011 at 7:07 AM, Swaroop Shankar V wrote:
>
>> Hello All,
>>
>> I am having a trough time with the Image Field. I am trying to upload an
>> image and even if i upload a valid image, the form validator throws an error
>> "Upload a valid image. The file you uploaded was either not an image or a
>> corrupted image.". I have verified that PIL is installed in my system, even
>> then its showing this validation error. I have not done any processing as
>> such. In my models.py i have the following statement:
>> avatar =
>> models.ImageField(_('Avatar'),upload_to=settings.IMAGE_UPLOAD_PATH,
>> null=True)
>>
>> where IMAGE_UPLOAD_PATH is set to 'uploads/images' which i guess should be
>> in my MEDIA_URL. Then in my forms.py i have the following statment:
>> avatar = forms.ImageField(label=_('Avatar'))
>>
>> I am not sure if i have done something wrong. Please guide me. Thanks
>>
>> Regards,
>>
>> Swaroop Shankar V
>>
>>
>  --
> 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.



Re: Image Field Issue

2011-10-23 Thread Swaroop Shankar V
Hello All,
An update to my previous question. The error occurs only if I try to upload
jpeg images, other formats like gif, png do not have this issue. Please let
me know if there is any extension that i need to install to support jpeg.
Please note that mine is a linux machine (Opensuse 11.3). Thanks

Regards,

Swaroop Shankar V



On Mon, Oct 24, 2011 at 7:07 AM, Swaroop Shankar V wrote:

> Hello All,
>
> I am having a trough time with the Image Field. I am trying to upload an
> image and even if i upload a valid image, the form validator throws an error
> "Upload a valid image. The file you uploaded was either not an image or a
> corrupted image.". I have verified that PIL is installed in my system, even
> then its showing this validation error. I have not done any processing as
> such. In my models.py i have the following statement:
> avatar =
> models.ImageField(_('Avatar'),upload_to=settings.IMAGE_UPLOAD_PATH,
> null=True)
>
> where IMAGE_UPLOAD_PATH is set to 'uploads/images' which i guess should be
> in my MEDIA_URL. Then in my forms.py i have the following statment:
> avatar = forms.ImageField(label=_('Avatar'))
>
> I am not sure if i have done something wrong. Please guide me. Thanks
>
> Regards,
>
> Swaroop Shankar V
>
>

-- 
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: how to reference to the model itself?

2011-10-23 Thread Mike Dewhirst

On 24/10/2011 4:00pm, Mike Dewhirst wrote:

On 24/10/2011 3:47pm, Ken wrote:

I want to create a parent-child like catalog system.

from django.db import models

class Catalog(models.Model):
username = models.EmailField()
name = models.CharField(max_length=64)
color = models.CharField(max_length=20)
state = models.IntegerField()
parentcatalog = models.ManyToOneRel(Catalog)

but when syncdb i got:
File "/home/ken/sites/mysite/catalog/models.py", line 12, in Catalog
parentcatalog = models.ManyToOneRel(Catalog)
NameError: name 'Catalog' is not defined

It seems like I cannot ref to a model which is not completely defined.
What should I do?


... and once you get past that you will likely find there isn't a 
models.ManyToOneRel class. You imported models from django so that is 
where python will look for that class. You don't need to refer to your 
own models.py namespace in front of your (incompletely defined) 
ManyToOneRel() class.


I think you are looking for a models.ForeignKey('self') relationship.

https://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey




With any luck you should be able to put Catalog in quotes so it is a
string rather than an undefined object.



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



Re: model: how to reference to the model itself?

2011-10-23 Thread Mike Dewhirst

On 24/10/2011 3:47pm, Ken wrote:

I want to create a parent-child like catalog system.

from django.db import models

class Catalog(models.Model):
 username = models.EmailField()
 name = models.CharField(max_length=64)
 color = models.CharField(max_length=20)
 state = models.IntegerField()
 parentcatalog = models.ManyToOneRel(Catalog)

but when syncdb i got:
   File "/home/ken/sites/mysite/catalog/models.py", line 12, in Catalog
 parentcatalog = models.ManyToOneRel(Catalog)
NameError: name 'Catalog' is not defined

It seems like I cannot ref to a model which is not completely defined.
What should I do?


With any luck you should be able to put Catalog in quotes so it is a 
string rather than an undefined object.




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



Re: model: how to reference to the model itself?

2011-10-23 Thread Ken
oh, I found the answer:

use ForeignKey('self') to a many-to-one ref to model self

please ignore my former post. >_<

On 10月24日, 下午12时47分, Ken  wrote:
> I want to create a parent-child like catalog system.
>
> from django.db import models
>
> class Catalog(models.Model):
> username = models.EmailField()
> name = models.CharField(max_length=64)
> color = models.CharField(max_length=20)
> state = models.IntegerField()
> parentcatalog = models.ManyToOneRel(Catalog)
>
> but when syncdb i got:
>   File "/home/ken/sites/mysite/catalog/models.py", line 12, in Catalog
> parentcatalog = models.ManyToOneRel(Catalog)
> NameError: name 'Catalog' is not defined
>
> It seems like I cannot ref to a model which is not completely defined.
> What should I do?

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



model: how to reference to the model itself?

2011-10-23 Thread Ken
I want to create a parent-child like catalog system.

from django.db import models

class Catalog(models.Model):
username = models.EmailField()
name = models.CharField(max_length=64)
color = models.CharField(max_length=20)
state = models.IntegerField()
parentcatalog = models.ManyToOneRel(Catalog)

but when syncdb i got:
  File "/home/ken/sites/mysite/catalog/models.py", line 12, in Catalog
parentcatalog = models.ManyToOneRel(Catalog)
NameError: name 'Catalog' is not defined

It seems like I cannot ref to a model which is not completely defined.
What should I do?

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



Image Field Issue

2011-10-23 Thread Swaroop Shankar V
Hello All,

I am having a trough time with the Image Field. I am trying to upload an
image and even if i upload a valid image, the form validator throws an error
"Upload a valid image. The file you uploaded was either not an image or a
corrupted image.". I have verified that PIL is installed in my system, even
then its showing this validation error. I have not done any processing as
such. In my models.py i have the following statement:
avatar = models.ImageField(_('Avatar'),upload_to=settings.IMAGE_UPLOAD_PATH,
null=True)

where IMAGE_UPLOAD_PATH is set to 'uploads/images' which i guess should be
in my MEDIA_URL. Then in my forms.py i have the following statment:
avatar = forms.ImageField(label=_('Avatar'))

I am not sure if i have done something wrong. Please guide me. Thanks

Regards,

Swaroop Shankar V

-- 
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: custom queryset with calculated field

2011-10-23 Thread dr.phil
Somehow I have itworking without any custom managers or querysets.
The last issue was fixed by importing simplejson instead of json.

Thanks for all the help

On Oct 23, 5:05 pm, "dr.phil"  wrote:
> I narrowed down the error. Strang thing is this works in a shell but
> not in my app.
>
> import datetime
> from django.utils import simplejson as json
> from django.core.serializers.json import DjangoJSONEncoder
>
> queryset = {"sColums" : "time", "aaDAta" : "[(datetime.datetime(2011,
> 10, 19, 17, 18, 2))]"}
> json.dumps(queryset, cls = DjangoJSONEcoder)
>
> ? This last statement fails in the app but not in a shell ?
>
> On Oct 23, 10:03 am, Casey Greene  wrote:
>
>
>
>
>
>
>
> > What is the error that that function gives you?  It may be possible to
> > just fix that function.
>
> > Casey
>
> > On 10/23/2011 07:42 AM, dr.phil wrote:
>
> > > The reason for this exercise is to produce suitable output for the
> > > jquery plugin datatables.  I am trying to use the following code
> > >http://rus.hk/django-data-parser-for-jquery-datatable/
>
> > > There are no problems until I include a datetime field. Then
> > > 'datatabilize' fails because it cannot jsonify a datetime object.
>
> > > Probably the easiest solution is to avoid this generic utility
> > > function and build my own?
>
> > > On Oct 22, 11:15 pm, Pedro Vasconcelos  wrote:
> > >> If you post the relevant part of your code inhttp://dpaste.com/willbe
> > >> more easy to help you!
>
> > >> On Saturday, October 22, 2011, dr.phil  wrote:
> > >>> Thank you for the response. I added a function to the model to convert
> > >>> a datetime field into the needed format (def convert_time). Then I set
> > >>> new_time = property(convert_time). If I iterate over the queryset I
> > >>> can access each.new_time BUT I need the value in the queryset
> > >>> (Model.objects.filter().values('new_time')). Unfortunately Iget an
> > >>> attribute error.
>
> > >>> Thank you.
>
> > >>> On Oct 22, 2:10 pm, Pedro Vasconcelos  wrote:
> >  Hello,
>
> >  A possible solution is create a specific method in your model class to 
> >  do
> >  this calculation. Take a look at:
>
> > >>https://docs.djangoproject.com/en/1.3/topics/db/models/#model-methods
>
> >  If you only want to do this calculations to show it in templates you 
> >  may
> >  consider creating a specific template custom tag/filters.
>
> >  Regards,
>
> >  On Sat, Oct 22, 2011 at 1:31 AM, dr.phil  wrote:
> > > Is this possible? I have a model that includes a datetime field.  When
> > > creating a queryset of this model, I want to include a calculated
> > > field of the time difference (in hours:minutes compared to
> > > datetime.now).
>
> > > Currently, when creating a queryset the datetime is included. I can
> > > iterate through the queryset to calculate the time difference and
> > > replace the value. HOWEVER, when I act on this queryset, the original
> > > (with datetime oject) is used, not the new dictionary I created.
>
> > > Help is apppreciated.
>
> > > --
> > > 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.
>
> >  --
> >  Pedro Vasconcelos858767.1843
> >  ptronico (skype)
>
> > >>> --
> > >>> 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.
>
> > >> --
> > >> Pedro Vasconcelos858767.1843
> > >> ptronico (skype)

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



How do I set an instance? (Model -> ModelForm -> FormView)

2011-10-23 Thread Kurtis
Hey,

I have a Model, a ModelForm (that does other custom stuff aside from
just editing the Model) and a FormView. Everything works great for
creating the Model and running my custom logic to do other things.

I'm trying to create an Edit/Update View now. I tried looking at
UpdateView as mentioned in IRC. I'm not sure on how to use it for my
purposes, though. I'd be happy just creating another FormView but I
don't know how to set the Instance for my Model. I'm calling my view
from urls.py in this format:

MyProfileUpdateView.as_view(template_name = 'my_template.html')

I tried to send the as_view the instance from urls.py but I have no
access to the request object in urls.py and need the current User
instance to grab the correct Model instance.

Any suggestions?

-- 
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 for large-scale e-commerce: A good or bad choice?

2011-10-23 Thread Russell Keith-Magee
On Sun, Oct 23, 2011 at 6:45 PM, Alec Taylor  wrote:
> Good afternoon,
>
> I'm looking at all the notable CMSs and web-frameworks across any
> language (C++, Ruby, Python, Perl, .NET, PHP), for an e-commerce
> solution which suits my project.
>
> Basically I'm creating an e-commerce store of e-commerce stores. So
> for all e-commerce stores integrated with this system, there is a
> shared user database and shopping cart integrated with PayPal (but
> preferably multiple payment gateways).
>
> Would DJango be a good choice for developing this project?

If you're building a user-facing, database backed website, Django
should meet your requirements.

> i.e. are there many predone components for this kind of thing which
> can be utilised to speedup development time?

Yes, there are. If you'd like an indication of the ecosystem of apps
and plugins that are available, look at:

http://djangopackages.com/packages/p/opencomparison/

This isn't a 100% comprehensive list (i.e., it's worth doing other
searches), but it is fairly extensive.

> Also, is DJango scalable enough for a system of this sort, or should I
> pick a competitor?

The decision to use Django won't be what stops your site from scaling.
For example, Mozilla and Disqus both use Django, and their sites
handle millions of requests a day. The ability of a site to scale has
a lot more to do with database design, caching choices, and so on.
Django gives you the tools to make your site as scalable as you need.

Yours,
Russ Magee %-)

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



Viewing file-upload in django admin site. How to do it?

2011-10-23 Thread Satyajit Sarangi
This is my models.py

from django.db import models

# Create your models here.

class Question(models.Model):
question_name = models.CharField(max_length=200)
question_type = models.CharField(max_length=20)
def __unicode__(self):
return self.question_name


class PythonQuestion(models.Model):
question_no = models.ForeignKey(Question)
question_text = models.TextField(max_length=1000)
question_testcase = models.TextField(max_length=1000)
question_difflevel = models.CharField(max_length=20)
def __unicode__(self):
return self.question_name


I'm viewing the fields via django-admin site. What I want to do :-

1. Upload a text file via django admin site.
2. Read its contents.
3. Serialize it into JSON and store it in the question_testcase field.

I know how to upload a file in django but not for django-admin site.

-- 
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: Piston XML Attributes

2011-10-23 Thread Guy Nesher
Thanks

On Oct 23, 9:17 pm, Masklinn  wrote:
> On 2011-10-23, at 21:20 , Guy Nesher wrote:> Hi,
>
> > I've started playing with Piston several days ago but I'm unable to
> > create XML attributes.
> > Do I need to create a special emitter for that ?
>
> From what I can read in the XMLEmitter code, I would think so yes: Piston's 
> built-in XMLEmitter maps arbitrary resources to element trees, and does not 
> bother with attributes at all (I don't see how you could built a simple 
> generic emitter deciding whether to serialize a given dict to attributes or 
> to elements, that would at the very least require pre-checking all dicts to 
> check whether their values are all atomic, and due to the way SAX serializers 
> work it would have to be done before creating the parent node)
>
> If you want to generate attributes, you will have to create a custom emitter 
> indeed.

-- 
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: custom queryset with calculated field

2011-10-23 Thread dr.phil
I narrowed down the error. Strang thing is this works in a shell but
not in my app.

import datetime
from django.utils import simplejson as json
from django.core.serializers.json import DjangoJSONEncoder

queryset = {"sColums" : "time", "aaDAta" : "[(datetime.datetime(2011,
10, 19, 17, 18, 2))]"}
json.dumps(queryset, cls = DjangoJSONEcoder)

? This last statement fails in the app but not in a shell ?

On Oct 23, 10:03 am, Casey Greene  wrote:
> What is the error that that function gives you?  It may be possible to
> just fix that function.
>
> Casey
>
> On 10/23/2011 07:42 AM, dr.phil wrote:
>
>
>
>
>
>
>
> > The reason for this exercise is to produce suitable output for the
> > jquery plugin datatables.  I am trying to use the following code
> >http://rus.hk/django-data-parser-for-jquery-datatable/
>
> > There are no problems until I include a datetime field. Then
> > 'datatabilize' fails because it cannot jsonify a datetime object.
>
> > Probably the easiest solution is to avoid this generic utility
> > function and build my own?
>
> > On Oct 22, 11:15 pm, Pedro Vasconcelos  wrote:
> >> If you post the relevant part of your code inhttp://dpaste.com/willbe
> >> more easy to help you!
>
> >> On Saturday, October 22, 2011, dr.phil  wrote:
> >>> Thank you for the response. I added a function to the model to convert
> >>> a datetime field into the needed format (def convert_time). Then I set
> >>> new_time = property(convert_time). If I iterate over the queryset I
> >>> can access each.new_time BUT I need the value in the queryset
> >>> (Model.objects.filter().values('new_time')). Unfortunately Iget an
> >>> attribute error.
>
> >>> Thank you.
>
> >>> On Oct 22, 2:10 pm, Pedro Vasconcelos  wrote:
>  Hello,
>
>  A possible solution is create a specific method in your model class to do
>  this calculation. Take a look at:
>
> >>https://docs.djangoproject.com/en/1.3/topics/db/models/#model-methods
>
>  If you only want to do this calculations to show it in templates you may
>  consider creating a specific template custom tag/filters.
>
>  Regards,
>
>  On Sat, Oct 22, 2011 at 1:31 AM, dr.phil  wrote:
> > Is this possible? I have a model that includes a datetime field.  When
> > creating a queryset of this model, I want to include a calculated
> > field of the time difference (in hours:minutes compared to
> > datetime.now).
>
> > Currently, when creating a queryset the datetime is included. I can
> > iterate through the queryset to calculate the time difference and
> > replace the value. HOWEVER, when I act on this queryset, the original
> > (with datetime oject) is used, not the new dictionary I created.
>
> > Help is apppreciated.
>
> > --
> > 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.
>
>  --
>  Pedro Vasconcelos858767.1843
>  ptronico (skype)
>
> >>> --
> >>> 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.
>
> >> --
> >> Pedro Vasconcelos858767.1843
> >> ptronico (skype)

-- 
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: Piston XML Attributes

2011-10-23 Thread Masklinn
On 2011-10-23, at 21:20 , Guy Nesher wrote:
> Hi,
> 
> I've started playing with Piston several days ago but I'm unable to
> create XML attributes.
> Do I need to create a special emitter for that ?
>From what I can read in the XMLEmitter code, I would think so yes: Piston's 
>built-in XMLEmitter maps arbitrary resources to element trees, and does not 
>bother with attributes at all (I don't see how you could built a simple 
>generic emitter deciding whether to serialize a given dict to attributes or to 
>elements, that would at the very least require pre-checking all dicts to check 
>whether their values are all atomic, and due to the way SAX serializers work 
>it would have to be done before creating the parent node)

If you want to generate attributes, you will have to create a custom emitter 
indeed.

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



Piston XML Attributes

2011-10-23 Thread Guy Nesher
Hi,

I've started playing with Piston several days ago but I'm unable to
create XML attributes.
Do I need to create a special emitter for that ?

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: Storage Backend for MediaTemple's ProCDN?

2011-10-23 Thread Mark Hughes
On 22 October 2011 22:11, Kevin  wrote:
> I have a client who is suggesting that I look into MediaTemple's
> ProCDN.  I currently only have experience with RackSpace's CloudFiles
> CDN, and only know of it and Amazon S3 for django storage support.
> Furthermore, I cannot seem to access their API pages without having a
> login, so this complicates it, as I'd like to see what sort of REST
> API I'd be looking into implementing.
>
> Has anyone had any success with managing a MediaTemple ProCDN with
> Django?  Or rather, as anybody used MediaTemple's CDN at all and what
> are their reviews over other popular CDNs such as S3 or Cloudfiles?
>

Hi,

I think that the MediaTemple's CDN is just a branded version of the
EdgeCast CDN which we use without any problems to serve static files.

http://mediatemple.net/webhosting/procdn/

As this is an 'origin pull' CDN it was far simpler to implement than
S3 or Cloudfiles as we don't need to upload any content using the API.
Just use the STATIC_URL template tag, when referencing static files
and then in the production settings.py make sure that STATIC_URL is
prefixed with the URL for the CDN.

https://docs.djangoproject.com/en/dev/howto/static-files/

Cheers,
Mark.

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



Setting default values in a form from DB table

2011-10-23 Thread Swaroop Shankar V
Hello All,

I am trying to create a Edit form to edit user information. I would like to
display the default values in the form fields rendered and am getting the
values from the db table. I can take an approach by creating a dictionary
with the values that needs to be populated in the form fields in my view
file and then pass it to the html. Then in the html, i can manually set the
values using the django-widget_tweaks. But the problem here is that there
are few select box for which this approach wont work. So the next option is
to do it from the forms.py but there i need to get the currently logged in
user and since request object is not available i created an __init__
function with the following statements

def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request', None)
super(UserEditForm, self).__init__(*args, **kwargs)

but now i am not sure on how to set up the form values. My form's class code
can be accessed via the url http://pastebin.com/1TuRmNhH . Please help.

Thanks and Regards,
Swaroop Shankar V

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



update database by phpmyadmin

2011-10-23 Thread Alfredo Alessandrini
Hi,

I'm trying to import a big database in the django project by phpmyadmin.

The import process is successful. The database by phpmyadmin and mysql
admin is ok.

If I try to make some query by python shell it work.

But the problem is that the database isn't showed in the admin panel.
(I've restart the webserver also).

And if I add a row by phpmyadmin the update is showed in the admin
panel (but I can see only the new row...)

Any idea??


thanks,

Alfredo

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



redirect problems

2011-10-23 Thread nicolas HERSOG
Hi everyone,

I'm stuck with the redirection in django.

This is my url.py

(r'^article/(?P\d+)/$', 'myapp.myappFront.views.article'),
(r'^article/(?P\d+)/addComment/$',
'myapp.myappFront.views.addComment'),

I developed a little view in order to add comment to my article, this is my
view.py

def article(request, id):
article = article.objects.get(id=id)
commentaires = Commentaire.objects.filter(article=article.id
).order_by("-dateComment")
#dateTime
date = datetime.datetime.now()

c = Context({
'article' : video,
'commentaires' : commentaires,
'now' : date,
})
form = CommentForms()
c['form'] = form
return render_to_response('myappFront/article.html', c,
context_instance=RequestContext(request))
def addComment(request, id):
article = article.objects.get(id=id)
if request.method == 'POST':
form = CommentForms(data=request.POST)
if form.is_valid():
cf_comment = form.cleaned_data['cf_comment']
cf_writer = request.user
cf_date = datetime.datetime.now()
cf_video = video
c1 = Commentaire.objects.create(comment=cf_comment,
dateComment=cf_date, writer=cf_writer, video=cf_video)
c1.save()
else:
c = Context({
'id' : id,
})
#return render_to_response('myappFront/article.html', c,
context_instance=RequestContext(request))
#return HttpResponseRedirect(reverse('myappFront.views.article',
args=(id,)))
#return HttpResponseRedirect(reverse('myappFront.views.article',
kwargs={'id': id}))
return HttpResponseRedirect(reverse('myappFront.views.article',
args=(id,)))

The view article works well, my form for add comment seems ok, i can add
comment to my article, but the problem is
the redirection at the end of the addComment method.
As u see, I tried many many syntax in order to redirect the user to the
article, but all of this test failed.
Every time i have this kind of error :

NoReverseMatch at /article/9/addComment/
Reverse for 'myAppFront.views.article' with arguments '(u'9',)' and keyword
arguments '{}' not found.

Any idea ?

Thx for all :)

-- 
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: custom queryset with calculated field

2011-10-23 Thread Casey Greene
What is the error that that function gives you?  It may be possible to 
just fix that function.


Casey

On 10/23/2011 07:42 AM, dr.phil wrote:

The reason for this exercise is to produce suitable output for the
jquery plugin datatables.  I am trying to use the following code
http://rus.hk/django-data-parser-for-jquery-datatable/

There are no problems until I include a datetime field. Then
'datatabilize' fails because it cannot jsonify a datetime object.

Probably the easiest solution is to avoid this generic utility
function and build my own?

On Oct 22, 11:15 pm, Pedro Vasconcelos  wrote:

If you post the relevant part of your code inhttp://dpaste.com/will be
more easy to help you!

On Saturday, October 22, 2011, dr.phil  wrote:

Thank you for the response. I added a function to the model to convert
a datetime field into the needed format (def convert_time). Then I set
new_time = property(convert_time). If I iterate over the queryset I
can access each.new_time BUT I need the value in the queryset
(Model.objects.filter().values('new_time')). Unfortunately Iget an
attribute error.



Thank you.



On Oct 22, 2:10 pm, Pedro Vasconcelos  wrote:

Hello,



A possible solution is create a specific method in your model class to do
this calculation. Take a look at:


https://docs.djangoproject.com/en/1.3/topics/db/models/#model-methods










If you only want to do this calculations to show it in templates you may
consider creating a specific template custom tag/filters.



Regards,



On Sat, Oct 22, 2011 at 1:31 AM, dr.phil  wrote:

Is this possible? I have a model that includes a datetime field.  When
creating a queryset of this model, I want to include a calculated
field of the time difference (in hours:minutes compared to
datetime.now).



Currently, when creating a queryset the datetime is included. I can
iterate through the queryset to calculate the time difference and
replace the value. HOWEVER, when I act on this queryset, the original
(with datetime oject) is used, not the new dictionary I created.



Help is apppreciated.



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



--
Pedro Vasconcelos858767.1843
ptronico (skype)



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



--
Pedro Vasconcelos85 8767.1843
ptronico (skype)




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



Excel Import Generic Relations

2011-10-23 Thread stephenstubbs
We have created an excel import application called cute_import at
https://bitbucket.org/darrenma/django-cuteimport which is able to
create and update records based on an excel spreadsheet. This works
well for one model currently. Currently it imports foreign keys based
on how they are matched up using a get or create and so will create
the foreign key if not found but only with the one field. We would
like to do something similar for generic relations and manytomany
fields before moving on to be able to import multiple tables at once.

I'm thinking of possibly matching the object on a field to a value but
not entirely sure how to do this.

object = generic.GenericForeignKey('content_type', 'object_id')

Can anyone shed some light on how this may be done?

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



not so Django problem. more like fastcgi problem

2011-10-23 Thread Alexandr Notchenko
I got a problem with my Django+fcgi+Nginx setup on VMware virtual
machine with “ubuntu server 11.04”

my

#urls.py

from django.conf.urls.defaults import patterns, include, url
from sitename.views import hello, my_homepage_view

urlpatterns = patterns('',
(r'^$', my_homepage_view),
(r'^hello/$', hello),
)

#views.py

from django.http import HttpResponse
import datetime

def my_homepage_view(request):
now = datetime.datetime.now()
html="It is now %s. Yep, ... This is my homepage. " % now
return HttpResponse(html)

def hello(request):
return HttpResponse("Hello World!")

---
when I run testserver

./manage.py runserver 192.168.169.155:8000

where  192.168.169.155 – is an adress of my virtual machine (when use
localhost same thing happens)

when I open  http://192.168.169.155:8000/ my “my_homepage_view” opens
and  http://192.168.169.155:8000/hello/ my “hello” page opens

but if I start fcgi

./manage.py runfcgi protocol=fcgi method=prefork daemonize=false
host=127.0.0.1 port=8881

and my nginx server configs looks like

#nginx.conf

server {
listen 80;
server_name servername;

charset utf-8;

access_log logs/access.log ;

client_max_body_size 300m;

location / {
fastcgi_pass 127.0.0.1:8881;
include fastcgi_params;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

# fastcgi_params

fastcgi_param   QUERY_STRING$query_string;
fastcgi_param   REQUEST_METHOD  $request_method;
fastcgi_param   CONTENT_TYPE$content_type;
fastcgi_param   CONTENT_LENGTH  $content_length;

fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param   SCRIPT_NAME $fastcgi_script_name;
fastcgi_param   REQUEST_URI $request_uri;
fastcgi_param   DOCUMENT_URI$document_uri;
fastcgi_param   DOCUMENT_ROOT   $document_root;
fastcgi_param   SERVER_PROTOCOL $server_protocol;

fastcgi_param   GATEWAY_INTERFACE   CGI/1.1;
fastcgi_param   SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param   REMOTE_ADDR $remote_addr;
fastcgi_param   REMOTE_PORT $remote_port;
fastcgi_param   SERVER_ADDR $server_addr;
fastcgi_param   SERVER_PORT $server_port;
fastcgi_param   SERVER_NAME $server_name;

fastcgi_param   REDIRECT_STATUS 200;
---
when I open  http://192.168.169.155/ my “my_homepage_view” opens
and  http://192.168.169.155/hello/ my “my_homepage_view” opens again.

I presume somewhere in my fcgi settings something redirects all
requests to site root
help me find it please
thank you

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



Re: How to add extra fields to User table

2011-10-23 Thread Yok Keen Hui
I think its simply easier to use AUTH profile to write a model for the
additional info that you want and add as an inline to the user admin.
Remember to unregister user in admin before registering user again under
admin.py, otherwise the inline will not show up in the user page.

On Sun, Oct 23, 2011 at 8:49 PM, Santiago Basulto <
santiago.basu...@gmail.com> wrote:

> I'm new with Django, but i've used AUTH_PROFILE_MODULE =
> 'accounts.UserProfile' and works great to me.
>
> It's really simple to work with it, becouse everywhere you have a
> auth.User you can issue a get_profile() and get your UserProfile.
>
> On Oct 23, 4:52 am, Chen Xu  wrote:
> > Hi, Every one:
> > I am trying to create a user registration form.
> > The default of User table has limited number of fields, but I want to add
> > more into it.
> > Therefore, I am wondering what is the better way to do it? Creating
> another
> > UserProfile class, and adding  "AUTH_PROFILE_MODULE =
> account.UserProfile",
> > or using Model inheritance?
> >
> > Thanks very much
> > Best regards
> >
> > --
> > ⚡ Chen Xu ⚡
>
> --
> 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.



Djano 1.4 SimpleListFilter 'selected' option issue

2011-10-23 Thread tejinderss
I have written a SimpleListFilter, here is the code: http://dpaste.com/639578/

It displays in the admin list properly, but i am having an issue, The
selected option does not get highlighted in the custom filter. Only
'All' highlights but not the custom options. Here is the screenshot to
illustrate that:

http://imgur.com/IyrYk

-- 
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 for large-scale e-commerce: A good or bad choice?

2011-10-23 Thread Carlos Leite
> I'm looking at all the notable CMSs and web-frameworks across any
> language (C++, Ruby, Python, Perl, .NET, PHP), for an e-commerce
> solution which suits my project.
Which language are most comfortable ?
Python is great, easy, elegant, and even for non hard programmers, its
easy to maintain.

> Basically I'm creating an e-commerce store of e-commerce stores. So
> for all e-commerce stores integrated with this system, there is a
> shared user database and shopping cart integrated with PayPal (but
> preferably multiple payment gateways).
> Would DJango be a good choice for developing this project?

Django is very Pythonic. I mean, Django keeps all characteristics from
the Python language.
 if you know Python, you don't have to "learn" the framework.
when you try a new web framework you always have to learn something,
but with django its not that hard !

> i.e. are there many predone components for this kind of thing which
> can be utilised to speedup development time?
A simple user register app can be made in 30 minutes in django or less.
My experience says, that the harder part of a good public application
is to build a good user interface and  look and feel (js ). MY
EXPERIENCE!
Django will not interfere on it !

Have you hear about http://www.satchmoproject.com/ ? its a complete store
may be its useful  -
http://www.packtpub.com/article/setting-up-complete-django-ecommerce-store-30-minutes
and you will find more apps here:  http://djangopackages.com/  and at
github... litle apps to improve usability to your application.
and lots of other apps to improve development speed. and a great community!

> Also, is DJango scalable enough for a system of this sort, or should I
> pick a competitor?
Django has different ways to cache , that has been improved since
version 0.96 (or earlier)
Its very possible one of those will meet your needs.
and then, look for a good  server (nginx may be a choice) , to work
with python. you have some options! :)


-
Cadu Leite

-- 
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 filter arithmetic seires in loop?

2011-10-23 Thread mitesh.patel1119


--
Sent via Nokia Email

--Original message--
From: Russell Keith-Magee 
To: 
Date: Sunday, October 23, 2011 4:06:08 PM GMT+0800
Subject: Re: How to filter arithmetic seires in loop?

On Sun, Oct 23, 2011 at 3:58 PM, Tsung-Hsien  wrote:
> Thanks your advice!
> However,using {% if forloop.counter % 4 == 1 %} shows problem that
> Exception Value:
> Could not parse the remainder: '%' from '%'
> Now, I refer 
> http://stackoverflow.com/questions/1438486/how-to-use-math-remainder-in-django-template
> and change it to {%forloop.counter|add:"-1"|divisibleby:4%}, and it
> work!

My apologies -- I had a momentary lapse of sanity. The modulus
operator won't work in an if clause; the new divisibleby solution
you've provided is correct. An alternate (and very slightly faster)
way of saying it would be:

{% if forloop.counter0|divisibleby: 4 %}

This uses a counter that starts at 0, rather than one that starts at
1, removing the need to do the "add:-1"

Yours,
Russ Magee %-)

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



Re: custom queryset with calculated field

2011-10-23 Thread dr.phil
The reason for this exercise is to produce suitable output for the
jquery plugin datatables.  I am trying to use the following code
http://rus.hk/django-data-parser-for-jquery-datatable/

There are no problems until I include a datetime field. Then
'datatabilize' fails because it cannot jsonify a datetime object.

Probably the easiest solution is to avoid this generic utility
function and build my own?

On Oct 22, 11:15 pm, Pedro Vasconcelos  wrote:
> If you post the relevant part of your code inhttp://dpaste.com/will be
> more easy to help you!
>
> On Saturday, October 22, 2011, dr.phil  wrote:
> > Thank you for the response. I added a function to the model to convert
> > a datetime field into the needed format (def convert_time). Then I set
> > new_time = property(convert_time). If I iterate over the queryset I
> > can access each.new_time BUT I need the value in the queryset
> > (Model.objects.filter().values('new_time')). Unfortunately Iget an
> > attribute error.
>
> > Thank you.
>
> > On Oct 22, 2:10 pm, Pedro Vasconcelos  wrote:
> >> Hello,
>
> >> A possible solution is create a specific method in your model class to do
> >> this calculation. Take a look at:
>
> https://docs.djangoproject.com/en/1.3/topics/db/models/#model-methods
>
>
>
>
>
>
>
>
>
> >> If you only want to do this calculations to show it in templates you may
> >> consider creating a specific template custom tag/filters.
>
> >> Regards,
>
> >> On Sat, Oct 22, 2011 at 1:31 AM, dr.phil  wrote:
> >> > Is this possible? I have a model that includes a datetime field.  When
> >> > creating a queryset of this model, I want to include a calculated
> >> > field of the time difference (in hours:minutes compared to
> >> > datetime.now).
>
> >> > Currently, when creating a queryset the datetime is included. I can
> >> > iterate through the queryset to calculate the time difference and
> >> > replace the value. HOWEVER, when I act on this queryset, the original
> >> > (with datetime oject) is used, not the new dictionary I created.
>
> >> > Help is apppreciated.
>
> >> > --
> >> > 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.
>
> >> --
> >> Pedro Vasconcelos858767.1843
> >> ptronico (skype)
>
> > --
> > 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.
>
>
>
> --
> Pedro Vasconcelos85 8767.1843
> ptronico (skype)

-- 
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: CSRF verification failed. Request aborted.

2011-10-23 Thread ch3ka
On Sat, 22 Oct 2011 20:32:02 +0100
Kayode Odeyemi  wrote:
> On Sat, Oct 22, 2011 at 9:40 PM,  wrote:
> > Drupal cannot know about the CSRF token it has to send.
> >
> > You'd need to disable the CSRF-Check for that view.
> > You can use the csrf_exempt decorator for example, found in the
> > django.views.decorators.csrf module.
> >
> Cool! Worked like a charm. I wish I could have csrf turned on for
> this though.

Well, you can always implement your own CSRF checks.
But what you're doing (POST from a drupal application to django) *is*
in fact a CSR, so you cannot use the default protection without
additional hacking.

Regards,
ch3ka

-- 
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 for large-scale e-commerce: A good or bad choice?

2011-10-23 Thread Alec Taylor
Good afternoon,

I'm looking at all the notable CMSs and web-frameworks across any
language (C++, Ruby, Python, Perl, .NET, PHP), for an e-commerce
solution which suits my project.

Basically I'm creating an e-commerce store of e-commerce stores. So
for all e-commerce stores integrated with this system, there is a
shared user database and shopping cart integrated with PayPal (but
preferably multiple payment gateways).

Would DJango be a good choice for developing this project?

i.e. are there many predone components for this kind of thing which
can be utilised to speedup development time?

Also, is DJango scalable enough for a system of this sort, or should I
pick a competitor?

Thanks for all suggestions,

Alec Taylor

-- 
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 add extra fields to User table

2011-10-23 Thread Santiago Basulto
I'm new with Django, but i've used AUTH_PROFILE_MODULE =
'accounts.UserProfile' and works great to me.

It's really simple to work with it, becouse everywhere you have a
auth.User you can issue a get_profile() and get your UserProfile.

On Oct 23, 4:52 am, Chen Xu  wrote:
> Hi, Every one:
> I am trying to create a user registration form.
> The default of User table has limited number of fields, but I want to add
> more into it.
> Therefore, I am wondering what is the better way to do it? Creating another
> UserProfile class, and adding  "AUTH_PROFILE_MODULE = account.UserProfile",
> or using Model inheritance?
>
> Thanks very much
> Best regards
>
> --
> ⚡ Chen Xu ⚡

-- 
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: Storage Backend for MediaTemple's ProCDN?

2011-10-23 Thread Kurtis Mullins
I'm glad to hear you're having better luck with Rackspace than we did!
Cumulus worked great for things like User Uploaded Media -- but when it came
to things like Static Media (specifically using django's collectstatic
feature) we had issues. Given, we could have just spent more time on the
situation but our project is under a ridiculous deadline and it was just
easier to use the S3Boto Backend.

Bandwidth is definitely a good thing to test for larger media formats. I
know that with Amazon you can specify if something is going to be Streamed
or just downloaded. I don't remember if Rackspace had any options like that.
And I've never used MT. Maybe it'd be a good idea to benchmark your
potential maximum streaming video load with large files to see which CDN can
handle the most stress during peak hours. I imagine for this type of a data
service, they'd all have similar performance. If price wasn't a problem, go
directly with Akamai, haha. Good luck to you!

On Sun, Oct 23, 2011 at 4:36 AM, Kevin  wrote:

> Thanks for your input.  I currently use Rackspace's CDN, their
> cloudfiles.  So far it works nicely with django using the cumulus
> storage backend.  Cumulus supports virtual directories in a container,
> and for the most part works.  I have not yet tried Amazon's S3, as
> currently all my services including servers are hosted on Rackspace.
> Today I was looking into the pricing of various CDNs and server
> providers, and I do like what Rackspace provides, a nice price, fast
> cloud servers, and they are adding new features all the time.
>
> I think I'd suggest using Rackspace CDN over MT CDN, as it's supported
> nicely in django, and I have current experience with it.  Although the
> app they plan on launching is movie streaming service, and that's
> where it get complicated...  I will need to judge more than just
> pricing and API, Bandwidth is also a big one, especially for the
> initial buffering of the stream.
>
> On Oct 22, 4:32 pm, Kurtis  wrote:
> > Hello,
> >
> > I never heard of MediaTemple or their CDN until I read your post. I
> > tried to look at their site for your information and it seems to be
> > hidden.
> >
> > We just went through this same thing but starting with Rackspace and
> > then moved to Amazon.
> >
> > One thing I ran across is that they (MT) use "Objects" for their CDN.
> > If this is anything like Rackspace, you may run into troubles. For
> > example, on Rackspace, you can only create Objects in a "root
> > directory" of your buckets and have to fake a file system if you want
> > multiple directories. Without performing some kind of a simulation of
> > a heirarchy within a flat-directory structure, you'll have a pretty
> > difficult time managing your files. It really depends on what you plan
> > on using the CDN for, though.
> >
> > We started with Rackspace and loved them. But, that one feature drove
> > us to try out Amazon's S3. Amazon provided the ability to store files
> > in a directory structure. And from there, publishing that "bucket" (I
> > forget what they're called on S3) to the CDN was extremely easy. The
> > main downside to Amazon's Cloudfront is the TTL Caching -- but I
> > honestly haven't tried that hard to invalidate or set lower refresh
> > times for objects in the CDN. The thing I loved about Rackspace was
> > their *excellent* support -- but with Amazon you have a huge community
> > which sort of makes up for that.
> >
> > I would suggest doing a complete evaluation of the three products.
> > Include components like pricing (hosting & CDN), development time, and
> > support. Then, present these to your boss and let him/her see why a
> > specific provider might be the best to use. Sure, MediaTemple *might*
> > be the cheapest to host (I don't know, just assuming) but if there's
> > no existing tools to use them as a storage backend, it might cost your
> > boss thousands of dollars (equivalent to years of hosting costs) to
> > have you build this thing.
> >
> > Sorry I couldn't compare MT CDN with the others but I hope that offers
> > a little help.
> >
> > On Oct 22, 5:11 pm, Kevin  wrote:
> >
> > > I have a client who is suggesting that I look into MediaTemple's
> > > ProCDN.  I currently only have experience with RackSpace's CloudFiles
> > > CDN, and only know of it and Amazon S3 for django storage support.
> > > Furthermore, I cannot seem to access their API pages without having a
> > > login, so this complicates it, as I'd like to see what sort of REST
> > > API I'd be looking into implementing.
> >
> > > Has anyone had any success with managing a MediaTemple ProCDN with
> > > Django?  Or rather, as anybody used MediaTemple's CDN at all and what
> > > are their reviews over other popular CDNs such as S3 or Cloudfiles?
> >
> > > 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 ema

Re: Storage Backend for MediaTemple's ProCDN?

2011-10-23 Thread Kevin
Thanks for your input.  I currently use Rackspace's CDN, their
cloudfiles.  So far it works nicely with django using the cumulus
storage backend.  Cumulus supports virtual directories in a container,
and for the most part works.  I have not yet tried Amazon's S3, as
currently all my services including servers are hosted on Rackspace.
Today I was looking into the pricing of various CDNs and server
providers, and I do like what Rackspace provides, a nice price, fast
cloud servers, and they are adding new features all the time.

I think I'd suggest using Rackspace CDN over MT CDN, as it's supported
nicely in django, and I have current experience with it.  Although the
app they plan on launching is movie streaming service, and that's
where it get complicated...  I will need to judge more than just
pricing and API, Bandwidth is also a big one, especially for the
initial buffering of the stream.

On Oct 22, 4:32 pm, Kurtis  wrote:
> Hello,
>
> I never heard of MediaTemple or their CDN until I read your post. I
> tried to look at their site for your information and it seems to be
> hidden.
>
> We just went through this same thing but starting with Rackspace and
> then moved to Amazon.
>
> One thing I ran across is that they (MT) use "Objects" for their CDN.
> If this is anything like Rackspace, you may run into troubles. For
> example, on Rackspace, you can only create Objects in a "root
> directory" of your buckets and have to fake a file system if you want
> multiple directories. Without performing some kind of a simulation of
> a heirarchy within a flat-directory structure, you'll have a pretty
> difficult time managing your files. It really depends on what you plan
> on using the CDN for, though.
>
> We started with Rackspace and loved them. But, that one feature drove
> us to try out Amazon's S3. Amazon provided the ability to store files
> in a directory structure. And from there, publishing that "bucket" (I
> forget what they're called on S3) to the CDN was extremely easy. The
> main downside to Amazon's Cloudfront is the TTL Caching -- but I
> honestly haven't tried that hard to invalidate or set lower refresh
> times for objects in the CDN. The thing I loved about Rackspace was
> their *excellent* support -- but with Amazon you have a huge community
> which sort of makes up for that.
>
> I would suggest doing a complete evaluation of the three products.
> Include components like pricing (hosting & CDN), development time, and
> support. Then, present these to your boss and let him/her see why a
> specific provider might be the best to use. Sure, MediaTemple *might*
> be the cheapest to host (I don't know, just assuming) but if there's
> no existing tools to use them as a storage backend, it might cost your
> boss thousands of dollars (equivalent to years of hosting costs) to
> have you build this thing.
>
> Sorry I couldn't compare MT CDN with the others but I hope that offers
> a little help.
>
> On Oct 22, 5:11 pm, Kevin  wrote:
>
> > I have a client who is suggesting that I look into MediaTemple's
> > ProCDN.  I currently only have experience with RackSpace's CloudFiles
> > CDN, and only know of it and Amazon S3 for django storage support.
> > Furthermore, I cannot seem to access their API pages without having a
> > login, so this complicates it, as I'd like to see what sort of REST
> > API I'd be looking into implementing.
>
> > Has anyone had any success with managing a MediaTemple ProCDN with
> > Django?  Or rather, as anybody used MediaTemple's CDN at all and what
> > are their reviews over other popular CDNs such as S3 or Cloudfiles?
>
> > 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: Django as a Standalone Desktop Application

2011-10-23 Thread Chandrakant Kumar

On 10/23/2011 07:02 AM, Alex Mandel wrote:

On 10/21/2011 07:35 PM, kenneth gonsalves wrote:

On Sat, 2011-10-22 at 00:02 +0200, Ivo Brodien wrote:

I think with django this is an easy tast.

This might loos like a typical Excel/VBA and maybe Word thing, but I
don’t want to use non open source software for this and since I like
Django and there it might be the feature of a online input of the data
I want to go with Django.

simpler to do it in dabo - or just wxPython

Actually it's not, since with Django you can specify table relationships
in the models and the admin is auto-generated.

Also the best part of this design is that you can turn it into a web app
at any time by simply opening a port on a machine to allow others to
connect.

Thanks,
Alex

You can use any python orm (viz. sqlalchemy) to specify table 
relationships in the models.


--
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 filter arithmetic seires in loop?

2011-10-23 Thread Russell Keith-Magee
On Sun, Oct 23, 2011 at 3:58 PM, Tsung-Hsien  wrote:
> Thanks your advice!
> However,using {% if forloop.counter % 4 == 1 %} shows problem that
> Exception Value:
> Could not parse the remainder: '%' from '%'
> Now, I refer 
> http://stackoverflow.com/questions/1438486/how-to-use-math-remainder-in-django-template
> and change it to {%forloop.counter|add:"-1"|divisibleby:4%}, and it
> work!

My apologies -- I had a momentary lapse of sanity. The modulus
operator won't work in an if clause; the new divisibleby solution
you've provided is correct. An alternate (and very slightly faster)
way of saying it would be:

{% if forloop.counter0|divisibleby: 4 %}

This uses a counter that starts at 0, rather than one that starts at
1, removing the need to do the "add:-1"

Yours,
Russ Magee %-)

-- 
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 filter arithmetic seires in loop?

2011-10-23 Thread Tsung-Hsien
Thanks your advice!
However,using {% if forloop.counter % 4 == 1 %} shows problem that
Exception Value:
Could not parse the remainder: '%' from '%'
Now, I refer 
http://stackoverflow.com/questions/1438486/how-to-use-math-remainder-in-django-template
and change it to {%forloop.counter|add:"-1"|divisibleby:4%}, and it
work!

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



How to add extra fields to User table

2011-10-23 Thread Chen Xu
Hi, Every one:
I am trying to create a user registration form.
The default of User table has limited number of fields, but I want to add
more into it.
Therefore, I am wondering what is the better way to do it? Creating another
UserProfile class, and adding  "AUTH_PROFILE_MODULE = account.UserProfile",
or using Model inheritance?

Thanks very much
Best regards


-- 
⚡ Chen Xu ⚡

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



form.is_valid() changes a ModelForm's associated instance

2011-10-23 Thread Torsten Bronger
Hallöchen!

I was bitten by this behaviour today, so I'd like to revisit an old
subject:

See
.
If I give an "instance" to a model form constructor and later on
call ".is_valid()" on that form, the given instance is changed in
place.  Is this intended behaviour?  If so, is it documented
somewhere?  And it is true that this was introduced in 1.2, and not
always the case?  (Because if so, I'd have to audit my complete
code.)

Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.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 at 
http://groups.google.com/group/django-users?hl=en.



Re: How to do string operations in Templates?

2011-10-23 Thread Russell Keith-Magee
On Sun, Oct 23, 2011 at 10:18 AM, Lee  wrote:
> New to template language. I've perused the docs but can't find how to
> do basic string operations like regex match/replace on {{ string
> variables }} within a template. Can someone please steer me to the
> right docs?

The reason you haven't found any docs on how to use regex
match/replace in Django's template language is because that sort of
thing isn't possible.

Django's template language isn't a general programming language. This
is a specific design constraint. We've gone to great lengths to make
it difficult to put business logic in a Django template, and if you're
talking about putting regular expressions in a template, it sounds
like that's what you're trying to do.

So -- what you really need to ask is "what am I trying to do with a
regular expression?" I'm going to guess that the use case is something
like cleaning up/modifying a label to meet some sort of display
requirement. If this is the case, then one way to address this would
be to use a template filter. A template filter is just a Python
function that can be used to transform a template variable into a
different form.

In a template tag module, you define something like:

@register.filter
def cleanup(value):
return re.sub(value, ...)

Then, in your template,

{% load mytagmodule %}

{{ myvariable|cleanup }}

This keeps the business logic -- how to "cleanup" the text -- separate
from the template itself. It also means that the regex code is
reusable -- you won't have to reproduce the regex every time you need
to do that particular substitution.

If you have more complex requirements, you may need to look into a
custom template tag.

For more details, see the docs on custom template filters and tags:

https://docs.djangoproject.com/en/1.3/howto/custom-template-tags/

Yours,
Russ Magee %-)

-- 
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 filter arithmetic seires in loop?

2011-10-23 Thread Russell Keith-Magee
On Sun, Oct 23, 2011 at 12:37 PM, Tsung-Hsien  wrote:
> I want to filter a loop when the number comes to 1,5,9,13,17...
> I use this but fail
> {% if forloop.counter |divisibleby range(1,100,4)%}{% endif %}
> How to fix it, thanks a lot !!

Firstly, your stated problem definition -- identifying when a loop
hits iteration 1, 5, 9, 13... -- isn't the same as what you've tried
to encode. What you've encoded is "if the number is divisible by
1,5,9,13,...". For example, 10 is divisible by 5, but isn't in the
sequence 1,5,9,13,...

Secondly, the reason this code doesn't work is that you can't use
arbitrary Python expressions in a Django template. range() isn't a
valid Django template operator -- in fact, almost nothing which
requires calling with brackets will be.

The good news is that what you're asking for is really easy to do: you
use the modulus operator.

{% if forloop.counter % 4 == 1 %}

i.e., Take get the modulus (remainder) after dividing the counter by
4; if the remainder is 1, the condition is true.

Yours,
Russ Magee %-)

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