Re: Problem importing model after inspectdb

2010-09-23 Thread Karen Tracey
On Thu, Sep 23, 2010 at 8:33 PM, Ivan  wrote:

> Hi all,
> I'm trying to build a Django project by working through the handbook
> but I'm having some problems accessing the database by referencing the
> model I've created from it (by inspectdb). When attemping to do some
> "Basic Data Access" (Chapter 5) I can't import the models I've made
> (from [app name].models import [model name]), with the console
> erroring 'ImportError: cannot import name [model name]'. I checked the
> models.py inspectdb made with 'python manage.py validate' and 'python
> manage.py syncdb' exits with 'No fixtures found'. I would appreciate
> any help I can get. Thanks
>
> Here is my models.py from my app:
> http://pastebin.ca/1947921
>
> And here is my settings.py
> http://pastebin.ca/1947922
>
>
Pastebin is not responding at present, so I cannot see what you have
provided. However as a general rule you are more likely to get helpful
responses if you show exactly what you have entered, and exactly what you
get in response. Do not replace key bits with [app name] and [model name],
and do cut/paste the actual output you get into the email and include it.
Having to guess what you might have really entered and how that might have
differed from what would work makes it a lot harder to try to help.

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

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

2010-09-23 Thread Karen Tracey
On Thu, Sep 23, 2010 at 10:09 PM, Katrina wrote:

> I am currently in the process of syncing my local copy of a Django app/
> project (the website is structured as one giant app plugged into a
> single project) with a development version that has undergone
> significant changes since I last worked on it in summer 2009.  When I
> attempt to view my copy of the site in my browser, I get the TypeError
> "int() argument must be a string or a number, not 'tuple' ".
>
> I am using Django 1.1.2 and Postgres w/ psycopg 2.2.2.  I have
> upgraded these from prior versions and moved them around on my
> computer a little, so it is possible that they are not all integrating
> properly. Any ideas about what could be causing this error?
>
> Thanks in advance for the help.  Here is the traceback:
>
> Traceback (most recent call last):
>  File "/Applications/django/trunk/django/core/servers/basehttp.py",
> line 674, in __call__
>return self.application(environ, start_response)
>  File "/Applications/django/trunk/django/core/handlers/wsgi.py", line
> 241, in __call__
>response = self.get_response(request)
>  File "/Applications/django/trunk/django/core/handlers/base.py", line
> 141, in get_response
>return self.handle_uncaught_exception(request, resolver,
> sys.exc_info())
>  File "/Applications/django/trunk/django/core/handlers/base.py", line
> 165, in handle_uncaught_exception
>return debug.technical_500_response(request, *exc_info)
>  File "/Applications/django/trunk/django/core/handlers/base.py", line
> 91, in get_response
>request.path_info)
>  File "/Applications/django/trunk/django/core/urlresolvers.py", line
> 249, in resolve
>for pattern in self.url_patterns:
>  File "/Applications/django/trunk/django/core/urlresolvers.py", line
> 278, in _get_url_patterns
>patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
>  File "/Applications/django/trunk/django/core/urlresolvers.py", line
> 273, in _get_urlconf_module
>self._urlconf_module = import_module(self.urlconf_name)
>  File "/Applications/django/trunk/django/utils/importlib.py", line
> 35, in import_module
>__import__(name)
>  File "[project path]/urls.py", line 10, in 
>from community.views import *
>  File "[app path]/views.py", line 35, in 
>from community.forms import *
>  File "[app path]/forms.py", line 214, in 
>class UserProfileForm(ModelForm):
>  File "[app path]/forms.py", line 218, in UserProfileForm
>communities = forms.ModelMultipleChoiceField(required=True,
> queryset=Community.objects.all(), widget=TableCheckboxWidget)
>  File "/Applications/django/trunk/django/db/models/manager.py", line
> 117, in all
>return self.get_query_set()
>  File "[app path]/models.py", line 1219, in get_query_set
>return super(CommunityManager,
> self).get_query_set().filter(pk__in=comms)
>

The ultimate exception you are getting indicates that this comms variable
contains items that are not simply integers, but rather tuples.

Karen

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

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



Problem with reversing url in test

2010-09-23 Thread Brandon Taylor
Hi everyone,

I'm having a problem with reversing a URL in a unit test:


class ProductTestCase(TestCase):
def setUp(self):
self.client = Client

def test_project_permalink(self):
project = Project.approved.all()[0]
url = project.get_absolute_url()


I'm using an initial_data.json fixture that I exported from my current
database, and I'm able to use the get_absolute_url method to navigate
to a project detail page without error.

When I try to reverse this url pattern in a test, I get a
NoReverseMatch exception. django-cms is also running on my site, but
disabling that app, and its url patterns doesn't make a difference.

Anyone have any ideas on why this method would fail?

TIA,
Brandon

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



subclassing UserCreationForm

2010-09-23 Thread Axel Bock
Hello all,

I must admit - I am going crazy. With something I thought should be
incredibly simple, but maybe I am just too f**king stupid.

All right, here comes my problem. I have subclassed "User" as "Student" and
added some required fields, one of them being "Course":

# models.py
class Student(User):
course = models.ForeignKey('Course')

So far, so good. Now I couldn't create a Student with an initial password -
the password field was plaintext, and the "change password" form wouldn't
work. I dug through the code and some postings, and discovered that if I
used a custom admin class it would just work fine, with the advantage that I
could exclude some fields I don't need in the admin view of the Students.
That basically looks like this:

# admin.py
class StudentAdmin(UserAdmin):
fieldsets = ( #...
)
admin.site.register(Student, StudentAdmin)
*
Then* I got another annoyance. If I tried to create a Student now, I was
confronted with the "usual" User creation screen. (Huh? ... ok, dig a bit in
Django internals, one can only learn ...). Basically I wouldnt mind, but the
Student creation does not work any more - the simple add user screen will of
course set no "course" value in the Student model, So I dug further. I
discovered that the user creation was handled by a form called
UserCreationForm, and this form explicitly excluded alot of stuff.

But now the magic went crazy. If I look at the UserCreationForm class, I
see:

class Meta:
model = User
fields = ("username",)

WTF? The only field which *should* be seen is "username", according to the
docs (according to
http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/). But there is
password AND username. Aha. I am pretty confused now. But not without
optimism. I tried subclassing the form now, which looked something like
this:

*class StudentCreationForm(UserCreationForm):
class Meta():
model = Student
fields = ('course')
*
class StudentAdmin(UserAdmin):
#fields = ('first_name', 'family_name', 'password', 'course', 'base')
fieldsets = ( # ... cut out
*add_form = StudentCreationForm*

And the result? No luck. WhatEVER I do (replacing UserCreationForm with
subclass of ModelForm, overriding get_form(), and some other things), the
form will only and inevitably show "username" and "password".

And it's about two hours now.

Help.

Please.


Thanks!
Axel.

-- 
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: Recommend a book

2010-09-23 Thread Ivan
Personally, I like hand on. "Practical Django Projects" is
recommended. http://apress.com/book/view/9781590599969



On Fri, Sep 24, 2010 at 12:38 PM, Tim Johnson  wrote:
> Thank you -
>  Shawn Milochik and Tran Cao Thai. :) thus far.
>  I'll check back in the morning.
>  cheers
> --
> Tim
> tim at johnsons-web.com or akwebsoft.com
> http://www.akwebsoft.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.
>
>

-- 
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: Operational Error 1060 Duplicate column name

2010-09-23 Thread Howard Wolf
I want the foreign key to be called taxonomy_kingdom.

So would I do something like this?

taxonomy_kingdom = models.ForeignKey(TaxonomyKingdom, null=True, blank=True)
superior=taxonomy_kingdom

On Thu, Sep 23, 2010 at 10:18 PM, Karen Tracey  wrote:

> On Thu, Sep 23, 2010 at 1:03 PM, Howard Wolf  wrote:
>
>> class TaxonomyPhylum(models.Model):
>>name = models.CharField(max_length=100, unique=True)
>>superior=taxonomy_kingdom = models.ForeignKey(TaxonomyKingdom,
>> null=True, blank=True)
>>
>
> Do you want that ForeignKey field to be named superior or taxonomy_kingdom?
> Right now you've got 2 equal signs in there, and somehow that is causing
> Django to try to create two columns with the 2nd name (taxonomy_kingdom_id).
>
> Karen
> --
> http://tracey.org/kmt/
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.
>



-- 

Howard Wolf, wolf18
Computer Science, University of Illinois, Urbana-Champaign
https://hwrdwlf18.homelinux.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.



Re: Newbie: Operational Error 1060 Duplicate column name

2010-09-23 Thread Karen Tracey
On Thu, Sep 23, 2010 at 1:03 PM, Howard Wolf  wrote:

> class TaxonomyPhylum(models.Model):
>name = models.CharField(max_length=100, unique=True)
>superior=taxonomy_kingdom = models.ForeignKey(TaxonomyKingdom,
> null=True, blank=True)
>

Do you want that ForeignKey field to be named superior or taxonomy_kingdom?
Right now you've got 2 equal signs in there, and somehow that is causing
Django to try to create two columns with the 2nd name (taxonomy_kingdom_id).

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

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

2010-09-23 Thread Tim Johnson
Thank you - 
  Shawn Milochik and Tran Cao Thai. :) thus far.
  I'll check back in the morning.
  cheers
-- 
Tim 
tim at johnsons-web.com or akwebsoft.com
http://www.akwebsoft.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.



Re: Recommend a book

2010-09-23 Thread Steven Elliott Jr
I have found beginning django e-commere as practical django projects to be 
great. Both from apress. I prefer to use books that go through building real 
world solutions. The definitive guide to django is a must read though. 

On Sep 23, 2010, at 9:57 PM, Tim Johnson  wrote:

> FYI: I'm an experienced python programmer, experienced web
> programmer, work mostly on linux platforms. And I like to
> start slow and get it down thoroughly. 
> 
> I'm soliciting recommendations for books on learning django. 
> E-book or paper. Paper is preferred.
> 
> I would prefer to avoid anything geared to a particular IDE.
> (I roll my own with either vim or emacs)
> 
> TIA
> -- 
> Tim 
> tim at johnsons-web.com or akwebsoft.com
> http://www.akwebsoft.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.
> 

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



Problem importing model after inspectdb

2010-09-23 Thread Ivan
Hi all,
I'm trying to build a Django project by working through the handbook
but I'm having some problems accessing the database by referencing the
model I've created from it (by inspectdb). When attemping to do some
"Basic Data Access" (Chapter 5) I can't import the models I've made
(from [app name].models import [model name]), with the console
erroring 'ImportError: cannot import name [model name]'. I checked the
models.py inspectdb made with 'python manage.py validate' and 'python
manage.py syncdb' exits with 'No fixtures found'. I would appreciate
any help I can get. Thanks

Here is my models.py from my app:
http://pastebin.ca/1947921

And here is my settings.py
http://pastebin.ca/1947922

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



TypeError upon page load

2010-09-23 Thread Katrina
I am currently in the process of syncing my local copy of a Django app/
project (the website is structured as one giant app plugged into a
single project) with a development version that has undergone
significant changes since I last worked on it in summer 2009.  When I
attempt to view my copy of the site in my browser, I get the TypeError
"int() argument must be a string or a number, not 'tuple' ".

I am using Django 1.1.2 and Postgres w/ psycopg 2.2.2.  I have
upgraded these from prior versions and moved them around on my
computer a little, so it is possible that they are not all integrating
properly. Any ideas about what could be causing this error?

Thanks in advance for the help.  Here is the traceback:

Traceback (most recent call last):
  File "/Applications/django/trunk/django/core/servers/basehttp.py",
line 674, in __call__
return self.application(environ, start_response)
  File "/Applications/django/trunk/django/core/handlers/wsgi.py", line
241, in __call__
response = self.get_response(request)
  File "/Applications/django/trunk/django/core/handlers/base.py", line
141, in get_response
return self.handle_uncaught_exception(request, resolver,
sys.exc_info())
  File "/Applications/django/trunk/django/core/handlers/base.py", line
165, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
  File "/Applications/django/trunk/django/core/handlers/base.py", line
91, in get_response
request.path_info)
  File "/Applications/django/trunk/django/core/urlresolvers.py", line
249, in resolve
for pattern in self.url_patterns:
  File "/Applications/django/trunk/django/core/urlresolvers.py", line
278, in _get_url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
  File "/Applications/django/trunk/django/core/urlresolvers.py", line
273, in _get_urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
  File "/Applications/django/trunk/django/utils/importlib.py", line
35, in import_module
__import__(name)
  File "[project path]/urls.py", line 10, in 
from community.views import *
  File "[app path]/views.py", line 35, in 
from community.forms import *
  File "[app path]/forms.py", line 214, in 
class UserProfileForm(ModelForm):
  File "[app path]/forms.py", line 218, in UserProfileForm
communities = forms.ModelMultipleChoiceField(required=True,
queryset=Community.objects.all(), widget=TableCheckboxWidget)
  File "/Applications/django/trunk/django/db/models/manager.py", line
117, in all
return self.get_query_set()
  File "[app path]/models.py", line 1219, in get_query_set
return super(CommunityManager,
self).get_query_set().filter(pk__in=comms)
  File "/Applications/django/trunk/django/db/models/query.py", line
550, in filter
return self._filter_or_exclude(False, *args, **kwargs)
  File "/Applications/django/trunk/django/db/models/query.py", line
568, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
  File "/Applications/django/trunk/django/db/models/sql/query.py",
line 1128, in add_q
can_reuse=used_aliases)
  File "/Applications/django/trunk/django/db/models/sql/query.py",
line 1071, in add_filter
connector)
  File "/Applications/django/trunk/django/db/models/sql/where.py",
line 66, in add
value = obj.prepare(lookup_type, value)
  File "/Applications/django/trunk/django/db/models/sql/where.py",
line 299, in prepare
return self.field.get_prep_lookup(lookup_type, value)
  File "/Applications/django/trunk/django/db/models/fields/
related.py", line 136, in get_prep_lookup
return [self._pk_trace(v, 'get_prep_lookup', lookup_type) for v in
value]
  File "/Applications/django/trunk/django/db/models/fields/
related.py", line 196, in _pk_trace
v = getattr(field, prep_func)(lookup_type, v, **kwargs)
  File "/Applications/django/trunk/django/db/models/fields/
__init__.py", line 294, in get_prep_lookup
return [self.get_prep_value(v) for v in value]
  File "/Applications/django/trunk/django/db/models/fields/
__init__.py", line 479, in get_prep_value
return int(value)
TypeError: int() argument must be a string or a number, not 'tuple'

-- 
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: Recommend a book

2010-09-23 Thread Shawn Milochik
I recommend "The Definitive Guide to Django," without reservation.  

See my review for more details:
http://www.amazon.com/review/R2ET5WRO205C9I/ref=cm_cr_rdp_perm

Ignore anyone who says it's outdated. Some people are thrown into fits of 
despair when a book's cover has a title that's 0.1 less than the latest 
release. Let them wallow. 

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: Recommend a book

2010-09-23 Thread Tran Cao Thai
Learning Website Development with Django: A be (ginner's tutorial to
building web applications, quickly and cleanly, with the Django application
framework ( *ISBN-13:* 978-1847193353)
The only one django book that i like. Give the reader a comprehensive look
for django framework (though it is about django 0.9) and doen't not cover
boring projects like creating a blog (which u can easily find from the
django website). There is a ebook version as well.

I also found that the django channel on irc is extremely useful for those
who want to learn django. People there are very nice and friendly


On Fri, Sep 24, 2010 at 11:57 AM, Tim Johnson  wrote:

> FYI: I'm an experienced python programmer, experienced web
> programmer, work mostly on linux platforms. And I like to
> start slow and get it down thoroughly.
>
> I'm soliciting recommendations for books on learning django.
> E-book or paper. Paper is preferred.
>
> I would prefer to avoid anything geared to a particular IDE.
> (I roll my own with either vim or emacs)
>
> TIA
> --
> Tim
> tim at johnsons-web.com or akwebsoft.com
> http://www.akwebsoft.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.
>
>

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



Call for proposals -- PyCon 2011

2010-09-23 Thread Jacob Kaplan-Moss
Call for proposals -- PyCon 2011 -- 
===

Proposal Due date: November 1st, 2010

PyCon is back! With a rocking new website, a great location and
more Python hackers and luminaries under one roof than you could
possibly shake a stick at. We've also added an "Extreme" talk
track this year - no introduction, no fluff - only the pure
technical meat!

PyCon 2011 will be held March 9th through the 17th, 2011 in Atlanta,
Georgia. (Home of some of the best southern food you can possibly
find on Earth!) The PyCon conference days will be March 11-13,
preceded by two tutorial days (March 9-10), and followed by four
days of development sprints (March 14-17).

PyCon 2011 is looking for proposals for the formal presentation
tracks (this includes "extreme talks"). A request for proposals for
poster sessions and tutorials will come separately.

Want to showcase your skills as a Python Hacker? Want to have
hundreds of people see your talk on the subject of your choice? Have
some hot button issue you think the community needs to address, or have
some package, code or project you simply love talking about? Want to
launch your master plan to take over the world with Python?

PyCon is your platform for getting the word out and teaching something
new to hundreds of people, face to face.

In the past, PyCon has had a broad range of presentations, from reports
on academic and commercial projects, tutorials on a broad range of
subjects, and case studies. All conference speakers are volunteers and
come from a myriad of backgrounds: some are new speakers, some have been
speaking for years. Everyone is welcome, so bring your passion and your
code! We've had some incredible past PyCons, and we're looking to you to
help us top them!

Online proposal submission is open now! Proposals  will be accepted
through November 10th, with acceptance notifications coming out by
January 20th. To get started, please see:

   

For videos of talks from previous years - check out:

   

For more information on "Extreme Talks" see:

   

We look forward to seeing you in Atlanta!

Please also note - registration for PyCon 2011 will also be capped at a
maximum of 1,500 delegates, including speakers. When registration opens
(soon), you're going to want to make sure you register early! Speakers
with accepted talks will have a guaranteed slot.

Important Dates:
   * November 1st, 2010: Talk proposals due.
   * December 15th, 2010: Acceptance emails sent.
   * January 19th, 2010: Early bird registration closes.
   * March 9-10th, 2011: Tutorial days at PyCon.
   * March 11-13th, 2011: PyCon main conference.
   * March 14-17th, 2011: PyCon sprints days.

Contact Emails:
   Van Lindberg (Conference Chair) - v...@python.org
   Jesse Noller (Co-Chair) - jnol...@python.org
   PyCon Organizers list: pycon-organiz...@python.org

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



Recommend a book

2010-09-23 Thread Tim Johnson
FYI: I'm an experienced python programmer, experienced web
programmer, work mostly on linux platforms. And I like to
start slow and get it down thoroughly. 

I'm soliciting recommendations for books on learning django. 
E-book or paper. Paper is preferred.

I would prefer to avoid anything geared to a particular IDE.
(I roll my own with either vim or emacs)

TIA
-- 
Tim 
tim at johnsons-web.com or akwebsoft.com
http://www.akwebsoft.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.



Re: Image Upload question

2010-09-23 Thread Joel Klabo
The problem was no PIL and libjpeg...

On Sep 23, 2:43 pm, Joel Klabo  wrote:
> from the django docs:
>
> inherits all attributes and methods from FileField, but also validates
> that the uploaded object is a VALID IMAGE.
>
> what does valid image mean?
>
> On Sep 23, 2:40 pm, Joel Klabo  wrote:
>
>
>
> > Thanks, upload is now working. But, only for smallish .png files, what
> > are the constraints on file type and size django sets? I can't find
> > the information anywhere? Beyond that, can I set them myself?
>
> > On Sep 23, 1:41 pm, Peter Bengtsson  wrote:
>
> > > By being bound it means that you will have run the .is_valid() method
> > > of the form instance once you've instanciated it with your POST and
> > > FILES data.
> > > E.g.
> > > form = BrewImageFrom(data=request.POST, files=request.FILES)
> > > if form.is_valid():
> > >     brewimage = form.save()
>
> > > On Sep 23, 3:00 pm, Joel Klabo  wrote:
>
> > > > I have a form trying to upload an image. In the docs it says that the
> > > > form must be bound to save a file. This is an issue for me because I
> > > > wan't to save the file with other data such as the User object that
> > > > saved it. I can't put a User object in a form so I put the username in
> > > > a hidden form field which allows me to find the user in the view and
> > > > use it. But, I can't bind the form with data not from POST right? I
> > > > need to do request.FILES, in combination with data not coming from
> > > > post. I'm obviously confused I would appreciate some guidance here
>
> > > > Here's the code:http://gist.github.com/594136

-- 
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: Can I run tests without installing indexes?

2010-09-23 Thread Russell Keith-Magee
On Fri, Sep 24, 2010 at 4:51 AM, Peter Bengtsson  wrote:
> When not using SQLite for running my tests it takes a aweful long time
> to install all the indexes.
> Considering that indexes are there for speeding up selects when the
> number of rows is very high I realise I don't need them during a test
> run.
>
> Is there a way to disable index creation during the syncdb?

Not easily. You could write a custom database backend that overrides
the index creation SQL calls, but that's a bit heavyweight for what
you're looking to do.

However, it is an interesting area for optimization for the test
suite. It's entirely possible that the overhead of constructing and
maintaining the indicies is much higher than the benefit gained by
having them; it's worth looking into whether dropping index creation
can speed up the test suite.

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: Why Django Apps Suck

2010-09-23 Thread Russell Keith-Magee
On Fri, Sep 24, 2010 at 1:41 AM, Yo-Yo Ma  wrote:
> Hey Russell,
>
> Do you think a round table discussion in a real person context with
> whiteboards and the best of the bunch (ie, at Django con or similar
> event) would be a good time/place to re architecture of the
> abstraction layers, perhaps to address some of the concerns brought up
> in the slide show by Eric? By abstraction layers I don't just refer to
> the "app" (which I don't see to be a problem as much as others do,
> although I don't like how so many apps have models in them). I'm also
> referring to things like; putting global functionality into urls.py,
> tight coupling of built-in apps, etc.

Sure. However, Djangocon 2010 finished a week ago, so you're going to
have to wait until next year before we have the next serious
opportunity to do this.

It also helps to have a concrete proposal on the table, rather than
just a bunch of abstract "hey this sucks"  bullet points.

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: Image Upload question

2010-09-23 Thread Joel Klabo
from the django docs:

inherits all attributes and methods from FileField, but also validates
that the uploaded object is a VALID IMAGE.

what does valid image mean?

On Sep 23, 2:40 pm, Joel Klabo  wrote:
> Thanks, upload is now working. But, only for smallish .png files, what
> are the constraints on file type and size django sets? I can't find
> the information anywhere? Beyond that, can I set them myself?
>
> On Sep 23, 1:41 pm, Peter Bengtsson  wrote:
>
>
>
> > By being bound it means that you will have run the .is_valid() method
> > of the form instance once you've instanciated it with your POST and
> > FILES data.
> > E.g.
> > form = BrewImageFrom(data=request.POST, files=request.FILES)
> > if form.is_valid():
> >     brewimage = form.save()
>
> > On Sep 23, 3:00 pm, Joel Klabo  wrote:
>
> > > I have a form trying to upload an image. In the docs it says that the
> > > form must be bound to save a file. This is an issue for me because I
> > > wan't to save the file with other data such as the User object that
> > > saved it. I can't put a User object in a form so I put the username in
> > > a hidden form field which allows me to find the user in the view and
> > > use it. But, I can't bind the form with data not from POST right? I
> > > need to do request.FILES, in combination with data not coming from
> > > post. I'm obviously confused I would appreciate some guidance here
>
> > > Here's the code:http://gist.github.com/594136

-- 
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: Image Upload question

2010-09-23 Thread Joel Klabo
Thanks, upload is now working. But, only for smallish .png files, what
are the constraints on file type and size django sets? I can't find
the information anywhere? Beyond that, can I set them myself?

On Sep 23, 1:41 pm, Peter Bengtsson  wrote:
> By being bound it means that you will have run the .is_valid() method
> of the form instance once you've instanciated it with your POST and
> FILES data.
> E.g.
> form = BrewImageFrom(data=request.POST, files=request.FILES)
> if form.is_valid():
>     brewimage = form.save()
>
> On Sep 23, 3:00 pm, Joel Klabo  wrote:
>
>
>
> > I have a form trying to upload an image. In the docs it says that the
> > form must be bound to save a file. This is an issue for me because I
> > wan't to save the file with other data such as the User object that
> > saved it. I can't put a User object in a form so I put the username in
> > a hidden form field which allows me to find the user in the view and
> > use it. But, I can't bind the form with data not from POST right? I
> > need to do request.FILES, in combination with data not coming from
> > post. I'm obviously confused I would appreciate some guidance here
>
> > Here's the code:http://gist.github.com/594136

-- 
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: reverse ForeignKey

2010-09-23 Thread Vali Lungu
Hi,

You may be interested in this:
http://stackoverflow.com/questions/2618893/how-to-filter-queryset-in-changelist-view-in-django-admin,
looks like a similar (solved) problem.
In short, it's about overriding the queryset() method of ModelAdmin.

On Thu, Sep 23, 2010 at 11:33 AM, ionut cristian cucu
wrote:

> Hi list,
> I just came to django, and to web programming for that matter, so my
> question is from a n0b:
> I have to models:
> class Pacient(models.Model):
> name=models.CharField('name', max_length=123)
> 
> class Exit(models.Model):
>  pacient=models.ForeignKey(Pacient)
> 
>
> How to I get the admin interface to show only the pacients for whom I
> have no exit objects.
> Rephrase: if I have an Exit object for a Pacient, I don't want that
> Pacient object to show up
> 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.



encrypted model field

2010-09-23 Thread adrian

I want this field to be saved encrypted in the db, but appear
unencrypted everywhere else.My question is which combination of
field methods should I use?

I have gotten parts of this working with various combinations of the
methods below, but can't get it all to work.   Using one method makes
modelform save work, but then I can't access the field
directly with model.secret because it is still encrypted.   If I use
the to_python method, I can
access the field with model.secret but the modelform handling breaks.

class EncryptedCharField(models.CharField):
__metaclass__ = models.SubfieldBase

def save_form_data(self, instance, data):
setattr(instance, self.name, encrypt(data))

def value_from_object(self, obj):
return decrypt(getattr(obj, self.attname))

#def to_python(self, value):
#return decrypt(value)

class MyModel(models.Model):
 secret = EncryptedCharField(max_length=100)

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



Can I run tests without installing indexes?

2010-09-23 Thread Peter Bengtsson
When not using SQLite for running my tests it takes a aweful long time
to install all the indexes.
Considering that indexes are there for speeding up selects when the
number of rows is very high I realise I don't need them during a test
run.

Is there a way to disable index creation during the syncdb?

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



encrypted model field

2010-09-23 Thread adrian

I want this field to be saved encrypted in the db, but appear
unencrypted everywhere else:

class EncryptedCharField(models.CharField):
__metaclass__ = models.SubfieldBase

def save_form_data(self, instance, data):
setattr(instance, self.name, encrypt(data))

#def get_prep_value(self, value):
#return encrypt(data)

def value_from_object(self, obj):
return decrypt(getattr(obj, self.attname))

#def to_python(self, value):
#return decrypt(value)

class MyModel(models.Model):
 secret = EncryptedCharField(max_length=100)

When this field is used in modelforms it works just fine: it is shown
with its decrypted length and saved encrypted.   However when secret
is accessed, such as:

object = MyModel.objects.get()

-- 
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: Image Upload question

2010-09-23 Thread Peter Bengtsson
By being bound it means that you will have run the .is_valid() method
of the form instance once you've instanciated it with your POST and
FILES data.
E.g.
form = BrewImageFrom(data=request.POST, files=request.FILES)
if form.is_valid():
brewimage = form.save()



On Sep 23, 3:00 pm, Joel Klabo  wrote:
> I have a form trying to upload an image. In the docs it says that the
> form must be bound to save a file. This is an issue for me because I
> wan't to save the file with other data such as the User object that
> saved it. I can't put a User object in a form so I put the username in
> a hidden form field which allows me to find the user in the view and
> use it. But, I can't bind the form with data not from POST right? I
> need to do request.FILES, in combination with data not coming from
> post. I'm obviously confused I would appreciate some guidance here
>
> Here's the code:http://gist.github.com/594136

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



Apache crashes on the latest trunk

2010-09-23 Thread Ramdas S
We run a dedicated server with several django sites with low volume,
but critical user traffic. Since upgrading to the latest trunk 1.2.3
we have started noticing that apache hangs very often. Curiously it
does not throw up any error in the apache.log. Apache does not crash,
but simply stops serving pages. There were a couple of sites which had
some deprecation error warnings. And one site had the
Flatpage.middleware present in middleware classes, but
contrib.flatpages was missing. I've fixed all these. Now only thing
remains is some deprecation warning coming from Python-mysqldb because
we run python 2.6.5, Yet the crashes continue.

We run Ubuntu 9.04, kernel, and all patches updated to the latest, and
django is the latest trunk.

Any advise, tips, directions is most helpful.

Mind you, the server was stable for over a year now, with absolutely
no issues. The problems have been noticed since we moved from 1.2.1 to
1.2.3, though I cannot ascertain whether that caused the issues.

We run Python modwsgi

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



Image Upload question

2010-09-23 Thread Joel Klabo
I have a form trying to upload an image. In the docs it says that the
form must be bound to save a file. This is an issue for me because I
wan't to save the file with other data such as the User object that
saved it. I can't put a User object in a form so I put the username in
a hidden form field which allows me to find the user in the view and
use it. But, I can't bind the form with data not from POST right? I
need to do request.FILES, in combination with data not coming from
post. I'm obviously confused I would appreciate some guidance here

Here's the code: http://gist.github.com/594136

-- 
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-registration vs django-account + django-url | opinions?

2010-09-23 Thread justin jools
I have tried out django-registration and liked the simplicity of it,

but following the pinax project, (and using their apps to instruct my
own build) I see they use:

django-account which also requires django-url

I have started just started playing with it and was wondering if
anyone has any opinions of using django-account over django-
registration?
Is one more flexible/has more features?

Pinax must have some reason for choosing this app over the impressive
django-registration

appreciate your feedback


-- 
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 Accounts - User account 'component'

2010-09-23 Thread piz...@gmail.com

El 23/09/2010, a las 18:04, Guiga escribió:


Hi guys,

I'd like to know if django have a "component" (or some like this) to
create, edit and login user's accounts. I mean, some like a system
user accounts to work with django.


Django has a built-in module called "auth" for managing users  
(preferences, login, logout, etc). Take a look to http:// 
docs.djangoproject.com/en/dev/topics/auth/




--
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 nested references

2010-09-23 Thread Marc Aymerich
On Thu, Sep 23, 2010 at 7:37 PM, Daniel Roseman wrote:

> On Sep 23, 6:26 pm, Marc Aymerich  wrote:
> > Hi
> > I'm trying to define two clases, one of them is a relational class
> between
> > services and users, so it has two foreign keys, one to services and
> another
> > to the user. On the other hand every service must have at least a default
> > tariff, so it has a "pointer" to it. However, I'm not sure how to declare
> > it, as i can not reference the class that is still to be defined. Do you
> > have any suggestion?
> >
> > class service(models.Model):
> > name = models.CharField(max_length=128)
> > default_tariff = models.OneToOneField(tariff)
> >
> > class tariff(models.Model):
> > service = models.ForeignKey(service)
> > user = models.ForeignKey(User)
> > price = models.CharField(max_length=64)
> >
> > Thanks a lot.
> > --
> > Marc
>
> http://docs.djangoproject.com/en/1.2/ref/models/fields/#lazy-relationships
> --
> DR.
>
>
Thanks for that daniel!!

-- 
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: Why Django Apps Suck

2010-09-23 Thread Yo-Yo Ma
Hey Russell,

Do you think a round table discussion in a real person context with
whiteboards and the best of the bunch (ie, at Django con or similar
event) would be a good time/place to re architecture of the
abstraction layers, perhaps to address some of the concerns brought up
in the slide show by Eric? By abstraction layers I don't just refer to
the "app" (which I don't see to be a problem as much as others do,
although I don't like how so many apps have models in them). I'm also
referring to things like; putting global functionality into urls.py,
tight coupling of built-in apps, etc.


Michael

On Sep 23, 5:40 am, Russell Keith-Magee 
wrote:
> On Thu, Sep 23, 2010 at 5:55 PM, Klaas van Schelven
>
>  wrote:
> > On Sep 23, 2:01 am, Russell Keith-Magee 
> > wrote:
>
> > So, we run into a few problems:
> > * How do we extend the models from the original extendible
> > application?
> > For this to work, we need to provide hooks in the application for
> > extendiblity. In the case of models, such a hook would be twofold:
> > 1. an abstract model to extend to provide a baseline (a default with
> > the minimum amount of fields)
> > 2. something overridable that is referred to by the rest of our app,
> > providing the concrete instance of [1] in the plain vanilla app, and
> > the concrete instance plus extensions in our extended app. (the actual
> > hook)
>
> Sure. Abstract models form the first part of this; the 'reference to
> the concrete instance' is a known problem -- the most obvious example
> of this surfacing is defining a custom User class to use in
> contrib.auth. Alex provides one possible solution (join models) in his
> talk; another (LazyForeignKey) was raised by Eric Florenzano in his
> keynote [1]. However, this is still very much an open area of debate.
> Any suggestions are welcome.
>
> [1]http://djangocon.blip.tv/file/4112452/
>
>
>
> > * how do we refer to ourselves from the various parts of the
> > extendible application?
> > Self-referral with overrides is a solved problem in the object
> > oriented world ("inheritance"). However, it's impossible in Django's
> > standard way of organizing apps, because we all use modules (not
> > classes or instances) for the various parts of the app ("models.py",
> > "views.py" etc).
> > It is not possible to pass context into a module (other than monkey
> > patching it)
>
> > Every views.py begins with a bunch of imports from the associated
> > models.py, tying the views into those particular app's models. My
> > alternative would be like so:
>
> > class View(...):
> >  def page_detail(self, request, pk=None):
> >    page = self.models.Page.objects.get(pk=pk)
> >    return render_to_response( page ...)
>
> > For models:
>
> > class Models(...):
> >  def get_Page(self):
> >    class Page(models.Model):
> >       #abstract
> >       category = models.ForeignKey(self.models.Category)
> >    return Page
> >  Page = property(get_Page)
>
> > (The above is a bit less elegant than the views example because models
> > are classes and the following therefor does not work:)
>
> > class Models(...)
> >  class Page(self, model.Model):
> >     ...
> >     category = models.ForeignKey(self.models.Category)
>
> > If anyone has an example of how to do this without a property I'd be
> > much obliged.
>
> Sure. There's at least two approaches. The first -- a method based
> approach -- is used by contrib.auth (amongst others):
>
> def my_view(request, arg1, arg2, klass=Page):
>     objects = klass.objects.filter(arg1=arg1, arg2=arg2)
>     ...
>
> The second is the class based approach, used by contrib.admin (and
> others), which is to define a class-based view, and provide methods
> like get_objects() that you can subclass to perform whatever behaviour
> you need.
>
> > Views.py methods generally have two types of parameters:
> > 1. Those that are passed in via urls.py from the request path. Love
> > 'em, couldn't live without 'em. This is what you're talking about.
> > 2. Those we add (with usefull defaults) to make our app "reusable".
> > What I was saying, is that I consider these in particular as unusable
> > in the general sense. If I subclass the idea of address in an address
> > book app (to add some field), would it make sense to refer to the
> > subclassed address class in every call to every single view function?
> > I'd say no. I'd rather say "give me my views where each view
> > understands that it should use the improved address class).
>
> Sure. And that's why you use class-based views. That's why Django's
> admin is a class.
>
> That's also why Django is in the process of getting a class-based view
> framework - again, from DjangoCon, see Ben Firshman's talk [2]
>
> [2]http://blip.tv/file/4109272
>
> 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 

Re: How to avoid nested references

2010-09-23 Thread Daniel Roseman
On Sep 23, 6:26 pm, Marc Aymerich  wrote:
> Hi
> I'm trying to define two clases, one of them is a relational class between
> services and users, so it has two foreign keys, one to services and another
> to the user. On the other hand every service must have at least a default
> tariff, so it has a "pointer" to it. However, I'm not sure how to declare
> it, as i can not reference the class that is still to be defined. Do you
> have any suggestion?
>
> class service(models.Model):
>     name = models.CharField(max_length=128)
>     default_tariff = models.OneToOneField(tariff)
>
> class tariff(models.Model):
>     service = models.ForeignKey(service)
>     user = models.ForeignKey(User)
>     price = models.CharField(max_length=64)
>
> Thanks a lot.
> --
> Marc

http://docs.djangoproject.com/en/1.2/ref/models/fields/#lazy-relationships
--
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.



Django Accounts - User account 'component'

2010-09-23 Thread Guiga
Hi guys,

I'd like to know if django have a "component" (or some like this) to
create, edit and login user's accounts. I mean, some like a system
user accounts to work with django.

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.



How to avoid nested references

2010-09-23 Thread Marc Aymerich
Hi
I'm trying to define two clases, one of them is a relational class between
services and users, so it has two foreign keys, one to services and another
to the user. On the other hand every service must have at least a default
tariff, so it has a "pointer" to it. However, I'm not sure how to declare
it, as i can not reference the class that is still to be defined. Do you
have any suggestion?

class service(models.Model):
name = models.CharField(max_length=128)
default_tariff = models.OneToOneField(tariff)

class tariff(models.Model):
service = models.ForeignKey(service)
user = models.ForeignKey(User)
price = models.CharField(max_length=64)

Thanks a lot.
-- 
Marc

-- 
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: Operational Error 1060 Duplicate column name

2010-09-23 Thread Howard Wolf
I deleted the database and installed a new one with no tables at all.
Using regular Python I ran the script manage.py with subcommand
syncdb. It created the first 4 tables then hit an error. Here is the
traceback for the error.
Traceback (most recent call last):
  File "manage.py", line 32, in 
execute_manager(settings)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 438, in execute_manager utility.execute()
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 191, in run_from_argv self.execute(*args,
**options.__dict__)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 218, in execute output = self.handle(*args, **options)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 347, in handle  return self.handle_noargs(**options)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
commands/syncdb.py", line 95, in handle_noargs
cursor.execute(statement)
  File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
mysql/base.py", line 86, in execute return self.cursor.execute(query,
args)
  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in
executeself.errorhandler(self, exc, value)
  File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line
35,in default errorhandler  raise errorclass, errorvalue
OperationalError: (1060, "Duplicate column name
'taxonomy_kingdom_id'")
Does this mean that when it tries to create the table
slide_taxonomykingdom there is already a column with "id" and its
trying to make another one?

Here is the Python code that creates the two associated tables:

class TaxonomyKingdom(models.Model):
name = models.CharField(max_length=100, unique=True)
superior=0

def __unicode__(self):
return '%s' % (self.name)

class TaxonomyPhylum(models.Model):
name = models.CharField(max_length=100, unique=True)
superior=taxonomy_kingdom = models.ForeignKey(TaxonomyKingdom,
null=True, blank=True)

def __unicode__(self):
return '%s' % (self.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: Newbie: Operational Error 1060 Duplicate column name

2010-09-23 Thread Howard Wolf
I delete the database and installed a new one with no tables at all.
Using regular Python I ran the script manage.py with subcommand syncdb
It created the first 4 tables then hit an error. Here is the traceback
for the error.

Traceback (most recent call last):
  File "manage.py", line 32, in 
execute_manager(settings)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 438, in execute_manager
utility.execute()
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 218, in execute
output = self.handle(*args, **options)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 347, in handle
return self.handle_noargs(**options)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
commands/syncdb.py", line 95, in handle_noargs
cursor.execute(statement)
  File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
mysql/base.py", line 86, in execute
return self.cursor.execute(query, args)
  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in
execute
self.errorhandler(self, exc, value)
  File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35,
in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1060, "Duplicate column name
'taxonomy_kingdom_id'")

Does this mean that when it tries to create the table
slide_taxonomykingdom there is already a column with "id" and its
trying to make another one?

-- 
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: Operational Error 1060 Duplicate column name

2010-09-23 Thread Howard Wolf
It was a IPython internal 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: Help with file upload using ModelForm

2010-09-23 Thread Federico Capoano
Sorry ignore this.

Changed from:
form = PdfForm(
initial ={
'name': pdf.name,
'description': pdf.description,
'file': pdf.file,
}
)

to:
form = PdfForm(instance = pdf)

and it works fine.


On 23 Set, 17:43, Federico Capoano  wrote:
> Hello to all,
>
> maybe is something really silly, but I don't get it.
>
> I'm using ModelForm to edit a database object that has a file input.
>
> The  tag has enctype="multipart/form-data" and the view uses
> request.FILES.
>
> I can add and edit files without problems, but there is a case in
> which editing a file does not work:
> when I don't want to change the file I simply leave the field blank
> and I get a validation error saying that the file field is required.
>
> What am I missing?

-- 
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 file upload using ModelForm

2010-09-23 Thread Federico Capoano
Hello to all,

maybe is something really silly, but I don't get it.

I'm using ModelForm to edit a database object that has a file input.

The  tag has enctype="multipart/form-data" and the view uses
request.FILES.

I can add and edit files without problems, but there is a case in
which editing a file does not work:
when I don't want to change the file I simply leave the field blank
and I get a validation error saying that the file field is required.

What am I missing?

-- 
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: Relationship between multiple sites & projects, apps

2010-09-23 Thread Brian Bouterse
We've got 4 domain names which all comprise a single website.  We went with
the second option where each domain is its own django project with a single
app in it.  We liked this option for two reasons.

1)  We wanted apache virtual hosts to be handling the decision about which
entry point to use instead of directing all traffic to a single django
project and letting the python (which we believe to be less performance
optimized than the apache method).  This was a performance decision.

2)  We also wanted the ability to flexibly grow the infrastructure backing
different domains.  Basically it is easier for us to handle traffic to
different areas of our site since we can always break out more servers to
handle different virtual hosts.  If it was all one django project I don't
think you could allocate infrastructure this granularly.

my 2 cents, but I'd love to hear what others think about these things

Brian

On Thu, Sep 23, 2010 at 5:00 AM, Benedict Verheyen <
benedict.verhe...@gmail.com> wrote:

> Hi,
>
>
> it's not exactly clear to me how the sites, projects and apps need to be
> structured.
>
> For instance, if you have 2 sites both with a domain name, how would you
> structure
> this in Django?
> The Django project could be called "mysites" or whatever name.
> In the admin site, you would then have 2 sites. So far so good.
> But how would you represent the sites?
> Do you make an application per site as each site could do something
> specific.
> Then you end up with this structure.
> Is this how it is meant to be?
> -- mysites (project)
> -- site 1 (app)
> -- site 2 (app)
>
> The only downside might be if both sites have loads of users, they are all
> displayed in the same list
> in the admin interface.
> Also, if you couple this with django-registration, it might not be that
> simple to let a user register
> for site 1 as well as site 2. I have no practical experience with
> django-registration but it seems
> like something i would use in the future.
>
> Or is it better to split the sites over 2 projects, so you have a project
> per site?
> -- site 1 (project)
> -- site 1 (app)
> -- site 2 (project)
> -- site 2 (app)
>
>
> Thanks for any insights,
> Regards,
> Benedict
>
> --
> 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.
>
>


-- 
Brian Bouterse
ITng Services

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



InterfaceError at /admin/ Error binding parameter 1 - probably unsupported type.

2010-09-23 Thread justin jools
Have searched everywhere for solution to this error (below) when
loggin in to admin

I also get this error during form post rediect, thinking it it
something to do with intalled apps/middleware or post setting maybe
but dont know what. Anyone come across this? Many Thanks


InterfaceError at /admin/
Error binding parameter 1 - probably unsupported type.Request Method:
POST

Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.3 pre-alpha
Exception Type: InterfaceError
Exception Value: Error binding parameter 1 - probably unsupported
type.
Exception Location: C:\Python26\lib\site-packages\django\db\backends
\sqlite3\base.py in execute, line 200
Python Executable: C:\Python26\python.exe
Python Version: 2.6.4

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.3 pre-alpha
Python Version: 2.6.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.humanize',
 'django.contrib.messages',
 'django.contrib.admin',
 'registration',
 'notification',
 'messages',
 'templatetags',
 'account',
 'django_openid',
 'openid',
 'announcements',
 'basic_profiles',
 'signup_codes',
 'authsub',
 'autocomplete_app',
 'uni_form',
 'core',
 'emailconfirmation',
 'about']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django_openid.consumer.SessionConsumer',
 'account.middleware.LocaleMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'pagination.middleware.PaginationMiddleware')


Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
wrapper
  207. return self.admin_view(view, cacheable)(*args,
**kwargs)
File "C:\Python26\lib\site-packages\django\utils\decorators.py" in
_wrapped_view
  76. response = view_func(request, *args,
**kwargs)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
  69. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
inner
  189. return self.login(request)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
  69. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
login
  342. login(request, user)
File "C:\Python26\lib\site-packages\django\contrib\auth\__init__.py"
in login
  69. user.save()
File "C:\Python26\lib\site-packages\django\db\models\base.py" in save
  434. self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
File "C:\Python26\lib\site-packages\django\db\models\base.py" in
save_base
  542. created=(not record_exists), raw=raw,
using=using)
File "C:\Python26\lib\site-packages\django\dispatch\dispatcher.py" in
send
  162. response = receiver(signal=self, sender=sender,
**named)
File "C:\django\pinax_rip\apps\account\models.py" in create_account
  67. account, created =
Account.objects.get_or_create(user=instance)
File "C:\Python26\lib\site-packages\django\db\models\manager.py" in
get_or_create
  135. return self.get_query_set().get_or_create(**kwargs)
File "C:\Python26\lib\site-packages\django\db\models\query.py" in
get_or_create
  373. obj.save(force_insert=True, using=self.db)
File "C:\Python26\lib\site-packages\django\db\models\base.py" in save
  434. self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
File "C:\Python26\lib\site-packages\django\db\models\base.py" in
save_base
  527. result = manager._insert(values,
return_id=update_pk, using=using)
File "C:\Python26\lib\site-packages\django\db\models\manager.py" in
_insert
  195. return insert_query(self.model, values, **kwargs)
File "C:\Python26\lib\site-packages\django\db\models\query.py" in
insert_query
  1480. return
query.get_compiler(using=using).execute_sql(return_id)
File "C:\Python26\lib\site-packages\django\db\models\sql\compiler.py"
in execute_sql
  783. cursor = super(SQLInsertCompiler,
self).execute_sql(None)
File "C:\Python26\lib\site-packages\django\db\models\sql\compiler.py"
in execute_sql
  727. cursor.execute(sql, params)
File "C:\Python26\lib\site-packages\django\db\backends\util.py" in
execute
  15. return self.cursor.execute(sql, params)
File "C:\Python26\lib\site-packages\django\db\backends
\sqlite3\base.py" in execute
  200. return 

Custom Exception question

2010-09-23 Thread Mike Pelley
Hello folks,

I'm somewhat new to python and very new to Django.  I'm trying to do
things "the right way" and I've encountered a problem.

At this point early in my project, all of my work has been to
customize the admin interface.  For one of the databases, there is an
admin option to retrieve a new version of the data from an external
source.

In models.py, I added a custom exception to a new class ModelPlus, and
all models extend this class.  It mostly works, but this line:

self.error = "Retrieve Error: %s" % e

does not work, in that self.error ends up as "Retrieve Error: ".  If I
change "e" to "e.reason", it works fine.  Could someone tell me why e
does not give me the string as intended?

I've included a bit of the code below as a reference.

Thanks very much,
Mike.


In "models.py":


class ModelPlus(models.Model):
"""Add helper methods to all models."""

class Meta:
abstract = True

def __unicode__(self):
if hasattr(self, 'name'):
return self.name
else:
return self.id

class RetrieveError(Exception):
def __init__(self, reason):
self.reason = reason
def __unicode__(self):
return self.reason


class TopList(ModelPlus):
"""Grab "Top 10" type lists."""
name = models.CharField(max_length=64)
error = models.CharField(max_length=128, blank=True)
[stuff deleted]

def retrieve(self):
"""Retrieve top entries from list."""

self.error = ""
try:
response = urllib2.urlopen(self.url, timeout =
30)
html = response.read()
response.close()
if not html:
raise self.RetrieveError("Document
Empty")
[stuff deleted]

# e is empty, but e.reason is correct
except self.RetrieveError as e:
self.error = "Retrieve Error: %s" % e

# this works as expected
except urllib2.URLError as e:
self.error = "URL Error: %s" % e

self.save()
return not bool(self.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: Include form in template tag

2010-09-23 Thread Anton Danilchenko
In my case this work well:

from ..forms import MessageSearchForm

Maybe we have other solution for this?

On 23 сен, 16:46, Anton Danilchenko 
wrote:
> Hi!
>
> I have created templatetag (used Django 1.2.3) in templatetags/
> board.py file. I need import form class from application.
>
> Structure of project is:
> + board/
> +++ views.py
> +++ forms.py
> +++ templatetags/
> + board.py
> + ... some other project applications ...
>
> How can I do import of form from the file forms.py?
>
> I try to do this:
> 1) from models import Message
> 2) from board.models import Message
> 3) from myprojectname.board.models import Message
>
> All this not work and show error message like this: "'board' is not a
> valid tag library: ImportError raised loading
> board.templatetags.board: No module named models"
>
> Please help.

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



Include form in template tag

2010-09-23 Thread Anton Danilchenko
Hi!

I have created templatetag (used Django 1.2.3) in templatetags/
board.py file. I need import form class from application.

Structure of project is:
+ board/
+++ views.py
+++ forms.py
+++ templatetags/
+ board.py
+ ... some other project applications ...

How can I do import of form from the file forms.py?

I try to do this:
1) from models import Message
2) from board.models import Message
3) from myprojectname.board.models import Message

All this not work and show error message like this: "'board' is not a
valid tag library: ImportError raised loading
board.templatetags.board: No module named models"

Please help.

-- 
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: What's the best way to develop an app that is similar the django admin?

2010-09-23 Thread Federico Capoano
Thanks for the answers guy, I knew a little bit model forms, but I'll
check out also the other solution.


On 22 Set, 09:29, Matthias Kestenholz 
wrote:
> On Mon, Sep 20, 2010 at 3:13 PM, Federico Capoano
>
>  wrote:
> > Hi all,
>
> > I try to explain it clearly.
>
> > I have to develop an application that will implement similar
> > functionality and look of the django admin, but in the frontend.
>
> > So this application will have files management, clients management,
> > and much more similar stuff, with add new, edit, delete, file upload
> > and so on.
>
> > Is there a way you would advice to do this?
>
> There are a few implementations around which try to do something like
> that. One of them is my django_modelviews project -- it's unreleased,
> undocumented, but I use it on several sites in production. Short usage
> instructions:
>
> http://github.com/matthiask/modelviews/
>
> 1. Add django_modelviews to INSTALLED_APPS
> 2. Create a ModelView instance somewhere in your views.py, f.e. for
> your Client model:
>
> from yourapp.models import Client
> from django_modelviews import generic
> client_views = generic.ModelView(Client)
>
> 3. Create a URL entry:
>
> from yourapp.views import client_views
> urlpatterns = patterns('',
>     url(r'^clients/', include(client_views.urls)),
> )
>
> If the code does not work for you or does not fit your needs, maybe it
> can still serve as an inspiration for your own project.
>
> Matthias
>
> --
> Django CMS building toolkit:http://www.feinheit.ch/labs/feincms-django-cms/

-- 
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: Why Django Apps Suck

2010-09-23 Thread Russell Keith-Magee
On Thu, Sep 23, 2010 at 5:55 PM, Klaas van Schelven
 wrote:
> On Sep 23, 2:01 am, Russell Keith-Magee 
> wrote:
>
> So, we run into a few problems:
> * How do we extend the models from the original extendible
> application?
> For this to work, we need to provide hooks in the application for
> extendiblity. In the case of models, such a hook would be twofold:
> 1. an abstract model to extend to provide a baseline (a default with
> the minimum amount of fields)
> 2. something overridable that is referred to by the rest of our app,
> providing the concrete instance of [1] in the plain vanilla app, and
> the concrete instance plus extensions in our extended app. (the actual
> hook)

Sure. Abstract models form the first part of this; the 'reference to
the concrete instance' is a known problem -- the most obvious example
of this surfacing is defining a custom User class to use in
contrib.auth. Alex provides one possible solution (join models) in his
talk; another (LazyForeignKey) was raised by Eric Florenzano in his
keynote [1]. However, this is still very much an open area of debate.
Any suggestions are welcome.

[1] http://djangocon.blip.tv/file/4112452/

> * how do we refer to ourselves from the various parts of the
> extendible application?
> Self-referral with overrides is a solved problem in the object
> oriented world ("inheritance"). However, it's impossible in Django's
> standard way of organizing apps, because we all use modules (not
> classes or instances) for the various parts of the app ("models.py",
> "views.py" etc).
> It is not possible to pass context into a module (other than monkey
> patching it)
>
> Every views.py begins with a bunch of imports from the associated
> models.py, tying the views into those particular app's models. My
> alternative would be like so:
>
> class View(...):
>  def page_detail(self, request, pk=None):
>    page = self.models.Page.objects.get(pk=pk)
>    return render_to_response( page ...)
>
> For models:
>
> class Models(...):
>  def get_Page(self):
>    class Page(models.Model):
>       #abstract
>       category = models.ForeignKey(self.models.Category)
>    return Page
>  Page = property(get_Page)
>
> (The above is a bit less elegant than the views example because models
> are classes and the following therefor does not work:)
>
> class Models(...)
>  class Page(self, model.Model):
>     ...
>     category = models.ForeignKey(self.models.Category)
>
> If anyone has an example of how to do this without a property I'd be
> much obliged.

Sure. There's at least two approaches. The first -- a method based
approach -- is used by contrib.auth (amongst others):

def my_view(request, arg1, arg2, klass=Page):
objects = klass.objects.filter(arg1=arg1, arg2=arg2)
...

The second is the class based approach, used by contrib.admin (and
others), which is to define a class-based view, and provide methods
like get_objects() that you can subclass to perform whatever behaviour
you need.

> Views.py methods generally have two types of parameters:
> 1. Those that are passed in via urls.py from the request path. Love
> 'em, couldn't live without 'em. This is what you're talking about.
> 2. Those we add (with usefull defaults) to make our app "reusable".
> What I was saying, is that I consider these in particular as unusable
> in the general sense. If I subclass the idea of address in an address
> book app (to add some field), would it make sense to refer to the
> subclassed address class in every call to every single view function?
> I'd say no. I'd rather say "give me my views where each view
> understands that it should use the improved address class).

Sure. And that's why you use class-based views. That's why Django's
admin is a class.

That's also why Django is in the process of getting a class-based view
framework - again, from DjangoCon, see Ben Firshman's talk [2]

[2] http://blip.tv/file/4109272

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: Please add tag for Django 1.2.3 release

2010-09-23 Thread James Bennett
On Thu, Sep 23, 2010 at 5:42 AM, Tom Evans  wrote:
> svn is the 'official' vcs, and is used to manage the development (and
> one would hope) the release engineering, but I doubt very much that it
> is the 'official distribution mechanism'; I would have thought that
> would be the tarball. Indeed, the release notes make no reference to
> svn.

Correct. The one and only official release mechanism is via the
packages listed on the Django downloads page.

We do tag things in SVN as a convenience (and for historical
purposes), and keep code organized into release-specific branches
people can deploy from if they want to, but the answer to the question
"what is Django 1.2.3" is "the file Django-1.2.3.tar.gz listed on the
downloads page".


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

-- 
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: Operational Error 1060 Duplicate column name

2010-09-23 Thread Karen Tracey
On Wed, Sep 22, 2010 at 11:18 PM, Howard Wolf  wrote:

> I'm fairly new to django and I'm trying to restart an old database.
>
> When I run the command run manage.py syncdb
>
> I get the following error:
>
> >run manage.py syncdb
> Creating table slide_taxonomyphylum
> ERROR: An unexpected error occured while tokenizing input
> The following traceback may be be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (72,0))
>
> ERROR: Internal Python error in the inspect module
> Below is the traceback from this internal error
>
> Traceback (most recent call last):
>   File "/usr/lib/pymodules/python2.6/IPython/ultraTB.py", line
> 667, in text
>  locals, formatvalue=var_rep))
>   File "/usr/lib/python2.6/inspect.py", line 875, in
> formatargvalues
>  specs.append(strseq(args[i], convert, join))
>   File "/usr/lib/python2.6/inspect.py", line 830, in strseq
>  return convert(objects)
>   File "/usr/lib/python2.6/inspect.py", line 872, in convert
>  return formatarg(name) + formatvalue(locals[name])
> KeyError: 'connection'
>
> Not sure what this means. Help is greatly appreciate.  I looked on
> google for some help but didn't find much.
>
>
First, where does the "Operational Error 1060 Duplicate column name" that
you have in the title of this thread come in? I don't see it anywhere in
your output.

Second, the traceback indicates you are running IPython, and the error
message suggests some internal-to-python error. I'd try with regular Python
and see what it does.

The title of the thread suggests an error involving a model with a duplicate
column name (though how that could happen isn't clear -- you model
definition for this table might help clarify). It's possible IPython is
somehow tripping up on reporting the raised error and regular Python would
give a less confusing error message, but since you don't show that database
error anywhere in the output I'm not even sure that error from the thread
title is related to the problem you have described in the email.

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

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



Newbie: Operational Error 1060 Duplicate column name

2010-09-23 Thread Howard Wolf
I'm fairly new to django and I'm trying to restart an old database.

When I run the command run manage.py syncdb

I get the following error:

>run manage.py syncdb
Creating table slide_taxonomyphylum
ERROR: An unexpected error occured while tokenizing input
The following traceback may be be corrupted or invalid
The error message is: ('EOF in multi-line statement', (72,0))

ERROR: Internal Python error in the inspect module
Below is the traceback from this internal error

Traceback (most recent call last):
   File "/usr/lib/pymodules/python2.6/IPython/ultraTB.py", line
667, in text
  locals, formatvalue=var_rep))
   File "/usr/lib/python2.6/inspect.py", line 875, in
formatargvalues
  specs.append(strseq(args[i], convert, join))
   File "/usr/lib/python2.6/inspect.py", line 830, in strseq
  return convert(objects)
   File "/usr/lib/python2.6/inspect.py", line 872, in convert
  return formatarg(name) + formatvalue(locals[name])
KeyError: 'connection'

Not sure what this means. Help is greatly appreciate.  I looked on
google for some help but didn't find much.

-- 
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: Please add tag for Django 1.2.3 release

2010-09-23 Thread Tom Evans
On Mon, Sep 13, 2010 at 4:19 PM, shacker  wrote:
> On Sep 12, 12:12 pm, creecode  wrote:
>> Hello all,
>>
>> I asked  and we
>> received! :-)  Thanks Russell!
>
> Hmm, the ticket is marked fixed, but the repo is still at 1.2.1. This
> is not good. 1.2.2 is a security release, and we should be able to use
> the official distribution mechanism (svn) to update our sites
> immediately.
>
> ./s
>

svn is the 'official' vcs, and is used to manage the development (and
one would hope) the release engineering, but I doubt very much that it
is the 'official distribution mechanism'; I would have thought that
would be the tarball. Indeed, the release notes make no reference to
svn.

It is useful to have the tags in svn, but given that it is not in any
way the release mechanism, it's a little unwise to rely upon it. YMMV.

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: Why Django Apps Suck

2010-09-23 Thread Klaas van Schelven
On Sep 23, 2:01 am, Russell Keith-Magee 
wrote:
> On Wed, Sep 22, 2010 at 11:31 PM, Klaas van Schelven
>
>  wrote:
> >> I'm yet to see a genuine case of (a) -- every time I've seen (a), it's
> >> really masked version of (b), (c) or (d).
>
> > I disagree. I think there are very specific problems, that has not
> > been adressed by any of the responses above.
> > Let's focus on one for now: how to extend models in any given app.
>
> > As stated in the original mail, there are at least two problems with
> > this in Django:
> > 1. How to provide the models in the first place? Everything that's not
> > abstract is hard to extend; providing abstract models feels really
> > awkward.
>
> If a model isn't abstract but needs to be, then that speaks to
> applications not being built to be as extensible as possible. Django
> hasn't always had abstract models -- they were added just before 1.0
> landed (IIRC).
>
> Unfortunately, it's very difficult to migrate from a concrete model
> back to an abstract model, so it's not easy to introduce an abstract
> model into an existing app without breaking backwards compatibility.
> There are also complications around handling foreign keys to abstract
> models. This is an area where there is room for improvement; there
> have been some very recent discussions on this very topic. Alex Gaynor
> discussed some of the issues and approaches in his recent DjangoCon
> presentation [1].
>
> [1]http://djangocon.blip.tv/file/4108781/

Thanks for the video.

I'll try to make my case again with the insight I've gained over the
last couple of mails.
Let me reiterate that a large part of the reusable app problem has
been solved. However, the following has not:

Reusing a small set of functionality around some typical, extensible
data structures.

Again, examples:
* A reusable address book
* A reusable "who's at the office" calendar
* A reusable small library tool (which books are in our library)
* A reusable time tracking tool

In any of the above, the data structure is typical and revolves around
a few related model classes. The views revolve around common CRUD for
the objects, and around "whatever makes the app special". Special
stuff is, in the case of time tracking: various ways of inputting time
and searching for it. In the case of an address book: displaying
relevant lists, detail views.

However, pretty much every actual use of the reusable app will involve
some additions to the models. Contacts in the USA? We'll add a State
field to your address model. Your particular use case requires us to
categorize time-lines in a specific manner? We'll slap a foreign key
on it to some "TimeLineCategory".

The key is, that this new extended address, time-line or whatever
should become the idea of an address, timeline or whatever from the
perspective of the app.

So, we run into a few problems:
* How do we extend the models from the original extendible
application?
For this to work, we need to provide hooks in the application for
extendiblity. In the case of models, such a hook would be twofold:
1. an abstract model to extend to provide a baseline (a default with
the minimum amount of fields)
2. something overridable that is referred to by the rest of our app,
providing the concrete instance of [1] in the plain vanilla app, and
the concrete instance plus extensions in our extended app. (the actual
hook)

* how do we refer to ourselves from the various parts of the
extendible application?
Self-referral with overrides is a solved problem in the object
oriented world ("inheritance"). However, it's impossible in Django's
standard way of organizing apps, because we all use modules (not
classes or instances) for the various parts of the app ("models.py",
"views.py" etc).
It is not possible to pass context into a module (other than monkey
patching it)

Every views.py begins with a bunch of imports from the associated
models.py, tying the views into those particular app's models. My
alternative would be like so:

class View(...):
  def page_detail(self, request, pk=None):
page = self.models.Page.objects.get(pk=pk)
return render_to_response( page ...)

For models:

class Models(...):
  def get_Page(self):
class Page(models.Model):
   #abstract
   category = models.ForeignKey(self.models.Category)
return Page
  Page = property(get_Page)

(The above is a bit less elegant than the views example because models
are classes and the following therefor does not work:)

class Models(...)
  class Page(self, model.Model):
 ...
 category = models.ForeignKey(self.models.Category)

If anyone has an example of how to do this without a property I'd be
much obliged.

As said, I'll try to come up with something in the evening hours that
allows for this and still feels Django-esque. (Which should make
conversion of my own apps easier as well).

>
> > 2. How to tie in the models into the views? Long view parameter lists
> > that are used 

Re: Problem with ForeignKey()

2010-09-23 Thread Tom Evans
First thought is "You haven't provided anywhere near enough context".

Second thought is "That is how it works, so you're doing something
else wrong. See #1".

class PropertyValue(BaseModel):
  value = models.CharField(max_length=256)
  prop = models.ForeignKey('Property')
  parent = models.ForeignKey('self', null=True, blank=True,
related_name='children')

>>> pvalue = PropertyValue.objects.get(id=42)
>>> if not pvalue.parent: print "prop value has no parent value"
...
prop value has no parent value


Cheers

Tom


On Thu, Sep 23, 2010 at 4:55 AM, Yo-Yo Ma  wrote:
> Any thoughts on this?
>
> On Sep 22, 10:47 am, Yo-Yo Ma  wrote:
>> Anyone know how to do this?
>>
>> On Sep 21, 10:35 pm, Yo-Yo Ma  wrote:
>>
>>
>>
>> > I have a model with:
>>
>> > parent = ForeignKey('self', blank=True, null=True)
>>
>> > In that model I've overridden clean() to contain:
>>
>> > if self.parent:
>> >     # Do some stuff
>>
>> > It raises an attribute error saying that parent.pk doesn't exist. How
>> > can I get around this. Note that my foreign key is recursive.
>
> --
> 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.



reverse ForeignKey

2010-09-23 Thread ionut cristian cucu
Hi list,
I just came to django, and to web programming for that matter, so my
question is from a n0b:
I have to models:
class Pacient(models.Model):
 name=models.CharField('name', max_length=123)

class Exit(models.Model):
  pacient=models.ForeignKey(Pacient)


How to I get the admin interface to show only the pacients for whom I
have no exit objects.
Rephrase: if I have an Exit object for a Pacient, I don't want that
Pacient object to show up
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.



Relationship between multiple sites & projects, apps

2010-09-23 Thread Benedict Verheyen
Hi,


it's not exactly clear to me how the sites, projects and apps need to be 
structured.

For instance, if you have 2 sites both with a domain name, how would you 
structure
this in Django?
The Django project could be called "mysites" or whatever name.
In the admin site, you would then have 2 sites. So far so good.
But how would you represent the sites?
Do you make an application per site as each site could do something specific.
Then you end up with this structure.
Is this how it is meant to be?
-- mysites (project)
-- site 1 (app)
-- site 2 (app)

The only downside might be if both sites have loads of users, they are all 
displayed in the same list
in the admin interface.
Also, if you couple this with django-registration, it might not be that simple 
to let a user register
for site 1 as well as site 2. I have no practical experience with 
django-registration but it seems
like something i would use in the future.

Or is it better to split the sites over 2 projects, so you have a project per 
site?
-- site 1 (project)
-- site 1 (app)
-- site 2 (project)
-- site 2 (app)


Thanks for any insights,
Regards,
Benedict

-- 
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: simple relationship difficult?

2010-09-23 Thread jayfee
well, never mind the rambling at the end because i *think* this
inheritance thing may be a very good lead. thanks for the tip!

On Sep 22, 5:18 pm, Karen Tracey  wrote:
> On Wed, Sep 22, 2010 at 7:11 AM, jayfee  wrote:
> > hello, so i've been running into a problem across a handful of
> > frameworks, which is beginning to make me think i'm doing something
> > dumb :-) so hopefully someone will be kind enough to set me on the
> > right path. here's what i'm trying to do.
>
> > i am creating a system that will be used to categorize ideas,
> > information, people, places, etc. now one piece of information that i
> > want to have associated with basically everything is date information.
> > since it's not always possible to know exactly when something
> > happened, i'm implementing this as a range, including information
> > about how "sure" the user is.
>
> > to implement this, i've been creating a model for "DateRange",
> > including 4 pieces of scalar data (start date, end date, start
> > certainty, end certainty). and i've then been trying to include a
> > standard widget on all data entry pages (people, place, event, etc)
> > which is based on the DataRange model in a way that looks and acts
> > seemless. basically i want it to act just like it would if i simply
> > included those four pieces of information directly in each other model
> > (Place, Person, etc). that doesn't seem very DRY to me though :-)
>
> > now here's where i'm running into trouble over and over. the way i've
> > naturally wanted to to do this is to include a relationship going from
> > any given piece of data and pointing to a DateRange. for example, in
> > my Person model, i've included a birthday_Id, which is a foreign key
> > pointing to DateRange primary key. this is where things get tricky.
>
> > for some reason, none of the frameworks i've looked into, django
> > included, like this relationship. instead, they want me to have a
> > foreign key in DateRange pointing to each piece of data (Person,
> > Place, etc). this either means using a generic foreign key or having a
> > bunch of foreign keys in DateRange. or perhaps there's a better way?
>
> You lost me with this last paragraph since you omitted what, exactly, leads
> you to say that none of the frameworks you ave looked at "like" this
> relationship, nor what leads you to say they "want" you to have a foreign
> key in the other direction.
>
> Going back a couple of paragraphs, though, if you'd really like to operate
> as though these four pieces of information are included directly in other
> models, then I think you might be better off using model inheritance 
> (http://docs.djangoproject.com/en/dev/topics/db/models/#model-inheritance)
> than a foreign key relationship. Have you looked into that way of doing
> this?
>
> Karen
> --http://tracey.org/kmt/

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

2010-09-23 Thread Joel Klabo
Thanks for the help, all working now!

On Sep 22, 11:52 pm, Russell Keith-Magee 
wrote:
> On Thu, Sep 23, 2010 at 2:41 PM, Joel Klabo  wrote:
> > I keep getting this import error and I can't figure out why? Any ideas
> > would be greatly appreciated:http://dpaste.org/BgtI/
>
> It's a circular import problem. signals.py imports objects from
> models.py, and models.py imports objects from signals.py. Python can't
> handle circular imports -- hence, the import error.
>
> To fix this, you either need to:
>
>  * Put everything in models.py
>  * Refactor signals.py so that it doesn't need to import models.py at
> the global level.
>
> The second approach can be handled in two ways -- either make the
> import internal to the 'drink_activity' method:
>
> def drink_activity(sender, **kwargs):
>     from models import Activity
>     
>
> or use Django's dynamic model loading to determine the model at runtime:
>
> from django.db.models import get_model
>
> def drink_activity(sender, **kwargs):
>     Activity = get_model('myapp','Activity)
>     ...
>
> Django 1.3 will probably introduce a third option -- a reliable place
> to register signals. We need this for completely separate reasons, but
> providing a safe home for signal registration will be a happy
> consequence.
>
> 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: Signals problem

2010-09-23 Thread Russell Keith-Magee
On Thu, Sep 23, 2010 at 2:41 PM, Joel Klabo  wrote:
> I keep getting this import error and I can't figure out why? Any ideas
> would be greatly appreciated: http://dpaste.org/BgtI/

It's a circular import problem. signals.py imports objects from
models.py, and models.py imports objects from signals.py. Python can't
handle circular imports -- hence, the import error.

To fix this, you either need to:

 * Put everything in models.py
 * Refactor signals.py so that it doesn't need to import models.py at
the global level.

The second approach can be handled in two ways -- either make the
import internal to the 'drink_activity' method:

def drink_activity(sender, **kwargs):
from models import Activity


or use Django's dynamic model loading to determine the model at runtime:

from django.db.models import get_model

def drink_activity(sender, **kwargs):
Activity = get_model('myapp','Activity)
...

Django 1.3 will probably introduce a third option -- a reliable place
to register signals. We need this for completely separate reasons, but
providing a safe home for signal registration will be a happy
consequence.

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: Signals problem

2010-09-23 Thread Joel Klabo
Update:
http://dpaste.org/kK5p/

On Sep 22, 11:41 pm, Joel Klabo  wrote:
> I keep getting this import error and I can't figure out why? Any ideas
> would be greatly appreciated:http://dpaste.org/BgtI/

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



Signals problem

2010-09-23 Thread Joel Klabo
I keep getting this import error and I can't figure out why? Any ideas
would be greatly appreciated: http://dpaste.org/BgtI/

-- 
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 use custom classes in django

2010-09-23 Thread Sam Lai
After revising python basics, here's how I'd structure it -

On 22 September 2010 18:10, jake2891  wrote:
> Hey guys, i am using extjs in django and am wondering the correct way
> to build custom classes like file upload classes and classes of
> functions.

I'm assuming by 'file upload classes' you mean file upload views, i.e.
the code responsible for receiving the file upload. If so, they're
just like any other view. In Django though, you might want to consider
putting file validation and processing code into your forms.py or
models.py for better abstraction and reusability.

For 'classes of (useful) functions', put them wherever they make
sense. As mentioned, they don't need to be classes - you can just have
files with functions in them. Use classes only when a class makes
sense. If they're only applicable in one app, put them in a file in
that app. You might want to use different files to separate the
functions into different namespaces.

> I am a bit confused does everything have to go into
> views.py by defining a function for each ajax request or what is the
> process? As with extjs like drop downs make an ajax request to
> populate them with data do all of these for all of my fields go into
> the view or can i create a custom class of methods and just use the
> views for rendering the forms. thanks

Yep, they're just like every other view. You could use some python
magic to reuse the same view for different but related AJAX requests
and avoid repetition. You might want to consider putting the code for
getting the data in your form, so you can easily create an alternative
non-AJAX form.

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