Re: template loader is missing a character.

2011-03-12 Thread royy
error fixed.

The problem: I was using c:\documents and settings\hp_propietario
\mysite\ emplates\polls
\index.html (File does not exist)

instead of:

c:/documents and settings/hp_propietario/mysite/templates/polls
/index.html (File does not exist)

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.



template loader is missing a character.

2011-03-12 Thread royy
Hi.

I'm following the tutotial for my first Django app, in part 3 after
edit the views.py file  I'm getting the error.

I already created the polls directory with the index.html file as
indicated in the tutorial, also I've edited the setting.py to indicate
where the templates are located. When I run the server or load the
page I'm getting this error:

TemplateDoesNotExist at /polls/
polls/index.html

Django tried loading these templates, in this order:

•Using loader django.template.loaders.filesystem.Loader:
◦c:\documents and settings\hp_propietario\mysite\ emplates\polls
\index.html (File does not exist)
•Using loader django.template.loaders.app_directories.Loader:
◦c:\python27\lib\site-packages\django\contrib\admin\templates\polls
\index.html (File does not exist)

As you can see template loader is missing the letter " t "  of
templates

I've changed twice the directory in TEMPLATE_DIRS and still getting
the same error.

What can I do to fix this problem?

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: How to aggreate in html django

2011-03-12 Thread sushanth Reddy
Hi Tom,

I given try but not printing any values in html.
can you please add some more code

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



Is it safe to change the "id" field of a model from int to bigint in the DB schema?

2011-03-12 Thread Andy
I have a model that may have a lot (billions) of records. I understand
that the "id" field of a model is defined as a 32-bits int. So it may
not be big enough.

Is it safe to just ALTER the database schema to change the "id" field
from int to bigint? Would Django break? What happens when the "id"
value returned by the database is larger than 32 bits, would Django be
able to handle that?

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: Sum in html template using template tag

2011-03-12 Thread sushanth Reddy
it worked,thanks aaa ton

-- 
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: Initial save()

2011-03-12 Thread werefr0g

Hello,

I'd rather check for self.pk as you can use primary_key argument on a 
field whatever is its name.


Regards,

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



Re: Initial save()

2011-03-12 Thread rebus_
On 13 March 2011 00:40, Julian Hodgson  wrote:
> I need to set up some default values on a ManyToMany field only when a model
> is first created.
>
> How can I find out in the save() override if the object is being created for
> the first time?
>
> Do I check the table for rows which have self.id or is this not defined till
> after the save?
>
> Julian
>

It is enough to check if self.id [1] is set in save().

[1] 
http://docs.djangoproject.com/en/dev/ref/models/instances/#auto-incrementing-primary-keys

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



Initial save()

2011-03-12 Thread Julian Hodgson
I need to set up some default values on a ManyToMany field only when a model
is first created.

How can I find out in the save() override if the object is being created for
the first time?

Do I check the table for rows which have self.id or is this not defined till
after the save?

Julian

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



Re: How to use CreateView?

2011-03-12 Thread hassan


On Mar 12, 9:06 pm, Igor Ischenko  wrote:
> Hi hassan,
Hi
> try to add {% csrf_token %} somewhere inside form in your template
I have it there
and with it does nothing I mean: no error no response, just a form
reload!!!

> On 11 ÜÐà, 23:41, hassan  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I am testing django 1.3 class based generic views. I have a model like
> > this one:
>
> > class Book(models.Model):
> >     name = models.CharField(max_length=50)
> >     author = models.CharField(max_length=50)
>
> > and in views.py:
>
> > class BookUpdateView(CreateView):
> >     model = Book
> >     template_name = "create_book.html"
>
> > and in create_book.html
> > 
> > ...
> > 
> > 
>
> > But when i press the save button it form it does nothing!
> > What's wrong with me?

-- 
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: Queryset cloning is very expensive

2011-03-12 Thread Alexander Schepanovski
On 14 фев, 15:21, myx  wrote:
> Thank you for the reply. But I meant a slightly different case:
>
> Item.objects.filter(...).order_by(...).values_list('id', flat=True)[:
> 10]
>
> As you can see, there are four cloning operations. Wouldn't be
> chaining possible without cloning the queryset? The method could just
> return the original queryset. Seems like I'll have to write raw
> queries in such cases :(

My own hacky solutions is:

class QuerySetMixin(object):
def __init__(self, *args, **kwargs):
self._no_monkey.__init__(self, *args, **kwargs)
self._inplace = False

def inplace(self):
self._inplace = True
return self

def _clone(self, klass=None, setup=False, **kwargs):
if self._inplace and klass is None:
self.__dict__.update(kwargs)
return self
else:
clone = self._no_monkey._clone(self, klass, setup,
**kwargs)
clone._inplace = self._inplace
return clone

QuerySet._no_monkey.__init__ = QuerySet.__init__
QuerySet._no_monkey._clone = QuerySet._clone
QuerySet.__init__ = QuerySetMixin.__init__
QuerySet._clone = QuerySetMixin._clone
QuerySet.inplace = QuerySetMixin.inplace

Can be used as:
Item.objects.all().inplace().filter(...).order_by(...).values_list('id',
flat=True)[:
10]

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



Re: How to use CreateView?

2011-03-12 Thread Igor Ischenko
Hi hassan,

try to add {% csrf_token %} somewhere inside form in your template

On 11 мар, 23:41, hassan  wrote:
> Hi,
>
> I am testing django 1.3 class based generic views. I have a model like
> this one:
>
> class Book(models.Model):
>     name = models.CharField(max_length=50)
>     author = models.CharField(max_length=50)
>
> and in views.py:
>
> class BookUpdateView(CreateView):
>     model = Book
>     template_name = "create_book.html"
>
> and in create_book.html
> 
> ...
> 
> 
>
> But when i press the save button it form it does nothing!
> What's wrong with me?

-- 
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: Payment Gateways

2011-03-12 Thread Malcolm
I recently used FeeFighters and they have a really awesome setup to
help you compare and find merchant processors and gateways.  It's
pretty neat because the merchant processors "bid" based on your
preferences and all of their pricing is transparent and easy to
understand.

As for gateway, I am going with Authorize.net for my project.  PyPI
has an authorize package for API integration and my developer found a
django app at:
https://github.com/zen4ever/django-authorizenet

If interested in FeeFighters, please consider using my referral link.
https://feefighters.com/referral/d61fce3c6c274b38 :-)

Malcolm


On Mar 8, 6:43 pm, David Zhou  wrote:
> I use Braintree, and it's been great.
>
> -- dz
>
> On Tue, Mar 8, 2011 at 4:40 PM, CLIFFORD ILKAY
>
>  wrote:
> > On 03/08/2011 09:59 AM, Bill Freeman wrote:
>
> >> And I can't resist recommending solutions that don't require your to touch
> >> the credit card number.  If you never had it, you can't be responsible for
> >> compromising it.
>
> > That is true. Most of thepaymentprocessors have some sort of hosted form
> > solution for that. However, there are significant limitations in those
> > hosted form solutions that may make them unsuitable in some situations. For
> > instance, we ran into one such limitation recently on a project where the
> > processor apparently doesn't provide any sort of "success" or "failure"
> > notification for zero dollar transactions. Why would you want a zero dollar
> > transaction you might be wondering? Our client was running a promotion where
> > some initial period was free after which the normal recurring fees would
> > kick in. Normally, there is an initial fee and recurring fees. Upon success
> > or failure on the normal initial fee, we'd get a callback to a view function
> > from thepaymentgateway which we'd need to complete the transaction.
> > Completion of the transaction consists of listing the product and updating
> > the user's dashboard with the transaction date and the expiry date for the
> > listing. With the zero dollar transaction, we never got a callback due so we
> > could do none of those things. We had to manually list the products and
> > update the user's dashboard for the successful transactions in that
> > scenario.
>
> > To avoid creating a situation in the future where there would have to be
> > tedious and error-prone manual processing, we recommended to the client that
> > they don't offer "free initial period" promotions but instead charge some
> > nominal amount, even if it's one cent. "All listings one cent" doesn't have
> > quite the same impact as "Free listings" even though for all intents and
> > purposes, it's the same thing. We've discovered many other limitations like
> > that, small and large, that really makes the case for API-level integration,
> > in which case you'd have to go through a PCI compliance audit. By the way,
> > we've been through it multiple times. For the most part, it's perfunctory.
> > --
> > Regards,
>
> > Clifford Ilkay
> > Dinamis
> > 1419-3266 Yonge St.
> > Toronto, ON
> > Canada  M4N 3P6
>
> > 
> > +1 416-410-3326
>
> > --
> > 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: Extending admin index.html

2011-03-12 Thread Lior Sion
Thanks Thomas,

These two solutions look interesting, but they are a lot more than I
required :)

I also think that a recommendation to copy a file and override it is
wrong - it kills future compatibility, regardless of how this would
really be solved..

Let's wait a few days and if not answer is accepted, raise it at dev
list.

On Mar 12, 5:24 pm, Thomas Weholt  wrote:
> I`ve asked the same question just a few days ago with little or no
> luck. You`ll probably get somebody who recommends Grappelli 
> (http://code.google.com/p/django-grappelli/wiki/Grappelli_2) 
> and/orhttp://pypi.python.org/pypi/django-admin-toolsand they might be what
> you`re looking for, but I`ve tried them both and still want to now how
> to implement/override both the admin/index-template and the related
> view.
>
> Any information you might have related to this is very interesting.
> Please post a reply to this thread.
>
> Regards,
> Thomas
>
>
>
>
>
>
>
>
>
> On Sat, Mar 12, 2011 at 4:14 PM, Lior Sion  wrote:
> > Hi,
>
> > Is there an easy way I'm missing to EXTEND the admin site's index.html
> > without copying the file and altering it, which kinda sounds like the
> > wrong solution?
>
> > Basically, I live with the current template well enough and want to
> > get updates with new versions of django, but I would like, for
> > example, to add an upper, lower, or side sections.. would it make
> > sense to add a {% block %} in those places?
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Mvh/Best regards,
> Thomas Weholthttp://www.weholt.org

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



Re: Rendering JSON from Django Views

2011-03-12 Thread Ezequiel Marquez
El 12/03/11 13:31, yongzhen zhang escribió:
> Hi, i want to rendering JSON from Django views, here is my models:
> class Continent(models.Model):
> name = models.CharField(max_length='10',unique=True)
> code = models.CharField(max_length='5',unique=True)
> class Country(models.Model):
> name = models.CharField(max_length='10',unique=True)
> code=models.CharField(max_length='10',unique=True)
> continent=models.ForeignKey('Continent')
> ###here is my views.py###
> from django.http import Http404
> from django.shortcuts import render_to_response, get_object_or_404
> from django.utils import simplejson as json
> from models import Continent, Country
> 
> def continent_json(request, continent_code):
> continent=get_object_or_404(Continent, code=continent_code)
> if not continent:
> raise Http404("Not implemented")
> context = {"all_contries":
> Country.objects.filter(continent=continent.id)}
> data=json.dumps(context)
> return render_to_response(data, mimetype="application/json")
> 
> I want to get the result when the continent_code=eu:
> {
>   "xk": "Kosovo",
>   "ch": "Switzerland",
>   "gr": "Greece",
>   "va": "Vatican City",
>   "ee": "Estonia",
>   "is": "Iceland",
>   "al": "Albania",
>   "gg": "Guernsey",
> }
> There is some problems with my views.py file. Anybody know how to
> modify my views.py?
> 

try with this view

def continent_json(request, continent_code):
continent=get_object_or_404(Continent, code=continent_code)
if not continent:
raise Http404("Not implemented")
context = [{'code': i.code, 'continent': i.name } for i in
Country.objects.all() ]
data=simplejson.dumps(context)
return render_to_response(data, mimetype="application/json")
-- 
Ezequiel Marquez



signature.asc
Description: OpenPGP digital signature


Rendering JSON from Django Views

2011-03-12 Thread yongzhen zhang
Hi, i want to rendering JSON from Django views, here is my models:
class Continent(models.Model):
name = models.CharField(max_length='10',unique=True)
code = models.CharField(max_length='5',unique=True)
class Country(models.Model):
name = models.CharField(max_length='10',unique=True)
code=models.CharField(max_length='10',unique=True)
continent=models.ForeignKey('Continent')
###here is my views.py###
from django.http import Http404
from django.shortcuts import render_to_response, get_object_or_404
from django.utils import simplejson as json
from models import Continent, Country

def continent_json(request, continent_code):
continent=get_object_or_404(Continent, code=continent_code)
if not continent:
raise Http404("Not implemented")
context = {"all_contries":
Country.objects.filter(continent=continent.id)}
data=json.dumps(context)
return render_to_response(data, mimetype="application/json")

I want to get the result when the continent_code=eu:
{
  "xk": "Kosovo",
  "ch": "Switzerland",
  "gr": "Greece",
  "va": "Vatican City",
  "ee": "Estonia",
  "is": "Iceland",
  "al": "Albania",
  "gg": "Guernsey",
}
There is some problems with my views.py file. Anybody know how to
modify my views.py?

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



"Connecting Small Biz with the World".

2011-03-12 Thread Melisa wilson
The site is called Alamead.com, helping small business owners market
their goods/services efficiently and effectively.  We will offering
website design, logo design, face book page design for only $99.
http://alamead.com/about-us

-- 
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: Extending admin index.html

2011-03-12 Thread Thomas Weholt
I`ve asked the same question just a few days ago with little or no
luck. You`ll probably get somebody who recommends Grappelli (
http://code.google.com/p/django-grappelli/wiki/Grappelli_2 ) and/or
http://pypi.python.org/pypi/django-admin-tools and they might be what
you`re looking for, but I`ve tried them both and still want to now how
to implement/override both the admin/index-template and the related
view.

Any information you might have related to this is very interesting.
Please post a reply to this thread.

Regards,
Thomas

On Sat, Mar 12, 2011 at 4:14 PM, Lior Sion  wrote:
> Hi,
>
> Is there an easy way I'm missing to EXTEND the admin site's index.html
> without copying the file and altering it, which kinda sounds like the
> wrong solution?
>
> Basically, I live with the current template well enough and want to
> get updates with new versions of django, but I would like, for
> example, to add an upper, lower, or side sections.. would it make
> sense to add a {% block %} in those places?
>
> --
> 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.
>
>



-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

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



Extending admin index.html

2011-03-12 Thread Lior Sion
Hi,

Is there an easy way I'm missing to EXTEND the admin site's index.html
without copying the file and altering it, which kinda sounds like the
wrong solution?

Basically, I live with the current template well enough and want to
get updates with new versions of django, but I would like, for
example, to add an upper, lower, or side sections.. would it make
sense to add a {% block %} in those places?

-- 
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 limit a ManyToManyField to three choices?

2011-03-12 Thread werefr0g

Well,

MAX_CUISINES = 3

def clean(self):
# three cuisines max. allowed
if self.pk is None:
# That's the case that raise the error
# you're inserting a new Restaurant
pass
else:
# Here, you're editing an existing Restaurant
# (including its relashionship with Cuisine)
if self.cuisines.count() > MAX_CUISINES:
raise ValidationError('I said, "Choose up to three" 
cusines!')


As we're aiming to prevent, at model's level, saving a new Restaurant 
when too many related Cuisine are provided, I'm afraid that doesn't fit 
the needs... unless saving restaurant's intance, run a validation then 
delete it if it fails the validation :) I'd like to place the validation 
at 'cusines' field level. I'm not confortable placing it at the "whole" 
model's level, despite my suggestion.


I failed for the moment to find a way and I'll resume tomorrow. Maybe 
the following unsuccessful tries can help you (with a mix of admin 
interface playing and shell, both on dev server):


  * use validator on models.ManyToManyField:

  I can't even trigger a simple print('test') TT

  * use a custom field by extending models.ManyToManyField, overriding 
its isValidIDList method


  Ok, it is a blind test: I was looking for a way to access values 
from cuisines for a non saved instance of Restaurant and maybe something 
is lurking there. I'm a beginner.


  * accessing self's attributes for a non saved or retrieved instance 
of Restaurant


  # desesperately random commands (I tried more :):

  u = Restaurant()
  r = Restaurant.objects.all()[0]

  dir(u)
  # hey, a "cuisines" attribute, great!
  dir(u.cuisines)
  # TT, same error you encountered
  dir(r.cuisines)
  # fine

  u.clean_fields()
  # 'cusines' is not even mentionned in the error message
  r.clean_fields()
  # fine

  [f.verbose_name for f in r._meta.fields]
  # no cusines

  I believe that no control is enforced before saving, but if you 
try to create an new Restaurant and not provide a cuisine, the 
validation failed from the admin. How does it handle that? I'll try to 
find out. Is there a way to access data provided to 'cuisines' for an 
unsaved Restaurant?


Regards,

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



Performance of django-tagging or mptt

2011-03-12 Thread Venkatraman S
Hi,

I am trying to evaluate django-tagging or taggit for a potential project and
was wondering if
anyone has done a study on the performance of the respective libs - i mean,
performance
in terms of scaling. Also, mptt for that matter. Was wondering whether
performance of the
app would be impacted or not, when trying to fetch the counts or children in
respective cases.

-Venkat
http://blizzardzblogs.blogspot.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: Django models and inheritance

2011-03-12 Thread Mark J. Nenadov
> When you define an abstract model, you have to define the ``abstract''
> property inside its 
> Meta.http://docs.djangoproject.com/en/1.2/ref/models/options/#abstracthttp://docs.djangoproject.com/en/1.2/topics/db/models/#abstract-base-...
>
> That way your abstract class can inherit models.Model and will have no
> database table created.
>
> Michal Petrucha
>
>  signature.asc
> < 1KViewDownload

Thank you Michal for your kind and useful help!

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



Re: test cannot find assertContains

2011-03-12 Thread werefr0g

Hi,

As far I can tell from the documentation, to use Django's extended 
TestCase, you should use django.test.TestCase [1]. Using 
django.utils.unittest allows you to benefit from python 2.7 unittest2 
library, [2]


Regards,

[1] 
http://docs.djangoproject.com/en/dev/topics/testing/#django.test.TestCase

[2] http://docs.djangoproject.com/en/dev/topics/testing/#writing-unit-tests

--
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: file upload size problem

2011-03-12 Thread Karen Tracey
On Sat, Mar 12, 2011 at 12:06 AM, vamsy krishna wrote:

> I'm doing a file upload from one of my forms and writing the content
> to a temp file on the server. The problem is any file of size more
> than 250 KB is throwing the below error:
>
> Request Entity Too Large
> The requested resource
> /tera/tera_upload/
> does not allow request data with POST requests, or the amount of data
> provided in the request exceeds the capacity limit.
>
> I read through the django file uploads documentation and it says the
> default file upload size in memory is about 2.5 MB. Can anyone tell me
> what I'm overlooking? Also how do I set a maximum file size limit and
> handle it?
>

This error isn't coming from Django, it's coming from your web server which
has apparently been configured to limit request body size. How to change the
limit will depend on what server you are using. If Apache, see for example
LimitRequestBody here: http://httpd.apache.org/docs/2.0/mod/core.html

Karen
-- 
http://tracey.org/kmt/

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



Re: Can I sort a related model reference in a template?

2011-03-12 Thread Micah Carrick
Yeash. Don't know how I missed that. Thanks!

On Sat, Mar 12, 2011 at 5:27 AM, Shawn Milochik  wrote:

> You can put a sort order in the model's meta info. That way you'll always
> have a default sort.
>
> --
> 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: Can I sort a related model reference in a template?

2011-03-12 Thread Shawn Milochik
You can put a sort order in the model's meta info. That way you'll always
have a default sort.

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



Can I sort a related model reference in a template?

2011-03-12 Thread Micah Carrick
If I have a Product model which has a one-to-many relationship with
ProductImage model...

I can get the images in the template using product.productimage_set.all,
however, is there any way to sort that or will I instead have to query the
product images in the view?

-- 
*Green Tackle* - *Environmentally Friendly Fishing Tackle*
www.GreenTackle.com 

 Email: mi...@greentackle.com
 Phone: 971.270.2206
 Toll Free: 877.580.9165
 Fax: 503.946.3106

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



Weird permissions issue

2011-03-12 Thread Eric Abrahamsen
I'm using the emencia newsletter, and things are essentially fine,
except that I've run into a very strange permissions issue in the
admin
backend. I have my regular user login, and the superuser. I've given
my
regular user all permissions for all newsletter models, and yet some
of
the inter-modal relations are not showing up.

The MailingList model has a ManyToMany relationship to Contact, yet
when
I'm logged in as my regular user and look at a MailingList instance,
the
two windows for selecting Contacts from the contact list are blank.
Same
for all the relationship fields on all the models: whether ForeignKey
or
ManyToMany, none of them display the choices for creating a
relationship. I just tried using the admin javascript green "plus
sign"
to both create an instance of a related model and put it into the
list.
The creation comes off okay, and I see the new Contact (in this case)
appear in the list, but when I save the MailingList model, it tells
me:
"Select a valid choice. 594 is not one of the available choices." 594
is
the id of the Contact instance I just created.

This only happens on my production system, not my development system.
Both are running django 1.2.3, and the development version of the
emencia
newsletter. What can have gotten screwed up here? I added the
newsletter
app much later, is there a possibility this is a database-level issue?

I've dumped the data, destroyed and recreated the tables, and loaded
the data again, to no avail…

Any pointers towards further debugging would be much welcome…

Thanks,
Eric

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



Re: Google app engine django 1.2 localization

2011-03-12 Thread Nick Rosencrantz
Many thanks for the idea! I'll try the setup you're referring to.
Regards, Nick Rosencrantz

On Mar 12, 9:48 am, Jiten Singh  wrote:
> Hi Nick,
>
> While working with GAE I use django provided onhttp://allbuttonspressed.com, 
> it is django non rel i know you must
> have heard about it.
>
> I have django1.2.4 final installed in my machine ,
>
> however i use django non rel for GAE apps.. and make it part of my gae
> project by symlinking to it django customized by non rel team. the version
> in my shell (using ./manage.py shell) is 1.3.0 alpha...
>
> I haven't tried localisation files yet.. just thought may be using django
> non rel at allbuttonspressed team can solve your problem...
>
> *Best Regards,*
> *Jitendra*
> *_discover the power of opensource_*
>
> On Sat, Mar 12, 2011 at 2:55 PM, Nick Rosencrantz wrote:
>
> > Dear Group, Here's a question I try to solve, Maybe you know what's
> > the change between GAE+django 0.96 and GAE+django 1.2 with respect to
> > localization? Putting .po and .mo files in APP_NAME/conf ... used to
> > work and upgraded to django 1.2 it won't work anymore. Having upgraded
> > from django 0.96 to 1.2 the i18n translations
> > I got that are in addition to the builtin translations bugged out. I
> > started a a question here about it
>
> >http://stackoverflow.com/questions/5271687/how-to-make-django-pick-up...
> > ie How to make GAE+ django pick up my .po and .mo translations. I got
> > translations ready in .po and .mo files. How can I make django 1.2
> > display these? I can use the builtin translations and now I want to
> > enable in addition the ones I keep in [application-name]/conf/locale/
> > [Language_Code]/LC_MESSAGES'
>
> > Is there a way? It used to work with django 0.96 and after the upgrade
> > only the builtin translations work. I tried moving to APP_DIR/locale/
> > LANG_CODE/LC_MESSAGES/django.po and it won't work for me. Maybe I
> > missed something. Do I have to recompile .po files?
>
> > Folowing the instructions from answers, I put my .po and .mo files in
>
> > APP_DIR/locale/LANG_CODE/LC_MESSAGES/django.po
>
> > It still won't work. I'm considering why and welcoming any more advice
> > or recommendation how to enable i18n features with django for google
> > app engine.
>
> > If any know-how is on this issue then kindly instruct here how to
> > proceed.
> > Regards,
> > Nick Rosencrantz
>
> > --
> > 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: Google app engine django 1.2 localization

2011-03-12 Thread Jiten Singh
Hi Nick,

While working with GAE I use django provided on
http://allbuttonspressed.com, it is django non rel i know you must
have heard about it.

I have django1.2.4 final installed in my machine ,

however i use django non rel for GAE apps.. and make it part of my gae
project by symlinking to it django customized by non rel team. the version
in my shell (using ./manage.py shell) is 1.3.0 alpha...

I haven't tried localisation files yet.. just thought may be using django
non rel at allbuttonspressed team can solve your problem...



*Best Regards,*
*Jitendra*
*_discover the power of opensource_*


On Sat, Mar 12, 2011 at 2:55 PM, Nick Rosencrantz wrote:

> Dear Group, Here's a question I try to solve, Maybe you know what's
> the change between GAE+django 0.96 and GAE+django 1.2 with respect to
> localization? Putting .po and .mo files in APP_NAME/conf ... used to
> work and upgraded to django 1.2 it won't work anymore. Having upgraded
> from django 0.96 to 1.2 the i18n translations
> I got that are in addition to the builtin translations bugged out. I
> started a a question here about it
>
> http://stackoverflow.com/questions/5271687/how-to-make-django-pick-up-my-po-and-mo-translations
> ie How to make GAE+ django pick up my .po and .mo translations. I got
> translations ready in .po and .mo files. How can I make django 1.2
> display these? I can use the builtin translations and now I want to
> enable in addition the ones I keep in [application-name]/conf/locale/
> [Language_Code]/LC_MESSAGES'
>
> Is there a way? It used to work with django 0.96 and after the upgrade
> only the builtin translations work. I tried moving to APP_DIR/locale/
> LANG_CODE/LC_MESSAGES/django.po and it won't work for me. Maybe I
> missed something. Do I have to recompile .po files?
>
> Folowing the instructions from answers, I put my .po and .mo files in
>
> APP_DIR/locale/LANG_CODE/LC_MESSAGES/django.po
>
> It still won't work. I'm considering why and welcoming any more advice
> or recommendation how to enable i18n features with django for google
> app engine.
>
> If any know-how is on this issue then kindly instruct here how to
> proceed.
> Regards,
> Nick Rosencrantz
>
> --
> 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: How to limit a ManyToManyField to three choices?

2011-03-12 Thread bagheera

Dnia 11-03-2011 o 22:45:34 greenie2600  napisał(a):


'Restaurant' instance needs to have a primary key value before a many-
to-many relationship can be used.


That is the answer You need to understand.  afiak You can't perform m2m  
validation on model level due that very reason.
That's why i did it on form level, and i think that's the only way to do  
this.  I know such things should be performed on server-side and model  
level, but i this case, is validation on form level causing any problems?


In my project i use only admin interface, so for end-user that validation  
is completely transparent.

--
Linux user

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



Google app engine django 1.2 localization

2011-03-12 Thread Nick Rosencrantz
Dear Group, Here's a question I try to solve, Maybe you know what's
the change between GAE+django 0.96 and GAE+django 1.2 with respect to
localization? Putting .po and .mo files in APP_NAME/conf ... used to
work and upgraded to django 1.2 it won't work anymore. Having upgraded
from django 0.96 to 1.2 the i18n translations
I got that are in addition to the builtin translations bugged out. I
started a a question here about it
http://stackoverflow.com/questions/5271687/how-to-make-django-pick-up-my-po-and-mo-translations
ie How to make GAE+ django pick up my .po and .mo translations. I got
translations ready in .po and .mo files. How can I make django 1.2
display these? I can use the builtin translations and now I want to
enable in addition the ones I keep in [application-name]/conf/locale/
[Language_Code]/LC_MESSAGES'

Is there a way? It used to work with django 0.96 and after the upgrade
only the builtin translations work. I tried moving to APP_DIR/locale/
LANG_CODE/LC_MESSAGES/django.po and it won't work for me. Maybe I
missed something. Do I have to recompile .po files?

Folowing the instructions from answers, I put my .po and .mo files in

APP_DIR/locale/LANG_CODE/LC_MESSAGES/django.po

It still won't work. I'm considering why and welcoming any more advice
or recommendation how to enable i18n features with django for google
app engine.

If any know-how is on this issue then kindly instruct here how to
proceed.
Regards,
Nick Rosencrantz

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



Re: request.user.save() doesnt work

2011-03-12 Thread Ndungi Kyalo
Keep in mind am using this on appengine as django-nonrel. Perhaps someone in
the nonrel project or someone with some experience with it could tell us
whether this is a known issue

On 12 March 2011 12:11, Ndungi Kyalo  wrote:

> It is a django.contrib.auth.models.User , as you say.
>
>
> On 11 March 2011 22:06, Jason Culverhouse  wrote:
>
>>
>> On Mar 11, 2011, at 10:46 AM, Daniel Roseman wrote:
>>
>> > On Thursday, March 10, 2011 11:59:15 PM UTC-8, Ndungi Kyalo wrote:
>> > Hi guys. Am using django non-rel on appengine. I am using django's
>> > auth backend for my authentication, since I did not want to have to
>> > force my users to use gmail logins, and appengine models
>> > {google.appengine.ext.db} for the other models. I have a form where I
>> > allow users to edit their email. So :
>> >
>> > if settings_form.is_valid() :
>> > user = request.user
>> > user.email = request.POST['email']
>> > user.save()
>> >
>> > print request.POST['email']  returns the correct data entered in the
>> > form. But user.save() just doesnt save!
>> > Am I doing it correctly ? Is there something else I shopuld be doing ?
>> > --
>> > Regards,
>> > Guy-at-the-end-of-the-tether :-)
>> >
>> > Are you sure that the condition is true - that the form is valid? Put
>> some logging in to be sure.
>>
>> Are you sure that user is a django.contrib.auth.models.User and not at
>>  django.contrib.auth.models.AnonymousUser.
>>
>>
>> http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.user
>>
>> if request.user.is_authenticated():
>># Do something for logged-in users.
>> else:
>># Do something for anonymous users.
>>
>>
>>
>> > --
>> > DR.
>> >
>> > --
>> > 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: request.user.save() doesnt work

2011-03-12 Thread Ndungi Kyalo
It is a django.contrib.auth.models.User , as you say.

On 11 March 2011 22:06, Jason Culverhouse  wrote:

>
> On Mar 11, 2011, at 10:46 AM, Daniel Roseman wrote:
>
> > On Thursday, March 10, 2011 11:59:15 PM UTC-8, Ndungi Kyalo wrote:
> > Hi guys. Am using django non-rel on appengine. I am using django's
> > auth backend for my authentication, since I did not want to have to
> > force my users to use gmail logins, and appengine models
> > {google.appengine.ext.db} for the other models. I have a form where I
> > allow users to edit their email. So :
> >
> > if settings_form.is_valid() :
> > user = request.user
> > user.email = request.POST['email']
> > user.save()
> >
> > print request.POST['email']  returns the correct data entered in the
> > form. But user.save() just doesnt save!
> > Am I doing it correctly ? Is there something else I shopuld be doing ?
> > --
> > Regards,
> > Guy-at-the-end-of-the-tether :-)
> >
> > Are you sure that the condition is true - that the form is valid? Put
> some logging in to be sure.
>
> Are you sure that user is a django.contrib.auth.models.User and not at
>  django.contrib.auth.models.AnonymousUser.
>
>
> http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.user
>
> if request.user.is_authenticated():
># Do something for logged-in users.
> else:
># Do something for anonymous users.
>
>
>
> > --
> > DR.
> >
> > --
> > 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: request.user.save() doesnt work

2011-03-12 Thread Ndungi Kyalo
Yes, the form validates and returns true.

On 11 March 2011 21:46, Daniel Roseman  wrote:

> Are you sure that the condition is true - that the form is valid? Put some
> logging in to be sure.

-- 
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: test cannot find assertContains

2011-03-12 Thread Mike Ramirez
On Friday, March 11, 2011 11:37:38 pm Kenneth Gonsalves wrote:

> and all is well. I think the dev docs need to be clearer on this point
> and mention this at the outset. After all they *are* dev docs.

http://docs.djangoproject.com/en/1.2/topics/testing/#testcase 


Mike
--
Would that my hand were as swift as my tongue.
-- Alfieri

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