Re: ANN: Updated Django Cheat Sheet

2008-09-21 Thread Nikos Delibaltadakis
Shouldn't ForeignKeyField to be just ForeignKey? Am I missing something? 2008/9/10 Fraser Nevett <[EMAIL PROTECTED]> > > Just letting everyone know that we've released a new edition which > removes the PhoneNumberField and USStateField fields as discussed -- > thanks to all those who contacted us

Re: webfaction django installation

2008-09-21 Thread tupixo
> I had also similar problems, because instead of documentation they have a > screencast(?!) and the forum. Did you at least spend 30 seconds looking for docs before writing that? They have a Django category in their knowledge base with quite a few articles: https://help.webfaction.com/index.php?

form get with special characters

2008-09-21 Thread Alessandro
I have a search form. When a user inserts a string like "Forlì", django returns a blank page. I need to convert ì to a url encoded string, but I don't know how to do. Thanks in advance. -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net SOASI Soc.Coop. - www.soasi.com Sviluppo

Re: DJANGO 1.0 : How to avoid converting to entities

2008-09-21 Thread Ivan Sagalaev
Malcolm Tredinnick wrote: >> Better yet, the thing that creates colorizedCode should mark it as >> "safe" (i.e. not requiring escaping) in this fashion: >> >> from django.utils.safestring import mark_safe >> def colorize(): >> # ... >> return mark_safe(result) > > Alt

Re: form get with special characters

2008-09-21 Thread Malcolm Tredinnick
On Sun, 2008-09-21 at 12:44 +0200, Alessandro wrote: > I have a search form. > When a user inserts a string like "Forlì", django returns a blank page. > I need to convert ì to a url encoded string, but I don't know how to do. You haven't explained where the problem is occurring. Is the correct d

filter queryset in admin

2008-09-21 Thread Alessandro
I want staff users to be able to see and edit only their objects. With newforms admin I managed to avoid cross user editings with def has_change_permission(self, request, obj=None): if obj and request.user == obj.referente: return super(SchedaOptions, self).has_change_permi

Re: form get with special characters

2008-09-21 Thread Alessandro Ronchi
2008/9/21 Malcolm Tredinnick <[EMAIL PROTECTED]>: > > > On Sun, 2008-09-21 at 12:44 +0200, Alessandro wrote: >> I have a search form. >> When a user inserts a string like "Forlì", django returns a blank page. >> I need to convert ì to a url encoded string, but I don't know how to do. > > You haven'

Django -- very very basic query !

2008-09-21 Thread [EMAIL PROTECTED]
Hi, I am basically c/c++/Unix dev, and knowing little python stuff. And little bit about xhtml. I just wanted to know to learn/develop site using Django, Do i have to master of Python, Xhtml , Javascript ? What kind of stuff, i can do using Django ? Thanks Raxit www.m4mum.com --~--~-~

Admin field custom validation

2008-09-21 Thread [EMAIL PROTECTED]
Hi, This is my code: class LogoAdminForm(forms.ModelForm): class Meta: model = Logo def clean(self): from django.core.files.images import get_image_dimensions logo = self.cleaned_data['logo'] w, h = get_image_dimensions(logo) if w > 150 or h > 150:

Re: Admin field custom validation

2008-09-21 Thread [EMAIL PROTECTED]
Sorry I was wrong, if I try to submit a NEW logo that is too large it fails correctly. But when I try to add a new logo that is the right size it enters a fully blank row into the database. Thanks --~--~-~--~~~---~--~~ You received this message because you are subs

Re: form get with special characters

2008-09-21 Thread julianb
On Sep 21, 4:01 pm, "Alessandro Ronchi" <[EMAIL PROTECTED]> wrote: > It seems now It works, becausehttp://www.animalisenzacasa.org/ricerca/?s=forlì > is converted to:http://www.animalisenzacasa.org/ricerca/?s=forl%C3%AC > > I don't know what's changed, because this morning the result was an > empt

Re: Admin field custom validation

2008-09-21 Thread [EMAIL PROTECTED]
Having done a bit more research I see this often used as: clean_fieldname(self) rather than clean(self) which I guess would eleviate my problem, as my clean(self) function doesn't appear to remember or pass on the rest of the submitted field information. However when I try the above I get: 'None

Sorting list of objets in Python/Django

2008-09-21 Thread Nianbig
Hi, I have a people-list like this: >>> class a: ... def __init__(self, name, number): ... self.name = name ... self.number = number ... >>> b = [] >>> b.append( a('Smith', 1) ) >>> b.append( a('Dave', 456) ) >>> b.append( a('Guran', 9432) ) >>> b.append( a('Asdf', 12)

Re: Sorting list of objets in Python/Django

2008-09-21 Thread Fredrik Lundh
Nianbig wrote: > I have a people-list like this: class a: > ... def __init__(self, name, number): > ... self.name = name > ... self.number = number > ... b = [] b.append( a('Smith', 1) ) b.append( a('Dave', 456) ) b.append( a('Guran', 9432) ) >

Re: Admin field custom validation

2008-09-21 Thread Daniel Roseman
On Sep 21, 6:01 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Having done a bit more research I see this often used as: > > clean_fieldname(self) rather than clean(self) > > which I guess would eleviate my problem, as my clean(self) function > doesn't appear to remember or pass on the rest

Re: Admin field custom validation

2008-09-21 Thread [EMAIL PROTECTED]
Hello Daniel, Thank you for your reply. I guess then that I cannot test image heights and widths on a form pre- save, because that is the only reason I can think of for this error after forum submissal (if I use clean_logo) 'NoneType' object is unsubscriptable. Does that make sense ? --~--~

Django 1.0 - Form documentation

2008-09-21 Thread Luis Sanchez
Hi, Do you know where can I find documentation about forms in django 1.0 specially for validations? Luis. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to d

Re: Django 1.0 - Form documentation

2008-09-21 Thread [EMAIL PROTECTED]
Does this help ? http://docs.djangoproject.com/en/dev/ref/forms/validation/ --~--~-~--~~~---~--~~ 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 u

Re: webfaction django installation

2008-09-21 Thread Bobby Roberts
> The "Getting started with Django at WebFaction" article should solve > Bobby's > problem:https://help.webfaction.com/index.php?_m=knowledgebase&_a=viewarticle... > Setting up a static application was easy and worked perfectly. Thanks! --~--~-~--~~~---~--~~ You

Comments

2008-09-21 Thread Bobby Roberts
the Django docs state that "Django's comments are all "attached" to some parent object"... I'm building a very simple django powered website with auth, flatpages, and comments currently installed. I want to use the comments so people can post testimonials which can then be displayed on the site.

Re: Django -- very very basic query !

2008-09-21 Thread John M
I would suggest taking a couple of hours to do the tutorial, and it basically runs through most of what django can do. Since 1.0 is out, you just need to download, install and run through the tutorial. It runs on any platform. Have fun. John On Sep 21, 7:20 am, "[EMAIL PROTECTED]" <[EMAIL PRO

ultra-n00b models.Model syntax error

2008-09-21 Thread notatoad
i just set up django and started on the tutorial. i get this after calling 'python manage.py sql polls' ceback (most recent call last): File "manage.py", line 11, in ? execute_manager(settings) File "/usr/lib/python2.4/site-packages/django/core/management/ __init__.py", line 3

_get_next_or_previous_ usage

2008-09-21 Thread Rafael Beccar Barca
Hi, I didn't find documentation for _get_next_or_previous_by_FIELD and _get_next_or_previous_in_order What parameters should I pass when calling them from shell ? How should I use them on my templates ? Gracias, Rafael --~--~-~--~~~---~--~~ You received this me

Passing in a value from a url

2008-09-21 Thread djandrow
Hi, I am currently trying to pass in a value from a url and the perform a query based on that, i've tried this: def category_view(request, category): current_entries = Entry.objects.filter(entry_cat=category).order_by("- entry_date") return render_to_response('blog/base.html', loc

Re: ultra-n00b models.Model syntax error

2008-09-21 Thread Karen Tracey
On Sun, Sep 21, 2008 at 4:21 PM, notatoad <[EMAIL PROTECTED]> wrote: > > i just set up django and started on the tutorial. i get this after > calling 'python manage.py sql polls' > > [snip] > File "/usr/local/django-apps/mysite/../mysite/polls/models.py", line 3 > >class Poll(mode

Re: Passing in a value from a url

2008-09-21 Thread Karen Tracey
On Sun, Sep 21, 2008 at 4:36 PM, djandrow <[EMAIL PROTECTED]> wrote: > > Hi, I am currently trying to pass in a value from a url and the > perform a query based on that, i've tried this: > > def category_view(request, category): >current_entries = > Entry.objects.filter(entry_cat=category)

Re: Sorting list of objets in Python/Django

2008-09-21 Thread Nianbig
Ah, thanks! /Nianbig On 21 Sep, 19:45, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Nianbig wrote: > > I have a people-list like this: > class a: > > ...     def __init__(self, name, number): > > ...             self.name = name > > ...             self.number = number > > ... > b = []

Re: Passing in a value from a url

2008-09-21 Thread djandrow
Here is my model for entry; class Entry(models.Model): entry_id = models.AutoField(primary_key=True) entry_date = models.DateField(auto_now_add=True) entry_title = models.CharField(max_length=70) entry_content = models.TextField(max_length=5000) entry_cat

Re: Sorting list of objets in Python/Django

2008-09-21 Thread Rodolfo
You could also achieve that using the __cmp__ magic method[1]: class a: def __init__(self, name, number): self.name = name self.number = number def __cmp__(self, other): return cmp(self.name, other.name) def __repr__(self): return "a(%s, %s)" % (rep

Re: Comments

2008-09-21 Thread Dmitry Dzhus
Bobby Roberts wrote: > What would I attach to using this form statement as a > starting point: > > {% render_comment_form for [object] %} > > ie what should the object be? Semantically comments application is not intended for creating new first-class data on your site, so the fact that you have

Re: _get_next_or_previous_ usage

2008-09-21 Thread Rodolfo
You can find the definition of those methods at: /django/django/db/models/base.py:def _get_next_or_previous_by_FIELD(self, field, is_next, **kwargs): /django/django/db/models/base.py:def _get_next_or_previous_in_order(self, is_next): So, check on your django installation to see what the

Re: Passing in a value from a url

2008-09-21 Thread Karen Tracey
On Sun, Sep 21, 2008 at 5:29 PM, djandrow <[EMAIL PROTECTED]> wrote: > > Here is my model for entry; > > class Entry(models.Model): > >entry_id = models.AutoField(primary_key=True) >entry_date = models.DateField(auto_now_add=True) >entry_title = models.CharField(max_length=

Adding www. prefix to get_absolute_url

2008-09-21 Thread Catalyst
I'm using Django .96 and I'm having trouble getting get_absolute_url to add a www. prefix on to my URLs. For the most part everything on my site keeps people on my www. URL, which is my goal, but my sitemap and RSS feeds point to URLs without a www. on them. Does anyone know a good way to

Re: Adding www. prefix to get_absolute_url

2008-09-21 Thread Erik Allik
You should instead use named URLs and the django.core.urlresolvers.reverse function in your get_absolute_url methods. That way you'll leave it to the URL system to handle. I believe you shouldn't use absolute URLs (with http:// and domain) at all. Just make sure in your web server config t

Impact of a CustomManager on the RelatedManager

2008-09-21 Thread gaz
Hi everyone, I apologise for the verbosity of this message - for my first post it's quite long. I am currently working on my first project employing the Sites framework, and have been moving along quite well with the documentation until I hit a snag last night. I have overloaded the default man

Re: _get_next_or_previous_ usage

2008-09-21 Thread Malcolm Tredinnick
On Sun, 2008-09-21 at 17:36 -0300, Rafael Beccar Barca wrote: > Hi, > > I didn't find documentation for _get_next_or_previous_by_FIELD and > _get_next_or_previous_in_order The fact that they start with underscores and aren't documented in the Model API is a big that they are internal methods, n

Re: _get_next_or_previous_ usage

2008-09-21 Thread Rafael Beccar Barca
On Sun, Sep 21, 2008 at 9:23 PM, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > > On Sun, 2008-09-21 at 17:36 -0300, Rafael Beccar Barca wrote: >> Hi, >> >> I didn't find documentation for _get_next_or_previous_by_FIELD and >> _get_next_or_previous_in_order > > The fact that they start with und

Re: Sorting list of objets in Python/Django

2008-09-21 Thread Steve Holden
You could, but a key function is generally better, and the larger the list the better (in the general case) it is likely to be. The problem is that using __cmp__ requires the sort algorithm to make Python callbacks from a C function for each object-pair comparison. Using the key function, that fun

sample app for beginner

2008-09-21 Thread Chuck Bai
Does anyone know a sample Django 1.0 application with complete source code that is good for beginner to explore? Thanks, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: filter queryset in admin

2008-09-21 Thread Martin Ostrovsky
Assuming you're using Django v1.0 ... you could override the queryset method in your class that defines the admin properties for your class. For example: class MyAdminClass(admin.ModelAdmin): def queryset(self, request): # Limit the queryset to some subset based on the value of reque

Re: ModelMultipleChoiceField and initial values

2008-09-21 Thread Vance Dubberly
Wow this is really screwing me royal. Doesn't work with any form of select, best I can tell initial doesn't work with ChoiceFields at all. I've tried going into the source and logging out the value param to the widget and it is always just []. Am I on crack, can somebody verify, so I can file a

Re: sample app for beginner

2008-09-21 Thread Gerard Petersen
Chuck, The Django tutorial should get you going: http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01 And an app. published earlier on this list: http://code.google.com/p/django-todo/ Happy coding. Gerard. Chuck Bai wrote: > Does anyone know a sample Django 1.0 applicatio