Re: Help with apache mod rewrite engine

2009-12-08 Thread Thomas Sutton
Hi Amit,

2009/12/9 Amit Sethi 

> Hi all , I need some help understanding the mod rewrite module of apache .
> What I wished to do want that i had a comments folder by the name of
> /comments/ . Now i run a django project on /sees and i want all the call to
> /comments/ be redirected to /sees/comments and than be handled by the wsgi
> file but the rewriting is not happening is it possible to rewrite url and
> than route it through wsgi script
>

Something like this?

RewriteEngine On
RewriteBase /
RewriteRule ^comments/ ^sees/comments/

Cheers,

Thomas Sutton

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Help with apache mod rewrite engine

2009-12-08 Thread Lakshman Prasad
You can just replace the regex ^/comments/$ with ^/sees/comments/$ within
the urls.py

Why can't you do that?

On Wed, Dec 9, 2009 at 12:10 PM, Amit Sethi wrote:

> Hi all , I need some help understanding the mod rewrite module of apache .
> What I wished to do want that i had a comments folder by the name of
> /comments/ . Now i run a django project on /sees and i want all the call to
> /comments/ be redirected to /sees/comments and than be handled by the wsgi
> file but the rewriting is not happening is it possible to rewrite url and
> than route it through wsgi script
>
> --
> A-M-I-T S|S
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>



-- 
Regards,
Lakshman
becomingguru.com
lakshmanprasad.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-us...@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-syncr - twitter.User.profile_image_url - deprecated attribute?

2009-12-08 Thread neridaj
Hello,

I'm just curious if anyone else has run into this problem using the
twitter app in django-syncr. I looked on the twitter API docs but
didn't find anything.

t.syncTwitterUserTweets('twitteruser')
Traceback (most recent call last):
File "", line 1, in 
File "/Users/user/django-apps/syncr/app/tweet.py", line 111, in
syncTwitterUserTweets
self._syncTwitterStatus(status)
File "/Users/user/django-apps/syncr/app/tweet.py", line 81, in
_syncTwitterStatus
user = self._syncTwitterUser(status.user)
File "/Users/user/django-apps/syncr/app/tweet.py", line 55, in
_syncTwitterUser
'thumbnail_url': user.profile_image_url,
AttributeError: 'User' object has no attribute 'profile_image_url'

Thanks,

Jason

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Help with apache mod rewrite engine

2009-12-08 Thread Amit Sethi
Hi all , I need some help understanding the mod rewrite module of apache .
What I wished to do want that i had a comments folder by the name of
/comments/ . Now i run a django project on /sees and i want all the call to
/comments/ be redirected to /sees/comments and than be handled by the wsgi
file but the rewriting is not happening is it possible to rewrite url and
than route it through wsgi script

-- 
A-M-I-T S|S

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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' object has no attribute 'ordered' Error When Using Inline Formset

2009-12-08 Thread Karen Tracey
On Tue, Dec 8, 2009 at 11:13 PM, saved...@gmail.com wrote:

> Every time I try to access a formset via inlineformset_factory I get
> the following error messages:
>
> Traceback:
> [snip]
> File "/home/luckybs/webapps/django1/lib/python2.5/django/forms/
> models.py" in get_queryset
>  495. if not qs.ordered:
>
> Exception Type: AttributeError at /questions/10/add_answer/
> Exception Value: 'QuerySet' object has no attribute 'ordered'
>
> I just updated my forms directory on my shared host from 1.0 to 1.2
> (Perhaps that could be the problem?)
>

First, 1.2 does not yet exist.  It's in development.  Perhaps you mean you
updated to a recent SVN checkout?

Second, you updated JUST the Django forms directory from 1.0 to ?  If so, yes, that is the problem. The line having the problem is in
django/forms, it is a line added (I think) during 1.1 development, and it
requires other code changes made elsewhere in the Django code base.  You
cannot simply update subdirectories within django individually. Django is an
integrated package: you need update the whole thing, or not at all.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Viewing uploaded files via the admin interface

2009-12-08 Thread Karen Tracey
On Tue, Dec 8, 2009 at 4:42 PM, Lukas  wrote:

> Hi everyone,
>
> i've a problem viewing uploaded files via the admin interface. When I
> try to view the file, everything I get is a ValueError exception:
> invalid literal for int() with base 10...
> I know it goes wrong, when your MEDIA_URL is not set correctly.
>
> The link to the file in the admin interface is:
> http://localhost:8000/admin/myModel/attachment/1/files/my-file.pdf/
>
> should be:
> http://localhost:8000/media/files/my-file.pdf/ <- this one works
>
> Here's are my related code:
>
> settings.py
> [...]
> MEDIA_ROOT = os.path.join(PROJECT_DIR,'media')
> MEDIA_URL = 'localhost:8000/media/'
>

Get rid of the localhost:8000 here.  Make MEDIA_URL just '/media/'.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: CharField cannot have a "max_length" greater than 255 when using "unique=True"

2009-12-08 Thread Karen Tracey
On Tue, Dec 8, 2009 at 1:21 PM, germ  wrote:

> > The point is that utf8 can use up to 3 bytes per character...
>
> i appreciate your reply. interesting distinction between bytes and
> chars. i think i still need some more guidance. still not sure how to
> resolve with your suggestion to consdier the character set.
>
> i am able to create the django model class defining the table manually
> in mysql without any error. i was also able to create that same model
> with django 1.0.2 using syncdb. however, with django 1.1.1 i get the
> max_length error (as originally posted). it seems like the django
> syncdb code is detecting a size threshold, outputting the error, and
> exiting without ever really attempting the mysql table create.
>
>
Yes, I believe that change was made in response to this thread:

http://groups.google.com/group/django-developers/browse_thread/thread/edf3312c4fa1d2d4

reporting validation did not detect table creations that MySQL would reject.
The ticket to look at for details of the change is #9431 (
http://code.djangoproject.com/ticket/9431).  It appears to be rather
difficult to determine ahead of time what, exactly, is the limit MySQL will
apply. You show it reporting 767 bytes, that thread shows it reporting 999
bytes, the ticket notes it's a different limit for InnoDB compared to
MyISAM, the table charset is a factor, etc.

I think that a limit of 255 was put into Django due to difficulty
(impossibility?) of figuring out ahead of time what the limit really is for
the table about to be created, and since 255 would definitely not trigger an
error, and probably having a unique index on a field longer than that is
likely not a great idea.  But I'm not sure about all the reasons, I'm just
guessing based on what I read on the thread/ticket.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 values and unbound forms (apparently a bug?)

2009-12-08 Thread Info Cascade
Hi, Manu,

Thanks for writing.  I tried what you suggested, and the forms were
displayed exactly as I wanted.
However, when I tried to submit the form, it triggered validation errors
for all the fields that were
left blank.
So, the behavior is not quite what I want.
I'm guessing that setting the initial values in that way is triggering
something that marks the form as having been modified.
So, back to the drawing board!

Any ideas, anyone?

Liam


Manu wrote:
> Hello,
>
> I would say that the behavior you have is normal. Quoting the doc
> 
> "Using initial data with a formset:
> Initial data is what drives the main usability of a formset. As shown
> above you can define the number of extra forms. What this means is
> that you are telling the formset how many additional forms to show
> **in addition** to the number of forms it generates from the initial
> data."
> 
>
> What I understood from the doc is that initial values are used for
> existing objects or ones being built. Ie, if you provided 6 forms with
> default values in a formset, you will end up with 6 new objects
> created/modified. It's up to you then to really create/modfiy those
> objects.
>
> Consequently a solution for you would be to set extra=0 and set up you
> inital datas as you have done but not create objects if default
> values have not been changed (for instance).
>
> Manu
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: UserProfile and Admin interface

2009-12-08 Thread Victor Hooi
heya,

I should probably add an example - we want to add a Title field to the
user form. Ideally, this would appear seamlessly as part of the User
form, next to the name fields, rather than it's own separate sub-
section below. What would be a Django-esque way of achieving that?

Cheers,
Victor

On Dec 9, 3:24 pm, Victor Hooi  wrote:
> heya,
>
> Well, now that was a bit silly of me.
>
> I just noticed that I was importing with "from
> django.contrib.auth.admin import UserAdmin", but then I was calling
> "admin.UserAdmin" below, rather than "UserAdmin". I've fixed that now,
> and the "People" app is now appearing in the admin interface. I'm
> still a bit confused as to why it sometimes seemed to load before, and
> sometimes gave the unable to find UserAdmin error before.
>
> Anyhow, on the User editing form, it does indeed have the extra
> "Person" attributes at the bottom (in this case, just "has_paid").
>
> However, each Department has a Head, which is a FK to a Person/User in
> the database. Initially, the drop-down list to select a Head is empty
> (I guess we have no Person objects). However, if I edit a user, and
> toggle the has_paid field, it will create the Person object associated
> with that user. Then, if I go into Department, the drop down now has
> "Person object" in it. I suppose I can edit the __unicode__ method for
> Person to spit out something a little friendlier (that's the best
> thing to do, right?)
>
> Either way, is there a friendlier way of auto-creating those Person
> objects, whenever a user is added? Or more tightly binding those two
> objects, User/Person together? All I really want is to add some extra
> fields to User - and I know that Bennett's blog post lists several
> reasons why a user-profile is better than sub-classing User, so I
> guess profiles is the way to go, but I'm trying to find a more
> intuitive way to deal with it all.
>
> Cheers,
> Victor
>
> On Dec 9, 2:53 pm, Victor Hooi  wrote:
>
>
>
> > heya,
>
> > I'm having issues extending Django's user model via UserProfile, and
> > then editing this through the admin interface. Essentially, what I
> > want is to add some extra fields to the User model (I've called this
> > model "Person"), and be able to edit these along with the normal User
> > attributes inline all from a single page.
>
> > In models.py:
>
> > from django.db import models
> > from django.contrib.auth.models import User
> > ...
> > class Person(models.Model):
> >     user = models.ForeignKey(User, unique=True)
> >     has_paid = models.BooleanField()
>
> > In admin.py:
>
> > from django.contrib import admin
> > from django.contrib.auth.models import User
> > from django.contrib.auth.admin import UserAdmin
> > from people.models import Person, Department
>
> > class PersonInline(admin.StackedInline):
> >     model = Person
>
> > class UserAdmin(admin.UserAdmin):
> >     inlines = [PersonInline]
>
> > class DepartmentAdmin(admin.ModelAdmin):
> >     pass
>
> > admin.site.register(Department, DepartmentAdmin)
> > admin.site.unregister(User)
> > admin.site.register(User, UserAdmin)
>
> > I've also added this to settings.py:
>
> > AUTH_PROFILE_MODULE = 'people.Person'
>
> > Sometimes, it seemed to come up with error message "AttributeError at /
> > admin/auth/user/1/
> > 'module' object has no attribute 'UserAdmin'". The weird thing was,
> > this seemed to be intermittent, and a refresh of the page loaded up
> > the admin interface normally. However, when that did load, the editing
> > links for Department and Person didn't appear in admin, and nor was
> > there anything about the extra fields under User. There was just the
> > "Auth" and "Sites" section.
>
> > Anyhow, what's the best way of achieve what I want (basically
> > seamlessly combining User/Person, so it'd appear as if User just had
> > some extra fields).
>
> > Cheers,
> > Victor
>
> > PS: I've read a tonne of sites, some of which seem to say slightly
> > different things:
>
> > One page (http://sam.bluwiki.com/blog/2008/05/extending-user-model-
> > profiles-in-django.php), recommended using something like:
>
> >     user = models.ForeignKey(User, unique=True,
> > edit_inline=models.TABULAR, num_in_admin=1,min_num_in_admin=1,
> > max_num_in_admin=1,num_extra_on_change=0)
>
> > However, this caused an error at models.TABULAR on my end.
>
> > Other sites:
>
> >http://pyxx.org/2008/08/18/how-to-extend-user-model-in-django-and-ena..

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




question about modelform lifecycle

2009-12-08 Thread chefsmart
At what point in a modelform's lifecycle does the underlying object
become accessible? Specifically, can I access the underlying object in
a modelform's "clean" method?  Or is it only after one does form.save
() with or without commit = False?

I basically need to do some custom validation and need to access the
object's pk attribute in "clean". Can this be done?

Regards,
CM.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: PIL zip decoder error (while installed) refering to a template tag ?!

2009-12-08 Thread Karen Tracey
On Sun, Dec 6, 2009 at 9:04 PM, GoSantoni  wrote:

> Hi all,
> What does this mean? It doesn't make sense doesn't it? Line 25 isn't
> referring to the PIL...
> Thanks
>
>
I've seen that before.  Whatever calculates the line number in the template
isn't getting it right.  In both your case and the case I noticed it
identified {% for %}, I'm guessing the actual line is within the {% for %}
block.  I have not had time to track down whether there is a ticket open on
this.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: MySQLdb (python 2.6/django from subversion)

2009-12-08 Thread Karen Tracey
On Fri, Dec 4, 2009 at 6:16 AM, Peter  wrote:

> Hi,
>
> I've installed django on an XP box and am trying to work through the
> tutorial.
>
> I got django from svn using the url from the django site:
>
> http://code.djangoproject.com/svn/django/trunk
>
> All is well until I try to do syncdb, at which point I get an error
> message:
>
> Error loading MySQLdb module: DLL load failed: The specified module
> could not be found
>
> I get the same if I try to import the module from the python prompt,
> as well.
>
>
Something is broken with your MySQLdb install.  Until you can import MySQLdb
from a Python command prompt, Django isn't going to be able to use it.

You need to find/build a working MySQLdb for Python 2.6.  I vaguely remember
that when Python 2.6 first came out someone posted an executable installer
for MySQLdb for Windows for it, but that version only worked if you had a
certain compiler runtime installed.  Later on someone posted one that worked
without that requirement.  Unfortunately I don't remember where I got a
working version.  You might have better luck on a more general Python list,
or a MySQLdb-specific forum.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: newbie problem with ModelForm

2009-12-08 Thread Karen Tracey
On Fri, Dec 4, 2009 at 6:04 AM, Andreas Kuntzagk <
andreas.kuntz...@mdc-berlin.de> wrote:

> Hi,
>
> have a (probably simple) problem using ModelForms. I'm following this
> guide:
> http://docs.djangoproject.com/en/1.0/topics/forms/modelforms/
>
> Here are my models:
>
> class Run(models.Model):
> name = models.CharField(max_length=200)
>
> class RunForm(ModelForm):
> class Meta:
> model = Run
>
>
> I already have some objects of class Run. But I don't know how to work
> with them and the ModelForm
>
>  >>> r = Run.objects.get(pk=1)
>  >>> f=RunForm(instance=r)
>  >>> f.is_valid()
> False
>  >>> f.save()
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.5/site-packages/django/forms/models.py", line
> 407, in save
> fail_message, commit, exclude=self._meta.exclude)
>   File "/usr/lib/python2.5/site-packages/django/forms/models.py", line
> 43, in save_instance
> cleaned_data = form.cleaned_data
> AttributeError: 'RunForm' object has no attribute 'cleaned_data'
>  >>> f.errors
> {}
>  >>>
>
> What did I misunderstood?
>
>
I think the documentation that shows you can successfully call save() on a
ModelForm created with just an instance parameter is incorrect.  Providing
the instance argument but no data dictionary on creation makes the form
unbound.  An unbound form has no data to validate or save.  The save() code
is tripping up because it is assuming it is dealing with a bound form, which
would have  the cleaned_data attribute.

To actually update an instance based on submitted data, you would supply the
POST data as the data dictionary when creating the form -- the code that is
shown last in the green box:

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method

Karen

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: UserProfile and Admin interface

2009-12-08 Thread Victor Hooi
heya,

Well, now that was a bit silly of me.

I just noticed that I was importing with "from
django.contrib.auth.admin import UserAdmin", but then I was calling
"admin.UserAdmin" below, rather than "UserAdmin". I've fixed that now,
and the "People" app is now appearing in the admin interface. I'm
still a bit confused as to why it sometimes seemed to load before, and
sometimes gave the unable to find UserAdmin error before.

Anyhow, on the User editing form, it does indeed have the extra
"Person" attributes at the bottom (in this case, just "has_paid").

However, each Department has a Head, which is a FK to a Person/User in
the database. Initially, the drop-down list to select a Head is empty
(I guess we have no Person objects). However, if I edit a user, and
toggle the has_paid field, it will create the Person object associated
with that user. Then, if I go into Department, the drop down now has
"Person object" in it. I suppose I can edit the __unicode__ method for
Person to spit out something a little friendlier (that's the best
thing to do, right?)

Either way, is there a friendlier way of auto-creating those Person
objects, whenever a user is added? Or more tightly binding those two
objects, User/Person together? All I really want is to add some extra
fields to User - and I know that Bennett's blog post lists several
reasons why a user-profile is better than sub-classing User, so I
guess profiles is the way to go, but I'm trying to find a more
intuitive way to deal with it all.

Cheers,
Victor

On Dec 9, 2:53 pm, Victor Hooi  wrote:
> heya,
>
> I'm having issues extending Django's user model via UserProfile, and
> then editing this through the admin interface. Essentially, what I
> want is to add some extra fields to the User model (I've called this
> model "Person"), and be able to edit these along with the normal User
> attributes inline all from a single page.
>
> In models.py:
>
> from django.db import models
> from django.contrib.auth.models import User
> ...
> class Person(models.Model):
>     user = models.ForeignKey(User, unique=True)
>     has_paid = models.BooleanField()
>
> In admin.py:
>
> from django.contrib import admin
> from django.contrib.auth.models import User
> from django.contrib.auth.admin import UserAdmin
> from people.models import Person, Department
>
> class PersonInline(admin.StackedInline):
>     model = Person
>
> class UserAdmin(admin.UserAdmin):
>     inlines = [PersonInline]
>
> class DepartmentAdmin(admin.ModelAdmin):
>     pass
>
> admin.site.register(Department, DepartmentAdmin)
> admin.site.unregister(User)
> admin.site.register(User, UserAdmin)
>
> I've also added this to settings.py:
>
> AUTH_PROFILE_MODULE = 'people.Person'
>
> Sometimes, it seemed to come up with error message "AttributeError at /
> admin/auth/user/1/
> 'module' object has no attribute 'UserAdmin'". The weird thing was,
> this seemed to be intermittent, and a refresh of the page loaded up
> the admin interface normally. However, when that did load, the editing
> links for Department and Person didn't appear in admin, and nor was
> there anything about the extra fields under User. There was just the
> "Auth" and "Sites" section.
>
> Anyhow, what's the best way of achieve what I want (basically
> seamlessly combining User/Person, so it'd appear as if User just had
> some extra fields).
>
> Cheers,
> Victor
>
> PS: I've read a tonne of sites, some of which seem to say slightly
> different things:
>
> One page (http://sam.bluwiki.com/blog/2008/05/extending-user-model-
> profiles-in-django.php), recommended using something like:
>
>     user = models.ForeignKey(User, unique=True,
> edit_inline=models.TABULAR, num_in_admin=1,min_num_in_admin=1,
> max_num_in_admin=1,num_extra_on_change=0)
>
> However, this caused an error at models.TABULAR on my end.
>
> Other sites:
>
> http://pyxx.org/2008/08/18/how-to-extend-user-model-in-django-and-ena...http://www.thenestedfloat.com/articles/displaying-custom-user-profile...http://www.amitu.com/blog/2007/july/django-extending-user-model/http://www.codekoala.com/blog/2009/quick-django-tip-user-profiles/http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m...http://shityoucantremember.wordpress.com/2009/02/14/unriddling-the-dj...

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




'QuerySet' object has no attribute 'ordered' Error When Using Inline Formset

2009-12-08 Thread saved...@gmail.com
Every time I try to access a formset via inlineformset_factory I get
the following error messages:

Traceback:
File "/home/luckybs/webapps/django1/lib/python2.5/django/core/handlers/
base.py" in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/home/luckybs/webapps/django1/lib/python2.5/django/contrib/auth/
decorators.py" in __call__
  67. return self.view_func(request, *args, **kwargs)
File "/home/luckybs/webapps/django1/languagen/questions/views.py" in
add_answer
  134. formset =  AnswerFormSet()
File "/home/luckybs/webapps/django1/lib/python2.5/django/forms/
models.py" in __init__
  724. queryset=qs)
File "/home/luckybs/webapps/django1/lib/python2.5/django/forms/
models.py" in __init__
  459. super(BaseModelFormSet, self).__init__(**defaults)
File "/home/luckybs/webapps/django1/lib/python2.5/django/forms/
formsets.py" in __init__
  44. self._construct_forms()
File "/home/luckybs/webapps/django1/lib/python2.5/django/forms/
formsets.py" in _construct_forms
  87. for i in xrange(self.total_form_count()):
File "/home/luckybs/webapps/django1/lib/python2.5/django/forms/
models.py" in total_form_count
  734. return super(BaseInlineFormSet, self).total_form_count
()
File "/home/luckybs/webapps/django1/lib/python2.5/django/forms/
formsets.py" in total_form_count
  68. total_forms = self.initial_form_count() + self.extra
File "/home/luckybs/webapps/django1/lib/python2.5/django/forms/
models.py" in initial_form_count
  729. return super(BaseInlineFormSet, self).initial_form_count
()
File "/home/luckybs/webapps/django1/lib/python2.5/django/forms/
models.py" in initial_form_count
  464. return len(self.get_queryset())
File "/home/luckybs/webapps/django1/lib/python2.5/django/forms/
models.py" in get_queryset
  495. if not qs.ordered:

Exception Type: AttributeError at /questions/10/add_answer/
Exception Value: 'QuerySet' object has no attribute 'ordered'

I just updated my forms directory on my shared host from 1.0 to 1.2
(Perhaps that could be the problem?)
The error message further states that the exact error message resides
i the following:

/home/luckybs/webapps/django1/lib/python2.5/django/forms/models.py in
get_queryset

 488. qs = self.queryset
 489. else:
 490. qs = self.model._default_manager.get_query_set()
 491.
 492. # If the queryset isn't already ordered we need to add an
 493. # artificial ordering here to make sure that all formsets
 494. # constructed from this queryset have the same form order.

 495. if not qs.ordered: ...

 496. qs = qs.order_by(self.model._meta.pk.name)
 497.
 498. if self.max_num > 0:
 499. self._queryset = qs[:self.max_num]
 500. else:
 501. self._queryset = qs

Can anyone point me in the right direction?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




UserProfile and Admin interface

2009-12-08 Thread Victor Hooi
heya,

I'm having issues extending Django's user model via UserProfile, and
then editing this through the admin interface. Essentially, what I
want is to add some extra fields to the User model (I've called this
model "Person"), and be able to edit these along with the normal User
attributes inline all from a single page.

In models.py:

from django.db import models
from django.contrib.auth.models import User
...
class Person(models.Model):
user = models.ForeignKey(User, unique=True)
has_paid = models.BooleanField()

In admin.py:

from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from people.models import Person, Department

class PersonInline(admin.StackedInline):
model = Person

class UserAdmin(admin.UserAdmin):
inlines = [PersonInline]

class DepartmentAdmin(admin.ModelAdmin):
pass

admin.site.register(Department, DepartmentAdmin)
admin.site.unregister(User)
admin.site.register(User, UserAdmin)

I've also added this to settings.py:

AUTH_PROFILE_MODULE = 'people.Person'

Sometimes, it seemed to come up with error message "AttributeError at /
admin/auth/user/1/
'module' object has no attribute 'UserAdmin'". The weird thing was,
this seemed to be intermittent, and a refresh of the page loaded up
the admin interface normally. However, when that did load, the editing
links for Department and Person didn't appear in admin, and nor was
there anything about the extra fields under User. There was just the
"Auth" and "Sites" section.

Anyhow, what's the best way of achieve what I want (basically
seamlessly combining User/Person, so it'd appear as if User just had
some extra fields).

Cheers,
Victor

PS: I've read a tonne of sites, some of which seem to say slightly
different things:

One page (http://sam.bluwiki.com/blog/2008/05/extending-user-model-
profiles-in-django.php), recommended using something like:

user = models.ForeignKey(User, unique=True,
edit_inline=models.TABULAR, num_in_admin=1,min_num_in_admin=1,
max_num_in_admin=1,num_extra_on_change=0)

However, this caused an error at models.TABULAR on my end.

Other sites:

http://pyxx.org/2008/08/18/how-to-extend-user-model-in-django-and-enable-new-fields-in-newforms-admin/
http://www.thenestedfloat.com/articles/displaying-custom-user-profile-fields-in-djangos-admin
http://www.amitu.com/blog/2007/july/django-extending-user-model/
http://www.codekoala.com/blog/2009/quick-django-tip-user-profiles/
http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/
http://shityoucantremember.wordpress.com/2009/02/14/unriddling-the-django-user-profile/

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 avoid pk collisions at loaddata time

2009-12-08 Thread Russell Keith-Magee
On Wed, Dec 9, 2009 at 8:28 AM, Phlip  wrote:
> Djangoids:
>
> Does the data fixture support automatically generated primary keys?
>
> We need to add a tiny stretch of new data to an existing website. A
> fixture, such as new_data.json, would work great for both the new data
> and for their new feature's unit tests. Then we would just run
> loaddata on the server.
>
> However, the fixture format seems to require hard-coded PKs. So we
> should not risk overwriting (or skipping?) any preexisting live data.
>
> I could code around this, either by looking up the current PKs and
> then moving the new ones to miss them, or by writing a README.txt file
> explaining how to add the same data thru the Admin. But this would
> seem to be a systemic problem with fixtures, so I was curious if they
> had a systemic solution.

At present, no. There is no systemic solution to this. Fixtures
require that you define a primary key.

In the past, it has been proposed that we allow fixtures to omit the
primary key, which would result in the same behavior that Django has
in code - a missing primary key results in an SQL INSERT and a new
object instance. However, this introduces a new problem - how do you
reference an object that is contained in a fixture (e.g., a foreign
key reference in the fixture to an object that is also in the
fixture)? As always, suggestions are welcome.

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-us...@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 avoid pk collisions at loaddata time

2009-12-08 Thread Phlip
Djangoids:

Does the data fixture support automatically generated primary keys?

We need to add a tiny stretch of new data to an existing website. A
fixture, such as new_data.json, would work great for both the new data
and for their new feature's unit tests. Then we would just run
loaddata on the server.

However, the fixture format seems to require hard-coded PKs. So we
should not risk overwriting (or skipping?) any preexisting live data.

I could code around this, either by looking up the current PKs and
then moving the new ones to miss them, or by writing a README.txt file
explaining how to add the same data thru the Admin. But this would
seem to be a systemic problem with fixtures, so I was curious if they
had a systemic solution.

--
  Phlip
  http://c2.com/cgi/wiki?MoreliaViridis

--

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




Re: How to get the last item of array in a built-in template tag?

2009-12-08 Thread pjrhar...@gmail.com
Whoops, didn't actually try that as I'm not at my normal pc, I just
remembered reading it somewhere.

Thinking about it now, you can actually just do:

{{ my_list|last }}

Pete

On Dec 7, 8:35 pm, Gaffar Overcomes  wrote:
> hey pete this does not work :S
> negative index does not support error occured..
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 Application Without it's own models

2009-12-08 Thread Russell Keith-Magee
On Wed, Dec 9, 2009 at 5:07 AM, spool  wrote:
> Hi I've got the same problem.
>
> Here's what I'd like to do: I'm trying to create a generic
> "time_series" app, which has models which are inherited by other apps
> but are not functional by themselves. I would like to create test
> models in tests.py, and then run unittests on them.

What you're looking for is ticket #7835.

This is a long standing problem for Django itself. For example, in
order to test contrib.admin, you need to have models defined, but the
models you need to test won't always be interesting or useful in the
general sense (in fact, they will almost never be).

Django solves this problem by having an external test suite that
consists of test applications - the tests/modeltests and
tests/regressiontests directories. This solution isn't ideal, but it
does work.

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-us...@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: FieldError on Django's sessions

2009-12-08 Thread dlrust
Starting to experience this error on our development server as well.
I'm beginning to think its some conflict in Django itself.

We even started getting other `FieldError`s like:

" FieldError: Cannot resolve keyword 'username' into field. Choices
are: id, username "

Any input would be helpful in debugging this issue.

Thanks
Daniel

On Dec 3, 3:02 pm, dlrust  wrote:
> Just experienced a very strange error on our production server on all
> page requests.
>
> "FieldError: Cannot resolve keyword 'session_key' into field. Choices
> are: expire_date, session_data, session_key"
>
> The error persisted for about 10 minutes until a graceful restart of
> apache2 was done.
>
> I couldn't find anything online regarding Django users experiencing a
> similar issue. Has anyone else experienced this error?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ManyToOne to auth.models.User

2009-12-08 Thread TiNo
On Tue, Dec 8, 2009 at 12:58, Itay Donenhirsch  wrote:

> one to many from year to user is same as many to one from a
> user to a year.
>

Yes, but how? :D I can't place a FK on the 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-us...@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 uploaded files via the admin interface

2009-12-08 Thread Lukas
Hi everyone,

i've a problem viewing uploaded files via the admin interface. When I
try to view the file, everything I get is a ValueError exception:
invalid literal for int() with base 10...
I know it goes wrong, when your MEDIA_URL is not set correctly.

The link to the file in the admin interface is:
http://localhost:8000/admin/myModel/attachment/1/files/my-file.pdf/

should be:
http://localhost:8000/media/files/my-file.pdf/ <- this one works

Here's are my related code:

settings.py
[...]
MEDIA_ROOT = os.path.join(PROJECT_DIR,'media')
MEDIA_URL = 'localhost:8000/media/'
ADMIN_MEDIA_PREFIX = '/media/admin/'
[...]

urls.py
[...]
from django.conf import settings
if settings.DEBUG:
urlpatterns += patterns('',
(r'^media/(?P.*)$', 'django.views.static.serve',
{ 'document_root': settings.MEDIA_ROOT }),
)

models.py
[...]
class Attachment(models.Model):
attached_file = models.FileField(upload_to="files")
filename = models.CharField(max_length=100)
created_at = models.DateTimeField(auto_now_add=True,
editable=False)
updated_at = models.DateTimeField(auto_now=True, editable=False)

def __unicode__(self):
return self.filename
[...]

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-us...@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 Application Without it's own models

2009-12-08 Thread spool
Hi I've got the same problem.

Here's what I'd like to do: I'm trying to create a generic
"time_series" app, which has models which are inherited by other apps
but are not functional by themselves. I would like to create test
models in tests.py, and then run unittests on them.

from django.test import TestCase
from django.db import models
from time_series.models import *
import datetime

class TestDatePoint(DatePointCanonical):
""" Testing datepoint class """
data = models.IntegerField()
name = models.CharField(max_length=50)

def __unicode__(self):
return '%d %s' % (self.data, self.date)

class TestTimeSeries(TimeSeries):
""" Testing Time Series Class """
time_series = models.ForeignKey(TestDatePoint, null=True,
related_name='time_series')

class InheritanceTest(TestCase):
def setUp(self):
self.ts = TestTimeSeries.objects.create()
self.a = self.ts.add(
data=5, name="first", date=datetime.date.today())
print 'success'

def testFirst(self):
self.assertEqual(self.ts.first, self.a)

def testCanonical(self):
self.assertEqual(self.ts.canonical, self.a)

running ./manage.py test time_series give me this:

EE..
==
ERROR: testCanonical (time_series.tests.InheritanceTest)
--
Traceback (most recent call last):
  File "/Users/griff/code/geonet/time_series/tests.py", line 43, in
setUp
self.ts = TestTimeSeries.objects.create()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/manager.py", line 125, in
create
return self.get_query_set().create(**kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/query.py", line 308, in
create
obj.save(force_insert=True)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/base.py", line 419, in
save
self.save_base(force_insert=force_insert,
force_update=force_update)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/base.py", line 504, in
save_base
result = manager._insert(values, return_id=update_pk)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/manager.py", line 179, in
_insert
return insert_query(self.model, values, **kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/query.py", line 1087, in
insert_query
return query.execute_sql(return_id)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/sql/subqueries.py", line
320, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/sql/query.py", line 2373,
in execute_sql
cursor.execute(sql, params)
ProgrammingError: relation "time_series_testtimeseries" does not exist
LINE 1: INSERT INTO
"time_series_testtimeseries" ("time_series_id") ...
^


==
ERROR: testFirst (time_series.tests.InheritanceTest)
--
Traceback (most recent call last):
  File "/Users/griff/code/geonet/time_series/tests.py", line 43, in
setUp
self.ts = TestTimeSeries.objects.create()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/manager.py", line 125, in
create
return self.get_query_set().create(**kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/query.py", line 308, in
create
obj.save(force_insert=True)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/base.py", line 419, in
save
self.save_base(force_insert=force_insert,
force_update=force_update)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/base.py", line 504, in
save_base
result = manager._insert(values, return_id=update_pk)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/manager.py", line 179, in
_insert
return insert_query(self.model, values, **kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/db/models/query.py", line 1087, in
insert_query
return query.execute_sql(return_id)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/

Accessing foreign key related item

2009-12-08 Thread lfrodrigues
I have this structure:

class Album(models.Model):
caption = models.CharField(max_length=500)

   def get_album_type(self):
if self.a_set.count() > 0: return 'a'
if self.b_set.count() > 0: return 'b'

  def _get_a(self):
return self.a_set.all()[0]

  def _get_b(self):
return self.b_set.all()[0]
   a = property(_get_a)
   b = property(_get_b)

class A(models.Model):
album = models.ForeignKey('album.Album', null=True)

class B(models.Model):
album = models.ForeignKey('album.Album', null=True)

I need to know what is the type of the album and access the related
object, currently using the solution above.
In a template with many albums I'm running a lot of queries, is there
a better way of doing this (a least for the get_album_type function)?

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




Filter queryset by foreignkey or manytomany count

2009-12-08 Thread pbzRPA
Hi

Does anyone know if its possible to filter a queryset by the count of
it's foreignkey or manytomany set?

For example:

class Y(models.Model):
  name = models.CharField(...)

class X(models.Model):
  name = models.CharField(...)
  y_rec = models.ManyToManyField(Y)

class Z(models.Model):
  x = models.ForeignKey(X)

now I would like to:

X.objects.filter(z__count__gt = 0, y__count = 0)

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Filtering queryset using two fields in one model

2009-12-08 Thread pbzRPA
Excellent thank you.

So the solution is:

from django.db.models import F
X.objects.filter(id = F('new_id'))

Thanks for the help guys.


On 8 Gru, 19:38, Boris Schäling  wrote:
> > -Original Message-
> > From: django-users+ow...@googlegroups.com [mailto:django-
> > users+ow...@googlegroups.com] On Behalf Of pbzRPA
> > Sent: Tuesday, December 08, 2009 7:19 PM
> > To: Django users
> > Subject: Filtering queryset using two fields in one model
>
> > Hi,
>
> > I am not sure if this is a really stupid question but how can you
> > filter a model by comparing two of it's own fields?
>
> > for example:
>
> > class X(models.Model):
> >   id = models.IntegerField()
> >   new_id = models.IntegerField()
>
> > now I want to say X.objects.filter(id = new_id)
>
> Seehttp://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-r...
> e-fields-on-the-model
>
> What is missing though is a feature to put a literal value on the left hand
> side - for example:
>
> X.objects.filter(1 = id)
>
> (Here for the equality operator it doesn't matter of course.)
>
> Boris

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Filtering queryset using two fields in one model

2009-12-08 Thread Boris Schäling


> -Original Message-
> From: django-users+ow...@googlegroups.com [mailto:django-
> users+ow...@googlegroups.com] On Behalf Of pbzRPA
> Sent: Tuesday, December 08, 2009 7:19 PM
> To: Django users
> Subject: Filtering queryset using two fields in one model
> 
> Hi,
> 
> I am not sure if this is a really stupid question but how can you
> filter a model by comparing two of it's own fields?
> 
> for example:
> 
> class X(models.Model):
>   id = models.IntegerField()
>   new_id = models.IntegerField()
> 
> now I want to say X.objects.filter(id = new_id)

See
http://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-referenc
e-fields-on-the-model 

What is missing though is a feature to put a literal value on the left hand
side - for example: 

X.objects.filter(1 = id) 

(Here for the equality operator it doesn't matter of course.) 

Boris 


--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Filtering queryset using two fields in one model

2009-12-08 Thread Peter Sagerson
Assuming you're using Django 1.1, take a look at:

http://docs.djangoproject.com/en/1.1/topics/db/queries/#filters-can-reference-fields-on-the-model


On Dec 8, 2009, at 10:18 AM, pbzRPA wrote:

> Hi,
>
> I am not sure if this is a really stupid question but how can you
> filter a model by comparing two of it's own fields?
>
> for example:
>
> class X(models.Model):
>  id = models.IntegerField()
>  new_id = models.IntegerField()
>
> now I want to say X.objects.filter(id = new_id)
>
> 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-us...@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-us...@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: CharField cannot have a "max_length" greater than 255 when using "unique=True"

2009-12-08 Thread germ
> The point is that utf8 can use up to 3 bytes per character...

i appreciate your reply. interesting distinction between bytes and
chars. i think i still need some more guidance. still not sure how to
resolve with your suggestion to consdier the character set.

i am able to create the django model class defining the table manually
in mysql without any error. i was also able to create that same model
with django 1.0.2 using syncdb. however, with django 1.1.1 i get the
max_length error (as originally posted). it seems like the django
syncdb code is detecting a size threshold, outputting the error, and
exiting without ever really attempting the mysql table create.

here's the mysql table created by django 1.0.2 syncdb without any
errors (some portions redacted) as output with 'show create table t':

CREATE TABLE `t` (
  `id` int(11) NOT NULL auto_increment,
  `url` varchar(760) NOT NULL,
  ...
  PRIMARY KEY  (`id`),
  UNIQUE KEY `url` (`url`),
  ...
) ENGINE=InnoDB AUTO_INCREMENT=1374 DEFAULT CHARSET=latin1

and here it is as i manually created it in mysql:

REATE TABLE `mbg_t` (
  `id` int(11) NOT NULL auto_increment,
  `url` varchar(760) NOT NULL,
  ...
  PRIMARY KEY  (`id`),
  UNIQUE KEY `url` (`url`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

the corresponding model class in models.py has not changed from django
1.0.2 to 1.1.1:
  url = models.CharField('Full URL', max_length=760, unique=True)

when we first implemented this a year ago for django 1.0.2 we tried
using a TextField; however, we switched to CharField due to
http://code.djangoproject.com/ticket/2495 which still seems
unresolved.

just looking for a simple way to specify a url field in models.py that
will allow creation with django 1.1.1 syncdb and mysql 5.0.67. want
this url text/char field to be as large as permitted and unique.

thanks all for your time and assistance!

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Filtering queryset using two fields in one model

2009-12-08 Thread pbzRPA
Hi,

I am not sure if this is a really stupid question but how can you
filter a model by comparing two of it's own fields?

for example:

class X(models.Model):
  id = models.IntegerField()
  new_id = models.IntegerField()

now I want to say X.objects.filter(id = new_id)

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-us...@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: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Paul Menzel
Am Dienstag, den 08.12.2009, 08:54 -0800 schrieb Jenn Hughes:
> I'm not sure what you mean by box.

»box« in this case means computer or system.


Thanks,

Paul


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


Re: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Shawn Milochik

On Dec 8, 2009, at 11:38 AM, Jenn Hughes wrote:

> I checked and no proxy is in place. I tried the other IPs, two
> wouldn't let me assign it and the third went through but gave me the
> same error that I began with. How odd.
> 

I suspect there may be some other tiny but very important problem with one of 
your files. Unfortunately, it's probably not something one of us can guess 
without more information, and you're not getting any informational error 
messages we can use to narrow it down. I suggest you work through the official 
tutorial step-by-step. That way, you should find out exactly where the problem 
lies. If you don't get the tutorial to work, knowing the point of failure 
should help a lot. If you do get it to work, then you can compare your project 
with the tutorial and see what's different.

You should be able to zip through enough of the tutorial in 10 or 15 minutes to 
get your answer.

http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01


Shawn


--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Peter Rowell
OK, let's do a little Networking 101.

127.0.0.1 is an unroutable address (that means you'll never see it on
the Internet) that *always* means the local host; in fact it's called
'localhost' in your 'hosts' file. For Linux this is /etc/hosts, for
Windows it's in c:/windows/system32/drivers/etc/hosts. So anything
running at 127.0.0.1 is only reachable by processes running on the
same system. The error message "Firefox can't establish a connection
to the server at 127.0.0.1:8000" means that your Django dev server is
either not running at all *or* it is not running **on the same machine
as Firefox.**

The error message "Error: That IP address can't be assigned-to." is
from Django. It's in django/core/management/commands/runserver.py,
line 84, and is returned when it gets the system error 99
(EADDRNOTAVAIL). It means that the machine you are on is not at the
address 156.56.137.131. Do you know the external address of the
machine you are on? How about the address/domain name of the machine
your django dev server is on? This is important stuff to know.

Let's say you do "python manage.py runserver 0.0.0.0:8000". This tells
the dev server to make itself available on *all possible IP addresses*
that the machine has. If you know the name/address of the machine you
should be able to get to your server now.

... Unless there's a firewall between you and the server that does
like unusual addresses, such as port 8000. Dealing with unknown
firewalls is an incredibly frustrating thing because they are sort of
like The Man Behind the Curtain -- they do stuff but you don't even
know they exist.  Talk to your instructor/sysadmin.

So, one last question: You said "Could the fact that I am using a
university computer make any difference (is there a way they can keep
this from being used?) "

Short answer: yes.

The longer answer is based on the answers to a lot of questions:

1. What kind of computer are you on?

2. Are you typing at the console (ie. the keyboard is directly
connected to the computer where you are trying to run Django) or are
you logged in remotely using SSH (or Putty or something like that)? If
you're at the console then the 127.0.0.1 should have worked. By the
way, if you are on a remote machine and others are working on the same
assignment you are, you may see the error "That port is already in
use." in which case you can try 8001, or some other number above 1024.
(Below 1024 you must be the root user to open that port.)

3. Does the system you are trying to run the dev server on permit you
to have "long running processes"? Many hosting companies explicitly
prohibit this and will auto-terminate anything that runs longer than N
seconds. Ask you system administrator and/or course instructor.

Bottom line: you need to get a better understanding of where your
machine lives relative to the system you are trying to run Django on.

Good luck!

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 allow RSS aggregators to use feeds available only for logged-in users?

2009-12-08 Thread Alex Robbins
Maybe you could just make another url that wasn't password protected.
If the token doesn't get used up in your plan, you have roughly the
same security (not much).

def rss_view(request):
   askdmalkdmakds

protected_rss_view = login_required(rss_view)

Hope that helps,
Alex

On Dec 7, 8:57 am, Miernik  wrote:
> I want to have RSS feeds in my Django application, which should be
> viewable only by a logged-in user. I want to allow users to add these
> RSS feeds to all aggregators, so I would need something which would
> work like this: supply the feed URL with a token, for 
> example:http://example.com/feed/rss=AeYQtFjQfjU5m so that token will
> cause the feed to be seen as if the user would be logged in.
>
> Is there some library in Django which would provide such a
> functionality?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Jenn Hughes
I'm not sure what you mean by box.

Jenn

On Dec 8, 11:26 am, Tom Evans  wrote:
> On Tue, Dec 8, 2009 at 4:18 PM, Jenn Hughes  wrote:
> > I gave this a try and I got this error:
> > [jjhug...@silo cms]$ python manage.py runserver 156.56.137.131:8000
> > Validating models...
> > 0 errors found
>
> > Django version 1.1.1, using settings 'cms.settings'
> > Development server is running athttp://156.56.137.131:8000/
> > Quit the server with CONTROL-C.
> > Error: That IP address can't be assigned-to.
>
> > Could the fact that I am using a university computer make any
> > difference (is there a way they can keep this from being used?)
>
> > Thanks for the help!
>
> > On Dec 8, 11:10 am, Shawn Milochik  wrote:
> >> If you run 'ifconfig' on the command line, you will get your IP address. 
> >> Let's pretend that your IP address is 192.168.1.105. Try this:
>
> >> python manage.py runserver 192.168.1.105:8000
>
> >> See if you can visithttp://192.168.1.105:8000instead.
>
> >> I don't know what the problem is, but maybe it's something to do with your 
> >> hosts file or some firewall issues that's messing with 127.0.0.1.  Thanks 
> >> for providing the command-line output to manage.py, although the fact that 
> >> it's not giving any errors doesn't help us here.
>
> >> Shawn
>
> Is the box you are running 'python manage.py runserver' on the same
> box that you are running internet explorer on?
>
> Seehttp://en.wikipedia.org/wiki/Localhost
>        http://en.wikipedia.org/wiki/IP_address
>
> Cheers
>
> Tom- Hide quoted text -
>
> - Show quoted text -

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Jenn Hughes
I checked and no proxy is in place. I tried the other IPs, two
wouldn't let me assign it and the third went through but gave me the
same error that I began with. How odd.


On Dec 8, 11:24 am, Shawn Milochik  wrote:
> I don't think they can prevent you from using it locally. The fact that I can 
> ping the IP address you provided means that it's publicly available. This 
> either means that your machine has its own direct connection to the Internet, 
> or ipconfig returned multiple addresses, including the address of your 
> router, and you chose that one to try.
>
> It's probably the latter, because that would definitely cause the error you 
> showed from manage.py runserver. There should be a local IP address for your 
> machine as well. Just try the different ones ipconfig shows until manage.py 
> runsever works with it. I supposed it's possible that a proxy server is in 
> place in your browsers by default, although I'd expect them to ignore 
> 127.0.0.1. But out of curiosity, please check your Firefox settings to see if 
> any proxying is taking place.
>
> Shawn

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: admin with data filtered with user scope

2009-12-08 Thread gaddoz
Just wondeful
Thank you

gaddoz

On 8 Dic, 15:04, Xia Kai(夏恺)  wrote:
> Hi~
>
> you can customize your admin interface by overriding default admin functions
> in django/contrib/admin/options.py
>
> These links might be helpful to you:
>
> http://www.slideshare.net/road76/customizing-the-django-admin-euro-dj...http://www.ibm.com/developerworks/opensource/library/os-django-admin/...
>
> Xia Kai(夏恺)
> xia...@gmail.comhttp://blog.xiaket.org
>
> --
> From: "gaddoz" 
> Sent: Tuesday, December 08, 2009 9:59 PM
> To: "Django users" 
> Subject: admin with data filtered with user scope
>
> > Hi all
>
> > I'm pretty new to django and I'm trying to figure out
> > if it's possible to use the wonderful admin feature filtering by user
> > data scope.
> > What I mean? I think that for non admin users could be really nice to
> > use admin
> > interface to manage their own data, for example, managing comments,
> > but
> > only the objects related to the logged user and not like for admin:
> > all the comments for all the users.
>
> > Maybe this is a FAQ somewhere, but I wasn't able to find it out,
> > sorry.
>
> > Thank you in advance for helping.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Tom Evans
On Tue, Dec 8, 2009 at 4:18 PM, Jenn Hughes  wrote:
> I gave this a try and I got this error:
> [jjhug...@silo cms]$ python manage.py runserver 156.56.137.131:8000
> Validating models...
> 0 errors found
>
> Django version 1.1.1, using settings 'cms.settings'
> Development server is running at http://156.56.137.131:8000/
> Quit the server with CONTROL-C.
> Error: That IP address can't be assigned-to.
>
>
> Could the fact that I am using a university computer make any
> difference (is there a way they can keep this from being used?)
>
> Thanks for the help!
>
> On Dec 8, 11:10 am, Shawn Milochik  wrote:
>> If you run 'ifconfig' on the command line, you will get your IP address. 
>> Let's pretend that your IP address is 192.168.1.105. Try this:
>>
>> python manage.py runserver 192.168.1.105:8000
>>
>> See if you can visithttp://192.168.1.105:8000instead.
>>
>> I don't know what the problem is, but maybe it's something to do with your 
>> hosts file or some firewall issues that's messing with 127.0.0.1.  Thanks 
>> for providing the command-line output to manage.py, although the fact that 
>> it's not giving any errors doesn't help us here.
>>
>> Shawn
>

Is the box you are running 'python manage.py runserver' on the same
box that you are running internet explorer on?

See http://en.wikipedia.org/wiki/Localhost
   http://en.wikipedia.org/wiki/IP_address

Cheers

Tom

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Shawn Milochik
I don't think they can prevent you from using it locally. The fact that I can 
ping the IP address you provided means that it's publicly available. This 
either means that your machine has its own direct connection to the Internet, 
or ipconfig returned multiple addresses, including the address of your router, 
and you chose that one to try.

It's probably the latter, because that would definitely cause the error you 
showed from manage.py runserver. There should be a local IP address for your 
machine as well. Just try the different ones ipconfig shows until manage.py 
runsever works with it. I supposed it's possible that a proxy server is in 
place in your browsers by default, although I'd expect them to ignore 
127.0.0.1. But out of curiosity, please check your Firefox settings to see if 
any proxying is taking place.

Shawn

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Jenn Hughes
I gave this a try and I got this error:
[jjhug...@silo cms]$ python manage.py runserver 156.56.137.131:8000
Validating models...
0 errors found

Django version 1.1.1, using settings 'cms.settings'
Development server is running at http://156.56.137.131:8000/
Quit the server with CONTROL-C.
Error: That IP address can't be assigned-to.


Could the fact that I am using a university computer make any
difference (is there a way they can keep this from being used?)

Thanks for the help!

On Dec 8, 11:10 am, Shawn Milochik  wrote:
> If you run 'ifconfig' on the command line, you will get your IP address. 
> Let's pretend that your IP address is 192.168.1.105. Try this:
>
> python manage.py runserver 192.168.1.105:8000
>
> See if you can visithttp://192.168.1.105:8000instead.
>
> I don't know what the problem is, but maybe it's something to do with your 
> hosts file or some firewall issues that's messing with 127.0.0.1.  Thanks for 
> providing the command-line output to manage.py, although the fact that it's 
> not giving any errors doesn't help us here.
>
> Shawn

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: settings caching?

2009-12-08 Thread Benjamin Wolf
Hi Daniel,

thanks for your reply - yes indeed it was the server restart.
I found it out a while after writing this post, but I still don' know 
why a apache restart is needed?
Maybe somebody can give me a short explain
thx a lot ;)

Daniel Roseman schrieb:
> On Dec 8, 1:54 pm, Benjamin Wolf  wrote:
>   
>> Hi there,
>>
>> I've just put my first little django app online (at webfaction) and I
>> have the problem that when I change my database connection in the
>> settings.py,
>> the application always tries to connect with my old connection data.
>> I just got no idea what I could try to fix this, hope you have a hint
>> for me.
>> Thanks and greets,
>> ben
>> 
>
> Maybe a silly question, but have you restarted the Apache instance? At
> webfaction there's a script to do this at:
> ~/webapps/myapp/apache2/bin/restart
> --
> 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-us...@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-us...@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: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Shawn Milochik
Sorry, I should have said 'ipconfig' instead of 'ifconfig' if you're running on 
Windows, and you mentioned IE so I guess you are. Unless you're running your 
Django server on one machine and trying to access it from another, which would 
definitely cause the exact problem you're seeing, but running it with your 
actual IP address should fix.

Shawn


--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Shawn Milochik
If you run 'ifconfig' on the command line, you will get your IP address. Let's 
pretend that your IP address is 192.168.1.105. Try this:

python manage.py runserver 192.168.1.105:8000

See if you can visit http://192.168.1.105:8000 instead.

I don't know what the problem is, but maybe it's something to do with your 
hosts file or some firewall issues that's messing with 127.0.0.1.  Thanks for 
providing the command-line output to manage.py, although the fact that it's not 
giving any errors doesn't help us here. 

Shawn


--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Jenn Hughes
Error on IE:
Internet Explorer cannot display the webpage

   Most likely causes:
You are not connected to the Internet.
The website is encountering problems.
There might be a typing error in the address.

Error on Firefox:
Failed to Connect
Firefox can't establish a connection to the server at
127.0.0.1:8000.

Though the site seems valid, the browser was unable to establish a
connection.

* Could the site be temporarily unavailable? Try again later.
* Are you unable to browse other sites?  Check the computer's
network connection.
* Is your computer or network protected by a firewall or proxy?
Incorrect settings can interfere with Web browsing.

I used "python manage.py syncdb" on cms which went through with out
any errors. I took this to mean it was running.

I have gone through the official tutorial on the site (along with ones
on other sites and one in the book "Practical Django Projects").


This is the message I get when I run the server in the shell:
[jjhug...@silo cms]$ python manage.py runserver
Validating models...
0 errors found

Django version 1.1.1, using settings 'cms.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

I have tried several other ports by adding the port number to the end
of the command, but that did not work either.

On Dec 8, 10:54 am, Shawn Milochik  wrote:
> We'll need some more information. What error messages are you getting, if 
> anything. How do you know the CMS works at all, if it hasn't been run locally?
>
> Have you followed the official tutorial to get a basic understanding of how 
> Django works? If not, please 
> do:http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Shawn Milochik
We'll need some more information. What error messages are you getting, if 
anything. How do you know the CMS works at all, if it hasn't been run locally?

Have you followed the official tutorial to get a basic understanding of how 
Django works? If not, please do: 
http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01


--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Jenn Hughes
Hi, I'm new to django and fairly new to programming. I have django
installed (and it give no errors when imported on python). I also have
a cms made and configured. However I cannot anything to come up on the
page when I ran the server and checked http://127.0.0.1:8000/. I have
tried some other ports also.

If you could please help me out with this it would be GREATLY
appreciated. Thanks.

Jenn

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Forms ForeignKeyField does not populate with initial value

2009-12-08 Thread bruno desthuilliers


On 8 déc, 13:26, Michael  wrote:
> ^ Thanks for that.  Have been scratching my head for a while as .id is
> not a field/property for model.user, according to the doco I am
> reading anyway (http://docs.djangoproject.com/en/dev/topics/auth/
> #topics-auth).

When no primary key is explicitely defined in a model, the ORM
automagically adds one with name "id" and type "integer auto
increment".

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Format fields in list, but keep sortable?

2009-12-08 Thread Shawn Milochik
Bear in mind that the admin has a limited scope. This is intentional. It was 
meant to be a friendly replacement for having to hit the Postgres/mySQL command 
line interface, and that's about it. It's trivial to create your own form for 
dealing with your model which can be customized in any way you like. This is 
not intended to be a snarky response. Partially it's a PSA, and partially a 
reminder to myself; the admin is so great that it makes me lazy, and I end up 
living without some really convenient functionality because the admin "almost 
does it."

Shawn

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: settings caching?

2009-12-08 Thread Daniel Roseman
On Dec 8, 1:54 pm, Benjamin Wolf  wrote:
> Hi there,
>
> I've just put my first little django app online (at webfaction) and I
> have the problem that when I change my database connection in the
> settings.py,
> the application always tries to connect with my old connection data.
> I just got no idea what I could try to fix this, hope you have a hint
> for me.
> Thanks and greets,
> ben

Maybe a silly question, but have you restarted the Apache instance? At
webfaction there's a script to do this at:
~/webapps/myapp/apache2/bin/restart
--
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-us...@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: Styling widgets with django.forms

2009-12-08 Thread Daniel Roseman
On Dec 8, 9:28 am, playfire  wrote:
> I am using django.forms for my forms and I want to style my 
> tags using css. I know I can customize the form template, but how do i
> customize the widget itself? Normally I would do 
> and then put the style in my css file but all I have is
> {{ form.fieldname }} to create the widget.

Well, the input automatically gets an id which is the name of the
field prefixed by 'id_', so you can use that, or you can add a class
value when you declare the field:

def MyForm(forms.Form):
myfield = forms.CharField(widget=forms.TextInput(attrs=
{'class':'myclass'}))

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




ne field lookup revival request

2009-12-08 Thread chefsmart
There used to be an "ne" field lookup (for expressing "not equal to"
conditions).

Now we can do similar things with the "exclude" filters.

But I really think having ne back as a field lookup would help in
situations like when I would like to do a quick:

Issue.objects.get(type__ne='immediate')

Regards,
CM.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: admin with data filtered with user scope

2009-12-08 Thread 夏恺
Hi~

you can customize your admin interface by overriding default admin functions 
in django/contrib/admin/options.py

These links might be helpful to you:

http://www.slideshare.net/road76/customizing-the-django-admin-euro-django-con09
http://www.ibm.com/developerworks/opensource/library/os-django-admin/index.html


Xia Kai(夏恺)
xia...@gmail.com
http://blog.xiaket.org

--
From: "gaddoz" 
Sent: Tuesday, December 08, 2009 9:59 PM
To: "Django users" 
Subject: admin with data filtered with user scope

> Hi all
>
> I'm pretty new to django and I'm trying to figure out
> if it's possible to use the wonderful admin feature filtering by user
> data scope.
> What I mean? I think that for non admin users could be really nice to
> use admin
> interface to manage their own data, for example, managing comments,
> but
> only the objects related to the logged user and not like for admin:
> all the comments for all the users.
>
> Maybe this is a FAQ somewhere, but I wasn't able to find it out,
> sorry.
>
> Thank you in advance for helping.
>
> 

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




admin with data filtered with user scope

2009-12-08 Thread gaddoz
Hi all

I'm pretty new to django and I'm trying to figure out
if it's possible to use the wonderful admin feature filtering by user
data scope.
What I mean? I think that for non admin users could be really nice to
use admin
interface to manage their own data, for example, managing comments,
but
only the objects related to the logged user and not like for admin:
all the comments for all the users.

Maybe this is a FAQ somewhere, but I wasn't able to find it out,
sorry.

Thank you in advance for helping.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




settings caching?

2009-12-08 Thread Benjamin Wolf
Hi there,

I've just put my first little django app online (at webfaction) and I 
have the problem that when I change my database connection in the 
settings.py,
the application always tries to connect with my old connection data.
I just got no idea what I could try to fix this, hope you have a hint 
for me.
Thanks and greets,
ben

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Coltrane Weblog Practical Django Projects 2nd Ed, page not found for http://127.0.0.1:8000/weblog/

2009-12-08 Thread bernard
Hi all,

I am reading through the Practical Django Projects 2nd Edition book
and i am now on the weblog entries_index part (page 84) where im
trying to view the weblog entry index but I get an error No FlatPage
matches the given query.

I followed exactly what's written in the book.
Please help, I'm new to Django and Python:

Here's my views.py
from django.shortcuts import render_to_response
from coltrane.models import Entry


def entries_index(request):
return render_to_response('coltrane/entry_index.html',
{ 'entry_list': Entry.objects.all() })


urls.py
from django.conf.urls.defaults import *
from coltrane.models import Entry

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',

(r'^admin/', include(admin.site.urls)),
(r'^tiny_mce/(?P.*)$', 'django.views.static.serve',
{ 'document_root': '/home/bernard/Django/cms/
tiny_mce/' }),
(r'^search/$', 'cms.search.views.search'),
(r'', include('django.contrib.flatpages.urls')),
(r'^weblog/$', 'coltrane.views.entries_index'), s

)


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-us...@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 error page: traceback too shallow?

2009-12-08 Thread Karen Tracey
On Thu, Dec 3, 2009 at 1:24 AM, notcourage  wrote:

> def home (request):
>
>if (request.user.is_authenticated()):
>artifacts = Artifact.objects.filter
> (member__exact=request.user.profile.id)
> ...
>else:
> ...
>
> In this case, the user is authenticated but the predicate is failing
> as expected because user.profile is NULL. The traceback is just odd.
>
>
I have not seen anything like missing levels in a traceback, nor can I
recreate anything like what you are reporting based on the information
provided.  If you can post a complete small example (models, url patterns,
view) that demonstrates what you see, someone might be able to help more.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Format fields in list, but keep sortable?

2009-12-08 Thread Chris Lawlor
You could add a field to store the calculated size, and override the
model's save method to perform the necessary calculation. Something
like:

def save(self, force_insert=False, force_update=False):
self.size_formatted = self.width * self.height // or whatever your
calculation actually is
super(ModelName, self).save(force_insert, force_update)

Be sure to replace 'ModelName' with the name of your model.

On Dec 8, 7:18 am, philomat  wrote:
> Hi,
>
> I keep numeric fields like "size", "width", "height" in my database.
> In the admin, I want to render them in a friendly format and attach
> units like "KiB" or "pixels" to them when showing them in the change
> list. I know this could easily be achieved by adding callables such as
> "size_formatted" etc to list_display. However, these are no longer
> sortable.
>
> Is there a way around this limitation?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Forms ForeignKeyField does not populate with initial value

2009-12-08 Thread Michael
^ Thanks for that.  Have been scratching my head for a while as .id is
not a field/property for model.user, according to the doco I am
reading anyway (http://docs.djangoproject.com/en/dev/topics/auth/
#topics-auth).

I should have just tried .id in the first place : \

... actually you'd think child tables of auth_user would be very, very
common, an example would be good on above doco me thinks.

.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ManyToOne to auth.models.User

2009-12-08 Thread Itay Donenhirsch
oopsy, one to many from year to user is same as many to one from a
user to a year.

On Tue, Dec 8, 2009 at 1:57 PM, Itay Donenhirsch  wrote:
> hey there,
> why not do one to many from each user to a year? same thing as many to
> one from a year to a user...
> itay
>
>
> On Tue, Dec 8, 2009 at 1:51 PM, TiNo  wrote:
>>> TiNo wrote:
>>> > On Sun, Nov 15, 2009 at 09:31, Dennis Kaarsemaker
>>> > wrote:
>>> >
>>> >
>>> >> On za, 2009-11-14 at 15:53 -0800, TiNo wrote:
>>> >>
>>> >>
>>> >>> In my apps, Users of the app participate in a certain Year. I would
>>> >>> like a Year to continue a ManyToOne relationship with a User.
>>> Don't you need a many to many relationship anyway?  Will a user only be
>>> limited to one year?
>>
>> A User only participates in one year, yes. So a ManyToMany would not be
>> good.
>> Anybody else a solution?
>> Tino
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@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-us...@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: ManyToOne to auth.models.User

2009-12-08 Thread Itay Donenhirsch
hey there,
why not do one to many from each user to a year? same thing as many to
one from a year to a user...
itay


On Tue, Dec 8, 2009 at 1:51 PM, TiNo  wrote:
>> TiNo wrote:
>> > On Sun, Nov 15, 2009 at 09:31, Dennis Kaarsemaker
>> > wrote:
>> >
>> >
>> >> On za, 2009-11-14 at 15:53 -0800, TiNo wrote:
>> >>
>> >>
>> >>> In my apps, Users of the app participate in a certain Year. I would
>> >>> like a Year to continue a ManyToOne relationship with a User.
>> Don't you need a many to many relationship anyway?  Will a user only be
>> limited to one year?
>
> A User only participates in one year, yes. So a ManyToMany would not be
> good.
> Anybody else a solution?
> Tino
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.




Format fields in list, but keep sortable?

2009-12-08 Thread philomat
Hi,

I keep numeric fields like "size", "width", "height" in my database.
In the admin, I want to render them in a friendly format and attach
units like "KiB" or "pixels" to them when showing them in the change
list. I know this could easily be achieved by adding callables such as
"size_formatted" etc to list_display. However, these are no longer
sortable.

Is there a way around this limitation?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Styling widgets with django.forms

2009-12-08 Thread playfire
I am using django.forms for my forms and I want to style my 
tags using css. I know I can customize the form template, but how do i
customize the widget itself? Normally I would do 
and then put the style in my css file but all I have is
{{ form.fieldname }} to create the widget.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ManyToOne to auth.models.User

2009-12-08 Thread TiNo
>
> TiNo wrote:
> > On Sun, Nov 15, 2009 at 09:31, Dennis Kaarsemaker <
> den...@kaarsemaker.net>wrote:
> >
> >
> >> On za, 2009-11-14 at 15:53 -0800, TiNo wrote:
> >>
> >>
> >>> In my apps, Users of the app participate in a certain Year. I would
> >>> like a Year to continue a ManyToOne relationship with a User.
> Don't you need a many to many relationship anyway?  Will a user only be
> limited to one year?
>

A User only participates in one year, yes. So a ManyToMany would not be
good.

Anybody else a solution?

Tino

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: admin app doesn't find template

2009-12-08 Thread bruno desthuilliers
On 8 déc, 01:47, Xbiton  wrote:
(snip)
> unfortunately when I try to access the admin  interface I recive an
> error saiying me that ther's no template for the apps, even I added
> the template folder ti the TEMPLATE_DIRS.
>
> Now I wondering why, in the debug page of the django server I see that
> to the template path django automatically adds admin/login.html

Seems logical to add 'admin/login.html' if the template loader is
looking for a template named 'login.html' and supposed to live in a
directory named 'admin'.


> even
> the path I added to TEMPALTE_DIR was only /django-site/test/cms/
> templates/.

I'm not sure this is what you really have in your settings - the
traceback mentions
"/Users/xaver/Documents/django-site/test/cms/templates/admin/
login.html"

Also, you may want to re-read the doc for template loaders - you don't
need to explicitely specifify each and any installed app's 'templates'
dir in TEMPLATE_DIRS, the app_directories template_loader will
automatically search these directories.


> practically the complete path
>  django is searching is /django-site/test/cms/templates/admin/
> login.html
> is that right?


cf above.

Also and FWIW, I think there's something missing in your
INSTALLED_APPS - the admin app. You should probably fix this first.


> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.flatpages',
>  'cms.frontend']

(snip)

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 get/set from model

2009-12-08 Thread bruno desthuilliers
On 7 déc, 18:55, Waqqas Jabbar  wrote:
> I want that I could override get/set on a field of my model. I want to
> redirect get/set
> to another field of some other model.

So what you want is not "a field of your model", it's to expose
another field of another model as if it was an attribute of the
model ?

If yes, the first solution that comes to mind is a property (if you
don't know what a property is, it's time you learn Python) - but you
didn't provide enough informations to make sure this is really the
right solution.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 change default template name for django.views.defaults.page_not_found ?

2009-12-08 Thread David De La Harpe Golden
mateusz.szulc wrote:
>>From Django Part 3 tutorial:
> "The 404 view is also called if Django doesn't find a match after
> checking every regular expression in the URLconf."
> 
> The 404 default view in django is defined as:
> def page_not_found(request, template_name='404.html'):
> 
> How can I change the value of the template_name parameter?
> 

Well, in your project's base urls.py, put:

handler404 = 'myapp.views.page_not_found'
handler500 = 'myapp.views.server_error'

in your myapp/views.py:

from django.views.defaults import page_not_found as default_page_not_found
from django.views.defaults import server_error as default_server_error

# Use custom 404 and 500 handlers, just to override template names
def page_not_found(request, template_name='tomato404.html.djt'):
return default_page_not_found(request, template_name=template_name)

def server_error(request, template_name='tomato500.html.djt'):
return default_server_error(request, template_name=template_name)




--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 filter on foreign key

2009-12-08 Thread Daniel Roseman
On Dec 8, 2:47 am, GoSantoni  wrote:
> Guys, i'm struggling with this problem for more than a week now. My
> goal is to use a queryset filter with a foreign key.
> Issues are
> 1) column generates a list, what is the right way to get the blog id
> for a post? So whether the post belongs to blog  1 question or blog 2
> answer? Tried  Post.objects.get which fails...
> 2) howto define this in the template
>
> Any help/ directions are appreciated!
>
> ** First I created this model  with a foreign key
> **
> class blog(models.Model):
>     function_CHOICES = (
>         (1, _('question')),
>         (2, _('answer')),
>         )
>     function          = models.IntegerField(_('function'),
> choices=function_CHOICES, default=2)
>
>     def __unicode__(self):
>         return self.get_function_display()
>
> class Post(models.Model):
>     blog = models.ForeignKey(blog)
>
> * This is the view with the 'column definition'
> **
> def blogs(request, username=None, template_name="blog/blogs.html"):
>     blogs = Post.objects.filter(status=2).select_related
> (depth=1).order_by("-publish")
>     column = Post.objects.values(blog__id).select_related('blog')
>
>    if column == 1:
>      blogs = blogs.filter(author=user).exclude(column==2)
>
>    pass
>      blogs = blogs.filter(author=user).exclude(column==1)
>
>    return render_to_response(template_name, {
>        "blogs": blogs,
>    }, context_instance=RequestContext(request))
>
> * Template. Goal: create 2 columns filtered by whether column
> =1 or 2 
>
> 
> 
> 
>     {% if blogs %}
>         {% trans "These are blog posts from everyone:" %}
>       {% autopaginate blogs %}
>
>                             ** if column == 1 **
>             {% for blog_post in blogs %}
>             {% show_blog_post blog_post %}
>             {% endfor %}
>
>         {% paginate %}
>     {% else %}
>         {% trans "No blog posts yet." %}
>     {% endif %}
> 
> 
>     {% if blogs %}
>         {% trans "These are blog posts from everyone:" %}
>
>                            ** condition for passed data
> **
>       {% autopaginate blogs %}
>             {% for blog_post in blogs %}
>                 {% show_blog_post blog_post %}
>             {% endfor %}
>         {% paginate %}
>
>     {% else %}
>         {% trans "No blog posts yet." %}
>     {% endif %}
> 
> 
> 

It's really unclear what you are trying to do here. You haven't
allowed for any way to pass in a parameter to filter on, so you will
always get all blogs to start with (with posts filtered by user).
'Column' - ie blog id - is a property of *each post* in the queryset,
and will be different for different posts.

Is it just that you want to split them up into two columns depending
on the blog id? In which case, you could do it like this:

blogs_one = Post.objects.filter(author=user, blog__id=1)
blogs_two = Post.objects.filter(author=user, blog__id=2)

and then iterate through blogs_one and blogs_two in your template.

There will definitely be better ways of doing this, but without
understanding what you're trying to achieve I can't help further.
--
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-us...@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: CharField cannot have a "max_length" greater than 255 when using "unique=True"

2009-12-08 Thread bruno desthuilliers
On 7 déc, 23:46, germ  wrote:
> my platform: django 1.1.1, mysql 5.0.67, python 2.6.2
>
> why does syncdb complain
>  CharField cannot have a "max_length" greater than 255 when using
> "unique=True"
>
> when mysql 5.0.67 does allow greater tan 255? is there a way to
> override or ignore this error?
>
> this works in mysql
> mysql> create table mbg_test_1 (id int(5), url varchar(760) not null,
> primary key (id), unique (url));
> Query OK, 0 rows affected (0.00 sec)
>
>
> not sure why django hits this error since the true max length is 767,
> not 255:
>
> mysql> create table mbg_test_1 (url varchar(999) not null, unique (url));
> ERROR 1071 (42000): Specified key was too long; max key length is 767
> bytes

Are you sure you're using the same encoding (charset) in both cases ?
Note that the above message says "767 *bytes*", not 767 *characters*

Here is what I have (mysql 5.0.75):

mysql> create table mbg_test_1 (url varchar(767) not null, unique
(url)) CHARACTER SET utf8;
ERROR 1071 (42000): Specified key was too long; max key length is 1000
bytes

The point is that utf8 can use up to 3 bytes per character...

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Field in admin not editable but still visible

2009-12-08 Thread gentlestone
There are many posibilities:

1. Update the admin template for the app and model and include field
variable into appropriate block
2. Update the form in admin and include the field with editable=false
in widget properties
3. Update the view function and include a new value into template data

On 4. Dec., 14:56 h., grimmus  wrote:
> Hi,
>
> I have a hit_count integer field on my model with a default value of 0
>
> In the admin area i would like to show this field (to see the amount
> of hits) but make it not editable.
>
> Is there any easy built in way to do this ?
>
> Thanks for any tips.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




djangp translates does not work

2009-12-08 Thread Sameer Rahmani
hi
i use django internationalize documents to translate my project , but when i
use that i just see that only some string are translated and font direction
still is ltr , can any one help me to do it step by step?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.