64 bit integer field

2008-07-17 Thread simon


How do i create a long long integer field in my model ? Do I use
decimal ? (worried about performance of the decimal field). I am using
the mysql backend.

Simon.

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



Flatpages and additional context

2009-04-21 Thread Simon

I'm using Django flatpages for all the "one-off" pages on my website,
but I'd like to create a "lite" version of the site for iPhone users
(for example) which would use a different style sheet and shorten the
site menu (by missing off several of the least used menu options). If
I put a variable like ?lite=1 on the URL, is there a way to access
this variable from the flatpages base template, and adjust the context
accordingly?

Thanks!

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



Re: Flatpages and additional context

2009-04-21 Thread Simon

Looks good. Thanks  :)


On 21 Apr, 14:31, Tom Evans  wrote:
> On Tue, 2009-04-21 at 06:02 -0700, Simon wrote:
> > I'm using Django flatpages for all the "one-off" pages on my website,
> > but I'd like to create a "lite" version of the site for iPhone users
> > (for example) which would use a different style sheet and shorten the
> > site menu (by missing off several of the least used menu options). If
> > I put a variable like ?lite=1 on the URL, is there a way to access
> > this variable from the flatpages base template, and adjust the context
> > accordingly?
>
> > Thanks!
>
> > --
> > Simon
>
> Hi
>
> Write your own context processor [1] to check for the existence of this
> variable, and then return a dictionary with an appropriate variable to
> add to your context.
>
> Cheers
>
> Tom
>
> [1]http://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Count by date

2009-11-23 Thread Simon
Hi all,

I am sure this must be a real noob question as it's so easy to do in
SQL.
I am trying to replicate something like the following in Django:

SELECT DATE(created) AS created_day, COUNT(id) AS NumberOf FROM
my_table GROUP BY created_day

Effectively, all I want to do is a count grouped by a specific day,
week or month.
I assumed I could use something like

MyTable.objects.annotate(Count('created'))

but I can't find a way to format the "created" date such that it
ignores the less significant elements, such as the hours and minutes
and only counts entries based on the unit I want.

Anyone any ideas how to do this?
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=.




Introducing ImageFlow for Django (Django-ImageFlow)

2010-06-07 Thread simon
Hi everyone,

ImageFlow is a platform-independent JavaScript picture gallery
inspired by the Cover Flow technique currently used in iTunes and the
file browser of OSX. The standard ImageFlow setup uses PHP to create
the optional reflections for images in the gallery. ImageFlow is free
for non-commercial use. You can read more on ImageFlow in its
documentation, or view examples of ImageFlow in use:
- http://finnrudolph.de/ImageFlow/Features
- http://finnrudolph.de/ImageFlow/Documentation
- http://finnrudolph.de/ImageFlow/Examples.

I've created a reusable Django app that utilises "reflection.py", a
script created by Justin Driscoll as part of the Django Photologue
project, to create the reflections. To read more on the app or to
download it, visit this blog post:
http://simonkagwe.com/blog/2010/06/06/introducing-django-imageflow/

I'd love to get your feedback on what you think about the app.

Regards,
Simon.

-- 
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: Introducing ImageFlow for Django (Django-ImageFlow)

2010-06-09 Thread simon

> Is their an option of positioning the Captions associated with the images?

The captions for the images are positioned below the image by default.
To change this, you would have to dive into the javascript in /static/
css/imageflow.jss. Search for captionDiv. The JS between lines 218
=and 280 basically creates the layout of the gallery. For example, to
position the captions above the images you would comment line 254
("navigationDiv.appendChild(captionDiv);") and add
"my.ImageFlowDiv.appendChild(captionDiv) &&" to the subsequent if
statement i.e:

if (my.ImageFlowDiv.appendChild(captionDiv) &&
my.ImageFlowDiv.appendChild(imagesDiv) &&
my.ImageFlowDiv.appendChild(loadingP) &&
my.ImageFlowDiv.appendChild(loadingDiv) &&
my.ImageFlowDiv.appendChild(navigationDiv))

You may also need to modify the CSS in /static/css/imageflow.css,
particularly ".imageflow .caption".

> Also, can we change the background - say, use another picture?

Yes. Modify the CSS in /static/css/imageflow.css. Add backgound
property to ".imageflow" at the very top of the CSS.

-- 
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: Introducing ImageFlow for Django (Django-ImageFlow)

2010-06-14 Thread simon


On Jun 11, 4:26 pm, backdoc  wrote:
> The examples are pretty slick.

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.



a bug (i think) with dynamic inlines and ManyToMany relationships

2010-03-13 Thread Simon
Hi all,

I've found what I think is a bug in django 1.2 beta 1 (SVN-12773).

The dynamic inlines works great with foreign key relationships, but
the "Add another xxx" link doesn't appear with ManyToMany
relationships.  It seems to be because of the '+' character in the
`inline_admin_formset.formset.prefix`, causing the regex in
`inlines.js` to fail.  By over-riding the `tabular.html` template and
hard-coding the prefix i can partly get the functionality, but it's
not perfect.

Before I look into it more (I'm not very familiar with the codebase)
and file a bug report, I wanted to check here if it's a known issue.
If anyone has any input I'll be very grateful to hear it.

Thanks!

Simon

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



Receiving an XML from client and parsing into django db

2007-11-22 Thread Simon

Hi everyone,
I'm actually very new to django and I haven't been able to find any
answers to my problem.
I was wondering if there was a way I could receive an xml from a
client and parse that into
the database that I created with django?

Originally, I had a server side script that would take in the xml file
through stdin,
but since I don't know much about django and would like to use it for
its database
capabilities I was wondering if this would even be possible?

Thanks for all the help.

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



Re: Receiving an XML from client and parsing into django db

2007-11-22 Thread Simon

Thank you for the quick reply DR.
I'll look into it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django Unit Tests Missing Database Columns

2012-07-16 Thread Simon


I created a unit test on Django to create a user account and send a 
verification e-mail. The user is created, but the e-mail fails to send. The 
e-mail's default contents are supposed to be created as a field in the user 
when a user is created, but for some reason, Django is claiming -

DatabaseError: no such column: app_userprofile.default_email_header

It works fine when the account is created manually, though for some reason 
it fails to create that column in the database when done from a unit test. 
Any suggestions for fixing this?

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



How to handle exceptions in middleware?

2013-08-22 Thread Simon
Hi,

I've got a webservice built on top Django which requires that every request 
(except authentication) include an auth token.

I've implemented this restriction as Middleware...

def process_view(self, request, view_func, view_args, view_kwargs):
if hasattr(view_func, 'NoAuthenticationRequired'):
return None

Token = request.REQUEST.get("Token", None)
if Token is None:
logger.warning('NoAuthToken: ...')
Ret = {'Exception': "No authentication token was provided'"}
return HttpResponse(json.dumps(Ret), 
content_type="application/json", status=UNAUTHORIZED)

TokenCheck = AuthManager.ValidateToken(Token)
...

Auth tokens are stored either in memcached or Postgres. In either case, if 
the service is unavailable, my code currently throws and exception 
resulting in a stock Django error page.

Since this is a webservice, I never want to output an html error, always 
Json, so this doesn't work for me. Unfortunately, exceptions raised in 
middleware, bypass process_exception middleware and go straight to the 
stock django exception handlers... (execution skips from 
core/handlers/base.py ~line 92, to the catch at ~line 175)

try:
response = None
# Apply request middleware
for middleware_method in self._request_middleware:
response = middleware_method(request)
if response:
break
...

except: # Handle everything else, including 
SuspiciousOperation, etc.
# Get the exception info now, in case another exception is 
thrown later.
signals.got_request_exception.send(sender=self.__class__, 
request=request)
response = self.handle_uncaught_exception(request, 
resolver, sys.exc_info())

I'm either looking for a way to avoid a chunk of code duplication (with 
every middleware method having lots of boilerplate try/catch/record+format 
exception) or, better yet, a way to use my own exception handler under any 
and all circumstances (effectively replace Django's 
handle_uncaught_exception)

I'm still relatively new to Django (and Python) so any pointers appreciated

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


user and perms context variables from auth context processor (in Django 1.2.3)

2011-04-29 Thread simon
Hello,

I am using Django 1.2.3. I was trying to check user permissions on a
certain model using the perms context variable from
contrib.auth.context_processors.auth. As per the documentation, I
tried this (foo is the app label, Bar is the model, and I'm using
default permissions):

{% if perms.foo.change_bar %} do stuff {% endif %}

It's always false even when logged in as a superuser. I tried doing
{{user.username}} to see if the user variable worked and it also
displayed nothing. So I checked in the debug toolbar and the variables
I get from the auth context processor are these:

{'messages':
,
 'perms': ,
 'user': }

My questions are:
1) wasn't the SimpleLazyObject for user not fixed as claimed by ticket
12060 ( http://code.djangoproject.com/ticket/12060 ) ? Or was it fixed
after 1.2.3?
2) How do I go about checking permissions using the perms variable? It
seemed to be wrapped in some other function.

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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Problem with FileField (file upload) and generic views

2011-03-10 Thread Simon
I'm writing an app to allow users in a school to upload newsletters to our 
website, but I'm having problems using models.FileField in a generic view. 
I've set 

MEDIA_ROOT = '/data/school/media/'

and MEDIA_URL is also set to a valid location. I've checked and re-checked 
permissions on the directories: www-data (apache user) has full RWX 
permissions. The model:

class Newsletter(models.Model):
issue_date= models.DateField()
issue_number  = models.IntegerField()
table_of_contents = models.TextField(null=True, blank=True)
pdf_file  = models.FileField(upload_to='newsletters', null=True, 
blank=True)

In urls.py:

# Create newsletter detail
(r'^new/$',
CreateView.as_view(
model=Newsletter,
template_name='newsletter/edit.html',
)),

If I set the pdf_file field so that a file is required, it fails every time 
with the error "This field is required", even though a file has been 
selected. If I set it to "null=True, blank=True" (as above) it takes no 
notice of the file I have selected in the "pdf_file" upload field.

I'm not sure if I've missed something obvious. Searching around turns up an 
old bug which gives the same problem but was fixed years ago.

Any suggestions would be appreciated, TIA.

--
Simon

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



Re: Problem with FileField (file upload) and generic views

2011-03-10 Thread Simon
Spot on. Thanks.

--
Simon

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



Django 1.8.2 - handler404 and handler500 refusing to work

2015-06-30 Thread simon
Good afternoon all,

Perhaps someone can give me a pointer here:

I'm an old hand at Django (1.0 to 1.6) but now in 1.8.2, the documented 
process of writing and attaching custom handlers for '404' and '500' 
appears to have stopped working.

As per the dox, I have added into my ROOT url file, the required overrides:

from django.conf.urls import *
from django.contrib import admin

urlpatterns = [
url(r'^apikey/', include('apikey.urls', namespace='apikey')),
url(r'^admin/', include(admin.site.urls)),
]

handler404 = 'apikey.views.custom_handler'
handler500 = 'apikey.views.custom_handler'

I have created the default 404.html template in the apikey/templates 
directory and updated the site settings file to reflect this
and I can confirm that this default 404.html file is indeed getting 
rendered, but not by my routine:

views.py
---
def custom_handler(request):
print ‘——>>> got to here’
return HttpResponseNotFound('Boo! - Page not found')

I've been testing with DEBUG=False under 'python manage.py runserver'.
My custom handler never, *ever* fires when a URL not in my apikey/urls.py 
file is submitted by a GET and a 404 is supposed to be raised.

I am at a complete loss as to why this isn't working, having had no issues 
with this custom handler process over the past 5 years :(

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4cea481b-9db4-4eb1-8d7f-57d3e44d60b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Execute a java program

2008-10-30 Thread Simon Brunning

2008/10/30 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> I have to execute a java program very simple look something like this:

(snip)

> How Can I do that? Do I have to use JVM ? How ?

You'll need a JVM - Python doesn't speak Java!

You can either just use the Subprocess module to call the JVM, just as
you would from the command line, or you might perhaps take a look at
<http://jpype.sourceforge.net/> or <http://jpe.sourceforge.net/>.

-- 
Cheers,
Simon B.
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/

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



List a model fields

2008-12-15 Thread JF Simon

Hello, i'm new with python (and french so my english may seem very
poor, sorry about that).
I would like to list a model's fields and return a dict, here is the
example :

I have a model class with :

meta_title : CharField(...)
meta_description : CharField(...)
body_header_title : CharField(...)
body_header_text : CharField(...)
foot : CharField(...)

This class represents context for a page. This class will have a
function get_context() who will return :

{
   meta :
   {
  title : 'value of meta_title' ,
  text : 'value of meta_text' ,
   } ,
   body :
   {
  header :
  {
 title : 'value of body_header_title ,
 text : 'value of body_header_text ,
  }
   } ,
   foot : 'value of foot'
}

So i would like to :

1. get the list of my class's fields attributes
2. parse their names to obtain the dict

Thanks a lot to the ones who read this message to the bottom !!
Long live the Django project !!!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: List a model fields

2008-12-16 Thread JF Simon

thanks dude.

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



ANN: dmigrations, a new migrations system for Django

2008-09-03 Thread Simon Willison

dmigrations is a new tool for managing changes to a Django database,
developed internally at Global Radio and designed to work well with a
medium-large (14 member) team of developers. We've been using it in
production for a few months, and were recently given the go-ahead to
open source it.

I've written more about the release here: 
http://simonwillison.net/2008/Sep/3/dmigrations/

The project (including documentation and a tutorial) is here:
http://code.google.com/p/dmigrations/

I'll be discussing the project on the schema migration panel at
DjangoCon this weekend.

Cheers,

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



Re: Restrict users to their own data

2008-09-11 Thread Simon Willison

On Sep 11, 5:23 pm, Glimps <[EMAIL PROTECTED]> wrote:
>     I would like to restrict users to the data they can see/modify/
> delete on a table. I have a Reservation table that holds reservations
> for multiple banners of Restaurant chain. I don't want the user from
> franchiseX to be able to see/confirm reservations from franchiseY.
>
> Since all the add/edit/delete is made with the admin interface (Django
> 1.0) I went and search for something I could override in the
> ModelAdmin class. No success.

Take another look at ModelAdmin - the methods you want to over-ride
are queryset(request) which returns the QuerySet used to create the
"change list" view and has_add_permission(request),
has_change_permission(request, obj) and has_delete_permission(request,
obj).

You can over-ride those methods on your ModelAdmin subclass to
implement your permissions logic. Your code will end up looking
something like this:

class ReservationAdmin(admin.ModelAdmin):
def queryset(self, request):
return super(ReservationAdmin, self).filter(user =
request.user)

def has_change_permission(self, request, obj=None):
if not obj:
return False
return obj.user == request.user

def has_delete_permission(self, ...)
# similar

Cheers,

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



Re: Displaying ManyToMany relations in Admin

2008-09-19 Thread Simon Willison

On Sep 19, 10:24 am, "Nick Sandford" <[EMAIL PROTECTED]> wrote:
> Is there some kind of limit the admin imposes on the number of items
> it will show in a  or the horizontal filter list? If so, can I
> change it? Also, is there any better way to do this?

raw_id_fields is the admin option you need:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#raw-id-fields

In Django prior to Django 1.0 this was the 'raw_id_admin=True' option
on a ForeignKey.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Cannot assign "": "Character.user_profile" must be a "UserProfile" instance.

2008-09-23 Thread Simon Forman

I'm getting an error I can't figure out.

I have a "UserProfile" class that is the AUTH_PROFILE_MODULE setting,
but then when I am trying to create an object from a model class that
has a ForeignKey for that UserProfile class

char = Character(
user_profile = request.user.profile,
...


where


class Character(Model):
user_profile = ForeignKey(UserProfile, related_name='characters')
...


I get a ValueError:

Cannot assign "": "Character.user_profile" must be a "UserProfile"
instance.

The user is logged in, and has a UserProfile according to the admin
interface.

TIA
~Simon

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



Re: Cannot assign "": "Character.user_profile" must be a "UserProfile" instance.

2008-09-23 Thread Simon Forman

profile = user.get_profile()

D'oh,  got it.

~Simon

On Sep 23, 2:47 pm, Simon Forman <[EMAIL PROTECTED]> wrote:
> I'm getting an error I can't figure out.
>
> I have a "UserProfile" class that is the AUTH_PROFILE_MODULE setting,
> but then when I am trying to create an object from a model class that
> has a ForeignKey for that UserProfile class
>
> char = Character(
>     user_profile = request.user.profile,
> ...
>
> where
>
> class Character(Model):
>     user_profile = ForeignKey(UserProfile, related_name='characters')
> ...
>
> I get a ValueError:
>
> Cannot assign " at 0x552b9a0b10>": "Character.user_profile" must be a "UserProfile"
> instance.
>
> The user is logged in, and has a UserProfile according to the admin
> interface.
>
> TIA
> ~Simon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Cannot assign "": "Character.user_profile" must be a "UserProfile" instance.

2008-09-23 Thread Simon Forman

Thanks Karen,  I must have gotten it just as you posted your reply,

Thanks anyhow,
~Simon

On Sep 23, 2:59 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Sep 23, 2008 at 5:47 PM, Simon Forman <[EMAIL PROTECTED]> wrote:
>
> > I'm getting an error I can't figure out.
>
> > I have a "UserProfile" class that is the AUTH_PROFILE_MODULE setting,
> > but then when I am trying to create an object from a model class that
> > has a ForeignKey for that UserProfile class
>
> > char = Character(
> >    user_profile = request.user.profile,
> > ...
>
> > where
>
> > class Character(Model):
> >    user_profile = ForeignKey(UserProfile, related_name='characters')
> > ...
>
> > I get a ValueError:
>
> > Cannot assign " > at 0x552b9a0b10>": "Character.user_profile" must be a "UserProfile"
> > instance.
>
> > The user is logged in, and has a UserProfile according to the admin
> > interface.
>
> Apparently request.user.profile is a RelatedManager type thing, not an
> instance of your user profile.  Per the docs 
> (http://www.djangoproject.com/documentation/authentication/#storing-ad...)
> it appears you should be using the get_profile() method on a User instance
> to retrieve the user's profile, so I'd try:
>
> char = Character(
>    user_profile = request.user.get_profile(),
> ...
>
> instead of what you have.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Traceback in the ``runserver`` console

2009-01-18 Thread Simon Forman

On Dec 27 2008, 5:14 am, "Russell Keith-Magee"
 wrote:
> On Sat, Dec 27, 2008 at 2:32 AM, Fridrik Mar Jonsson  
> wrote:
>
>
>
> > Hi Djangonians,
>
> > I recently had an instance where it would have been really convenient
> > to see the error and a traceback in the ``runserver`` console instead
> > of just a single line telling me that the request returned a 500
> > error.

I just noticed this too.  Sometime between 0.96.3 and 1.0  "./
manage.py runserver" stops printing out tracebacks. The "--traceback"
and "-v" options do nothing.

> > In the event of blind debugging, where a 3rd party tool is performing
> > a request that renders in an error, is there a Django mechanism or
> > extension that allows you to catch any exceptions that occur during a
> > page load and redirect them to the ``runserver`` console in addition
> > to displaying them in the template?
>
> There are two options I can think of on an unmodified Django install.
>
> Firstly, write a middleware that implements process_exception(). This
> middleware will get invoked whenever an exception is raised as part of
> the view; the middleware method will be the exception as one of the
> arguments.
>
> http://docs.djangoproject.com/en/dev/topics/http/middleware/#process-...
>
> Secondly, write a listener for the got_request_exception signal. This
> signal is fired whenever an exception other than 404, Permission
> Denied, or SystemExit is raised.
>
> http://docs.djangoproject.com/en/dev/ref/signals/#django.core.signals...
>
> > For an optimistic moment I thought ``--traceback`` was a bit
> > promising, but then it turned out that it doesn't really seem to do
> > what I expected in the case of ``runserver``.  I even considered
> > switching to e-mail tracebacks but ended up writing a client to mimic
> > the 3rd party tool's functionality instead.
>
> When I read this I went and had a look at the code, and it appears you
> are correct. ``--traceback`` exists as a top-level command option, but
> it doesn't appear to be exploited at all inrunserver. This actually
> surprised me - it seems like a reasonable suggestion for an
> improvement. Feel free to open this as a ticket (and if you're really
> adventurous, work on a patch :-)
>
> Yours,
> Russ Magee %-)

I can open a ticket, and even attempt a patch.  How did this go away?
I'm curious.

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



Re: object_detail 404 (queryset outdated?)

2009-02-02 Thread Simon Westphahl

After some further investigation it seems this problem is related to
my custom manager.

###
class OfferManager(models.Manager):
def get_query_set(self):
return super(OfferManager, self).get_query_set().exclude
(start_date__gt=datetime.now).exclude(end_date__lt=datetime.now)
###

I'm using a queryset filtered with a callable (datetime.now) which
appears to be set only once/on load time?!
Does anyone no a way to work around this?

Regards,
Simon

On Feb 2, 9:21 am, Simon Westphahl  wrote:
> Hi,
>
> I'm getting the following 404 when accessing an objects detail page.
>
> ###
> Page not found (404)
> Request Method: GET
> Request URL:http://127.0.0.1:8000/offers/service/testservice/
>
> No  found
> matching the query
> ###
>
> This seems a little strange to me since the object overview works like
> a charm.
> I'm using this urly.py for my app:http://dpaste.com/115521/
>
> The queryset passed to 'extra_context' has to be a python function as
> mentioned in the django generic views documentation, since i want to
> get a queryset that is always fresh (This works!)
> Does this also apply to the 'service_detail' dict passed to the
> 'object_list' generic view?
> It seems as if the the queryset is outdated and only evaluated once?
>
> Thanks in advance!
>
> Simon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



object_detail 404 (queryset outdated?)

2009-02-02 Thread Simon Westphahl

Hi,

I'm getting the following 404 when accessing an objects detail page.

###
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/offers/service/testservice/

No  found
matching the query
###

This seems a little strange to me since the object overview works like
a charm.
I'm using this urly.py for my app: http://dpaste.com/115521/

The queryset passed to 'extra_context' has to be a python function as
mentioned in the django generic views documentation, since i want to
get a queryset that is always fresh (This works!)
Does this also apply to the 'service_detail' dict passed to the
'object_list' generic view?
It seems as if the the queryset is outdated and only evaluated once?

Thanks in advance!

Simon

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



object_detail 404 (queryset outdated?)

2009-02-02 Thread Simon Westphahl

Hi,

I'm getting the following 404 when accessing an objects detail page.

###
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/offers/service/testservice/

No  found
matching the query
###

This seems a little strange to me since the object overview works like
a charm.
I'm using this urly.py for my app: http://dpaste.com/115521/

The queryset passed to 'extra_context' has to be a python function as
mentioned in the django generic views documentation, since i want to
get a queryset that is always fresh (This works!)
Does this also apply to the 'service_detail' dict passed to the
'object_list' generic view?
It seems as if the the queryset is outdated and only evaluated once?

Thanks in advance!

Simon


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



Re: object_detail 404 (queryset outdated?)

2009-02-02 Thread Simon Westphahl

I finally got it to work! I wrapped the object_detail view with a view
that calls the manager method as suggested by Carl.

Thank you!

On 2 Feb., 16:38, Carl Meyer  wrote:
> I think you've got the right idea of what's going wrong, but you're
> looking for the problem in the wrong place.  This method isn't module-
> level code; it will be executed anew each time you query on this
> manager.  More likely is that you're storing a reference to the
> returned queryset in module-level code; probably in a dictionary of
> kwargs you're passing to the object_detail generic view (most likely
> in your urls.py).  It's that queryset that is never getting updated;
> the call to your manager method is happening only once, when the
> urls.py module is first loaded.
>
> The solution is to wrap the object_detail view with a very lightweight
> view of your own that calls the manager method and passes the
> resulting queryset in to object_detail.  Then the queryset will be re-
> created for each request.
>
> Carl
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: object_detail 404 (queryset outdated?)

2009-02-02 Thread Simon Westphahl

On 3 Feb., 03:54, Malcolm Tredinnick  wrote:
> Have you verified that an object exists for whatever the slug value is
> that you're passing in? Using Django's debug page, you should be able to
> see the slug value and try it out at a Python prompt. That would be the
> first step.
>
> On the surface, your code looks fine. The queryset is cloned each time
> the generic view is called, which causes it to be refreshed, so that
> shouldn't be an issue. I suggest you start debugging from the error
> message: why is nothing matching the query (remember that it's
> performing a "get()" based on the slug, so that's why you're getting an
> ObjectDoesNotExist exception).
>
> Regards,
> Malcolm

The poblem is with the 'datetime.now' callable passed to my custom
manager. I was able to reproduce the same behavior by starting the
development server and manually changing the clock to a date in the
future. The 'object_detail' generic view of 'objects' created AFTER
the start date of the dev server (emulated by manually changing the
clock ...) are not accessible since the generic view seems to to some
kind of caching.

This behavior can be prevented by wrapping the generic view:

###
def object_detail(request):
return django.views.generic.list_detail.object_detail(
request,
queryset = Service.valid_objects.all()
)
###

It seems to me as if there is some magic going on ;)

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



Re: how to use django-profiles?

2009-03-13 Thread Simon Greenwood

That's correct, it has to be the name of the profile model as written
in app/models.py.

s/

On Mar 11, 5:25 am, Micah Ransdell  wrote:
> Viktor,
>
> Try capitalizing UserProfile so that it is 'membership.UserProfile' instead
> of all lowercase. That has worked for me in the past.
>
> Micah
>
> On Tue, Mar 10, 2009 at 5:03 PM, Viktor Nagy  wrote:
>
> > Hi,
>
> > I just can't figure out how to use django-profiles. I've an
> > application called ``membership``, and there I have a models.py file
> > containing:
>
> > class UserProfile(models.Model):
> >    user = models.ForeignKey(User, unique=True)
> >    affiliation = models.TextField(blank=False,
> >                                   help_text=_('Affiliation of the user'))
> >    conf_food_preference = models.CharField(max_length=10,
> > choices=FOOD_PREFERENCES,
> >                                    help_text=_('Special food
> > requirements'))
> >    conf_billing_address = models.TextField(blank=False,
> >                                    help_text=_('Billing address'))
> >    membership_active = models.DateField(blank=True, null=True,
> >                                         default=date.today,
> >                                         help_text=_('Membership
> > expires on this day'))
>
> >    def get_absolute_url(self):
> >        return ('profiles_profile_detail', (), {'username':
> > self.user.username})
>
> >    get_absolute_url = models.permalink(get_absolute_url)
>
> > finally I set AUTH_PROFILE_MODULE = 'membership.userprofile' in
> > settings.py, but I still get a ``SiteProfilenotAvailable`` exception.
>
> > Could someone help me out please? I'm sure that there is a blatant
> > thing I don't notice!
>
> > Thanks, V
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django-profile instance data on custom form

2009-03-13 Thread Simon Greenwood



On Mar 12, 3:11 pm, simong  wrote:
> I'm creating a profile form that includes first_name and last_name
> fields that write to the User model  and additional fields that write
> to my user profile model derived from Alex S's post 
> here:http://groups.google.com/group/django-users/msg/00e49ca16c63762c
>
> class UserProfileForm(forms.Form):
>         first_name = forms.CharField(max_length=128, required=False)
>         last_name = forms.CharField(max_length=128, required=False)
> # userprofile form
>         address1 = forms.CharField(widget=forms.TextInput(attrs={ 'size':
> '40' }), required=False)
>         address2 = forms.CharField(widget=forms.TextInput(attrs={ 'size':
> '40' }), required=False)
>         address3 = forms.CharField(widget=forms.TextInput(attrs={ 'size':
> '40' }), required=False)
>         towncity = forms.CharField(widget=forms.TextInput(attrs={ 'size':
> '40' }), required=False)
>         adminregion      = forms.CharField(widget=forms.TextInput(attrs={ 
> 'size':
> '40' }), required=False)
>         country = forms.CharField(max_length=128, required=False)
>         postcode = forms.CharField(max_length=10, required=False)
>         telno = forms.CharField(max_length=20, required=False)
>         email = forms.EmailField(required=False)
>
> I have implemented a save() method but haven't tested it yet.
>
> The urlpattern for this is:
>
> (r'^profiles/edit/$', 'profiles.views.edit_profile', { "form_class":
> UserProfileForm }, "profile_edit_profile")
>
> I can draw an instance of the form using django-profile's
> profile_edit_profile view but this is not currently populating the
> form with existing profile data. Following the django-profile docs, I
> have created an __init__ function for the form as follows:
>
>         def __init__(self, instance, *args, **kwargs):
>                 super(UserProfileForm, self).__init__(instance, *args, 
> **kwargs)
>                 self.instance = instance
>
> This returns a form because it creates an 'instance' keyword but
> doesn't populate it with data from profile_obj as called in views.py.
> Do I need to call profile_obj in my init function and how, or is it
> something else, or am I looking in the wrong direction. Document
> pointers are welcome as I can't find anything specific.
>

I'll answer myself: it is all in the docs, and after a bit more
reading a slightly more elegant solution is to create a ModelForm on
the UserProfile model, extend it by adding the required fields for the
User model and setting that form as the form_class. Now I'm a bit
stuck on passing the user object into the save() method but I'll have
it after a bit more head scratching. More detail when I can do that.

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



Admin dashboard : hide and merge modules

2009-08-17 Thread JF Simon

Hi men,

I'm using Django + Grappelli and I'd like to know if there is a simple
way to make some improvements to the dashboard (index) of the admin
such as :

- hide modules (like Django_Evolution)
- merge modules (Auth entries with my User module)
- rename existing modules (not for now, just to know)

I dont found anything so I'm not sure anyone can help...
Thanks for all (even if there is no way to do that !)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin dashboard : hide and merge modules

2009-08-17 Thread JF Simon

Thanks, I don't though about users perms !
Grappelli just turn your admin more pretty, you should try:
http://code.google.com/p/django-grappelli/ !
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Error in setting up psycopg2

2009-08-18 Thread Simon Lee

I am trying to set up a simple test website in the Apache Server that
comes with OSX 10.5.8 and continuously ran into errors that
complainted about not able to import something in pscycopg2. The site
works if I ran with the django development server. When I port to
Apache, it did not work. Can someone tell me what I am missing?



The set up is as followed:
Python
- version: 2.6
- installed location: /Library/Frameworks/Python.framework/Versions/
2.6/

Psycopg2
- version: 2.0.12
- installed location: /Library/Frameworks/Python.framework/Versions/
2.6/lib/python2.6/site-packages/psycopg2

Other installed components:
mod_wsgi-3.0c4



My test site stuff is in "/Users/myname/mysite3"

Inside "/Users/myname/mysite3", the following files and directories
exist:
- __init__.py
- manage.py
- settings.py
- urls.py
- apache (folder)
  - myapp.wsgi
- blog (django app folder)
  - __init__.py
  - models.py (empty)
  - views.py
- django (folder, symbolic link to the django directory)

--

The content of /mysite3/settings.py is as followed:
DATABASE_ENGINE = 'postgresql_psycopg2'
DATABASE_NAME = 'djangodb'
DATABASE_USER = 'postgres'
DATABASE_PASSWORD = 'myname'
DATABASE_HOST = 'localhost'
DATABASE_PORT = '5432'

ROOT_URLCONF = 'mysite3.urls'

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'mysite3.blog',
)

The rest of the settings are the default



The url address www.test-mysite.com is bind to /mysite3/apache/
myapp.wsgi with the following settings:

In "/etc/apache2/http.conf":
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

In "/private/etc/apache2/extra/httpd-vhosts.conf":

ServerName www.test-mysite.com
ServerAdmin webmas...@test-mysite.com
DocumentRoot "/Users/myname/wsgi/documents"
ServerAlias test-mysite.com
ErrorLog "/private/var/log/apache2/mysite.com-error_log"
CustomLog "/private/var/log/apache2/mysite.com-access_log" common


  Order allow,deny
  Allow from all



Order deny,allow
Allow from all


WSGIScriptAlias / /Users/myname/mysite3/apache/myapp.wsgi





The content of /mysite3/apache/myapp.wsgi is as followed:

import os, sys
sys.path.append('/Users/simonlee')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite3.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

---

When I entered www.test-mysite.com into the browser, it gave me the
following error message:

Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request

The following error was logged in my error log file:

[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=120): Exception occurred processing WSGI script '/Users/myname/
mysite3/apache/myapp.wsgi'.
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
myname/mysite3/django/core/handlers/wsgi.py", line 239, in __call__
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
myname/mysite3/django/core/handlers/base.py", line 67, in get_response
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
myname/mysite3/django/contrib/sessions/middleware.py", line 9, in
process_request
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] ImportError: No
module named db

--

I tried everything that I found on the web but nothing seems to work.
Any suggestion would be much appreciated.

Simon

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



Re: Error in setting up psycopg2

2009-08-19 Thread Simon Lee

Hi Thomas,

Tried your method and modified /mysite3/apache/myapp.wsgi as followed:

import os, sys
sys.path.append('/Users/myname')
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django')
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/psycopg2')

try:
import psycopg2 as Database
except ImportError, exc:
import sys
raise ImportError('%s %s' % (exc, sys.path))

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite3.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()



Now the error log is as followed:

[Wed Aug 19 23:58:54 2009] [info] [client 127.0.0.1] mod_wsgi
(pid=135, process='', application='www.test-mysite.com|'): Reloading
WSGI script '/Users/myname/mysite3/apache/myapp.wsgi'.
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=135): Target WSGI script '/Users/myname/mysite3/apache/
myapp.wsgi' cannot be loaded as Python module.
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=135): Exception occurred processing WSGI script '/Users/myname/
mysite3/apache/myapp.wsgi'.
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1]   File "/Users/
myname/mysite3/apache/myapp.wsgi", line 10, in 
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] raise
ImportError('%s %s' % (exc, sys.path))
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] ImportError:
cannot import name tz ['/Library/Frameworks/Python.framework/Versions/
2.6/lib/python26.zip', '/Library/Frameworks/Python.framework/Versions/
2.6/lib/python2.6', '/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/plat-darwin', '/Library/Frameworks/Python.framework/
Versions/2.6/lib/python2.6/plat-mac', '/Library/Frameworks/
Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-
scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/lib-tk', '/Library/Frameworks/Python.framework/Versions/
2.6/lib/python2.6/lib-old', '/Library/Frameworks/Python.framework/
Versions/2.6/lib/python2.6/lib-dynload', '/Library/Frameworks/
Python.framework/Versions/2.6/lib/python2.6/site-packages', '/Users/
myname', '/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django', '/Library/Frameworks/Python.framework/
Versions/2.6/lib/python2.6/site-packages/psycopg2']



Any idea? Please advise. Thanks.

Simon

On Aug 19, 10:44 pm, Thomas Guettler  wrote:
> Hi,
>
> you need to know what sys.path looks like. This is a list of
> searched directories.
>
> try:
>     import  # Import lines that failes
> except ImportError, exc:
>     import sys
>     raise ImportError('%s %s' % (exc, sys.path))
>
> Then check if the stuff you want to import is on sys.path.
>
> Simon Lee schrieb:
>
>
>
>
>
> > I am trying to set up a simple test website in the Apache Server that
> > comes with OSX 10.5.8 and continuously ran into errors that
> > complainted about not able to import something in pscycopg2. The site
> > works if I ran with the django development server. When I port to
> > Apache, it did not work. Can someone tell me what I am missing?
> > ...
> ...
> > The following error was logged in my error log file:
>
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] mod_wsgi
> > (pid=120): Exception occurred processing WSGI script '/Users/myname/
> > mysite3/apache/myapp.wsgi'.
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] Traceback (most
> > recent call last):
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
> > myname/mysite3/django/core/handlers/wsgi.py", line 239, in __call__
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
> > myname/mysite3/django/core/handlers/base.py", line 67, in get_response
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
> > myname/mysite3/django/contrib/sessions/middleware.py", line 9, in
> > process_request
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] ImportError: No
> > module named db
>
> Here you will find your ImportError and sys.path.
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error in setting up psycopg2

2009-08-20 Thread Simon Lee

tz.py is in the directory: "'/Library/Frameworks/Python.framework/
Versions/2.6/lib/python2.6/site-packages/psycopg2" which is in the
sys.path list. Why does the import still fail? Please advise.

Simon

On Aug 20, 4:37 pm, Thomas Guettler  wrote:
> The important part: cannot import tz.
>
> Maybe you need to install it. I don't this module.
>
>   Thomas
>
> Simon Lee schrieb:
>
>
>
>
>
> > Hi Thomas,
>
> > Tried your method and modified /mysite3/apache/myapp.wsgi as followed:
>
> > import os, sys
> > sys.path.append('/Users/myname')
> > sys.path.append('/Library/Frameworks/Python.framework/Versions/2.6/lib/
> > python2.6/site-packages/django')
> > sys.path.append('/Library/Frameworks/Python.framework/Versions/2.6/lib/
> > python2.6/site-packages/psycopg2')
>
> > try:
> >     import psycopg2 as Database
> > except ImportError, exc:
> >     import sys
> >     raise ImportError('%s %s' % (exc, sys.path))
>
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite3.settings'
> > import django.core.handlers.wsgi
> > application = django.core.handlers.wsgi.WSGIHandler()
>
> > 
>
> > Now the error log is as followed:
>
> > [Wed Aug 19 23:58:54 2009] [info] [client 127.0.0.1] mod_wsgi
> > (pid=135, process='', application='www.test-mysite.com|'): Reloading
> > WSGI script '/Users/myname/mysite3/apache/myapp.wsgi'.
> > [Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] mod_wsgi
> > (pid=135): Target WSGI script '/Users/myname/mysite3/apache/
> > myapp.wsgi' cannot be loaded as Python module.
> > [Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] mod_wsgi
> > (pid=135): Exception occurred processing WSGI script '/Users/myname/
> > mysite3/apache/myapp.wsgi'.
> > [Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] Traceback (most
> > recent call last):
> > [Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1]   File "/Users/
> > myname/mysite3/apache/myapp.wsgi", line 10, in 
> > [Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1]     raise
> > ImportError('%s %s' % (exc, sys.path))
> > [Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] ImportError:
> > cannot import name tz ['/Library/Frameworks/Python.framework/Versions/
> > 2.6/lib/python26.zip', '/Library/Frameworks/Python.framework/Versions/
> > 2.6/lib/python2.6', '/Library/Frameworks/Python.framework/Versions/2.6/
> > lib/python2.6/plat-darwin', '/Library/Frameworks/Python.framework/
> > Versions/2.6/lib/python2.6/plat-mac', '/Library/Frameworks/
> > Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-
> > scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.6/
> > lib/python2.6/lib-tk', '/Library/Frameworks/Python.framework/Versions/
> > 2.6/lib/python2.6/lib-old', '/Library/Frameworks/Python.framework/
> > Versions/2.6/lib/python2.6/lib-dynload', '/Library/Frameworks/
> > Python.framework/Versions/2.6/lib/python2.6/site-packages', '/Users/
> > myname', '/Library/Frameworks/Python.framework/Versions/2.6/lib/
> > python2.6/site-packages/django', '/Library/Frameworks/Python.framework/
> > Versions/2.6/lib/python2.6/site-packages/psycopg2']
>
> > 
>
> > Any idea? Please advise. Thanks.
>
> > Simon
>
> > On Aug 19, 10:44 pm, Thomas Guettler  wrote:
> >> Hi,
>
> >> you need to know what sys.path looks like. This is a list of
> >> searched directories.
>
> >> try:
> >>     import  # Import lines that failes
> >> except ImportError, exc:
> >>     import sys
> >>     raise ImportError('%s %s' % (exc, sys.path))
>
> >> Then check if the stuff you want to import is on sys.path.
>
> >> Simon Lee schrieb:
>
> >>> I am trying to set up a simple test website in the Apache Server that
> >>> comes with OSX 10.5.8 and continuously ran into errors that
> >>> complainted about not able to import something in pscycopg2. The site
> >>> works if I ran with the django development server. When I port to
> >>> Apache, it did not work. Can someone tell me what I am missing?
> >>> ...
> >> ...
> >>> The following error was logged in my error log file:
> >>> [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] mod_wsgi
> >>> (pid=120): Exception occurred processing WSGI scr

Re: Error in setting up psycopg2

2009-08-21 Thread Simon Lee

Hi Thomas,

Ok, I put in the "assert False, os.getuid()". The error log logged the
following:

[Fri Aug 21 23:37:48 2009] [error] [client 127.0.0.1] assert
False, os.getuid()
[Fri Aug 21 23:37:48 2009] [error] [client 127.0.0.1] AssertionError:
70

Then, I go the shell and entered "su - 70". It asked for the password.
I entered my root password, that's the only password that I set before
and the only password I know. But it said the password is wrong. I
cannot go any further as your advised. What should I do? I am not too
familiar with using Linux. Please help.

Simon

On Aug 21, 2:18 pm, Thomas Guettler  wrote:
> Hi Simon,
>
> it could be a permission problem:
>
> in the code do something like
>
> assert False, os.getuid().
>
> then on the shell, you need get this user:
> su - corresponding-user
> id # check if you have this UID
> #try to open the file:
> more /.../tz.py
>
> HTH,
>   Thomas
>
> Simon Lee schrieb:
>
> > tz.py is in the directory: "'/Library/Frameworks/Python.framework/
> > Versions/2.6/lib/python2.6/site-packages/psycopg2" which is in the
> > sys.path list. Why does the import still fail? Please advise.
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error in setting up psycopg2

2009-08-21 Thread Simon Lee

Thank you for being patient in helping me out.

I checked it /etc/passwd and found this line which I think is the
reference for UID 70

_www:*:70:70:World Wide Web Server:/Library/WebServer:/usr/bin/false

I did "su - _www" (I hope I did this right). It still asked for a
password which I entered my root password (the only password that I
know) and it complained that the password is wrong.

Please advise.

Simon

On Aug 22, 2:30 am, Randy Barlow  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Simon Lee declared:
>
> > Hi Thomas,
>
> > Ok, I put in the "assert False, os.getuid()". The error log logged the
> > following:
>
> > [Fri Aug 21 23:37:48 2009] [error] [client 127.0.0.1]     assert
> > False, os.getuid()
> > [Fri Aug 21 23:37:48 2009] [error] [client 127.0.0.1] AssertionError:
> > 70
>
> > Then, I go the shell and entered "su - 70". It asked for the password.
> > I entered my root password, that's the only password that I set before
> > and the only password I know. But it said the password is wrong. I
> > cannot go any further as your advised. What should I do? I am not too
> > familiar with using Linux. Please help.
>
> The problem is that su wants a username and you are giving it a user id.
>  You can look in /etc/passwd to see what user has UID 70 and then su -
> .
>
> - --
> Randy Barlow
> Software Developer
> The American Research Institutehttp://americanri.com
> 919.228.4971
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2.0.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org
>
> iEYEARECAAYFAkqO58wACgkQw3vjPfF7QfVV7gCfTU3JLho3zVZ7viiHWJefkF6z
> o1wAnjgRLCGgNF4sGSL5d/iSyhMtph9/
> =hkaK
> -END PGP SIGNATURE-
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error in setting up psycopg2

2009-08-25 Thread Simon Lee
Hi Thomas,
When I typed the following into my python console as advised:
>>> from django.contrib.session.backends import db
I got the following error:
Traceback (most recent call last):  File "", line 1, in   File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/contrib/sessions/backends/db.py",
 line 2, in     from django.contrib.sessions.models import 
Session  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/contrib/sessions/models.py",
 line 4, in     from django.db import models  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/__init__.py",
 line 10, in     if not settings.DATABASE_ENGINE:  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/utils/functional.py",
 line 269, in __getattr__    self._setup()  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/conf/__init__.py",
 line 38, in _setup    raise ImportError("Settings cannot be
 imported, because environment variable %s is undefined." % 
ENVIRONMENT_VARIABLE)ImportError: Settings cannot be imported, because 
environment variable DJANGO_SETTINGS_MODULE is undefined.
I searched "/Users/myname/mysite3/settings.py" for the variable SESSION_ENGINE 
but it is not defined in that file. I don't know where settings.SESSION_ENGINE 
is defined???
Simon

--- On Mon, 8/24/09, Thomas Guettler  wrote:

From: Thomas Guettler 
Subject: Re: Error in setting up psycopg2
To: "Simon Lee" , django-users@googlegroups.com
Date: Monday, August 24, 2009, 11:17 PM


Hi Simon,

your first traceback looked like this:

[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=120): Exception occurred processing WSGI script '/Users/myname/
mysite3/apache/myapp.wsgi'.
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
myname/mysite3/django/core/handlers/wsgi.py", line 239, in __call__
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
myname/mysite3/django/core/handlers/base.py", line 67, in get_response
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
myname/mysite3/django/contrib/sessions/middleware.py", line 9, in
process_request
[Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] ImportError: No
module named db

My line 9 of middleware.py of sessions looks like this:
engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])

What does your variable settings.SESSION_ENGINE look like?

Is it 'django.contrib.sessions.backends.db'?

Try to import this as www user:
w...@host> python
>>> from django.contrib.session.backends import db

Does this work?

Simon Lee schrieb:
> You are right. I am a newbie on Linux, trying hard to learn it at the
> same time with the other stuff.
> 
> I did the following in the shell:
> 
> macbook:~myname$ su
> Password: 
> sh-3.2# su - _www
> sh-3.2# more /Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/site-packages/psycopg2/tz.py
> 
> I can read the file with more. Seems that there is no problem on
> permission. Please advise.
> 


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de





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



Re: Error in setting up psycopg2

2009-08-25 Thread Simon Lee

Hi Thomas,

I did a Google search and did as one suggestion:
$ export PYTHONPATH=$HOME/:$PYTHONPATH
$ export DJANGO_SETTINGS_MODULE=mysite3.settings
$ python
>>> from django.contrib.sessions.backends import db

It works with no error. The same thing works if I do "python manage.py
shell" without the export.

That does not solve my problem though. I changed myapp.wsgi to the
following:

--

import os, sys
sys.path.append('/Users/simonlee')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite3.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

--

It shows the following error in my log:

[Tue Aug 25 19:12:24 2009] [info] [client 127.0.0.1] mod_wsgi
(pid=170, process='', application='www.test-hago-group.com|'): Loading
WSGI script '/Users/simonlee/mysite3/apache/myapp.wsgi'.
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=170): Exception occurred processing WSGI script '/Users/simonlee/
mysite3/apache/myapp.wsgi'.
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/core/handlers/wsgi.py", line 241, in __call__
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] response =
self.get_response(request)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/core/handlers/base.py", line 73, in get_response
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] response =
middleware_method(request)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/contrib/sessions/middleware.py", line 10, in process_request
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] engine =
import_module(settings.SESSION_ENGINE)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/utils/importlib.py", line 35, in import_module
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] __import__
(name)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/contrib/sessions/backends/db.py", line 2, in 
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] from
django.contrib.sessions.models import Session
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/contrib/sessions/models.py", line 4, in 
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] from
django.db import models
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/db/__init__.py", line 41, in 
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] backend =
load_backend(settings.DATABASE_ENGINE)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/db/__init__.py", line 17, in load_backend
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] return
import_module('.base', 'django.db.backends.%s' % backend_name)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/utils/importlib.py", line 35, in import_module
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] __import__
(name)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
django/db/backends/postgresql_psycopg2/base.py", line 22, in 
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] raise
ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]
ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   Referenced
from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
site-packages/psycopg2/_psycopg.so
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   Expected in:
dynamic lookup
[Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]

---

I did a search on the web but found only two links on similar error
without any solution. Does anyone know what caused "Symbol not foun

Re: Is valid {% ifequal model.name "Mymodelname" %}??

2009-09-02 Thread JF Simon

Be more specific, is model in the context ? is name a property of
model ?


On 2 sep, 17:44, Sandra Django  wrote:
> Hi friends, Can I do a condition depending on my model name? For example, I
> did that:
> {% ifequal model.name "Mymodelname" %}
>      do something
> {% endifequal %}
>
> But don't work. Someone could help me?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django admin templates not loading

2009-09-09 Thread Simon Lee

Hi All,

I am following the tutorial in the Django website (writing your first
django app) and get it to work on the development server. However,
when I port to Apache, the admin template is not loaded and thus I
could not get the nice Django UI with Apache. I try copying the
default django admin templates into my project root and add the path
to the TEMPLATE_DIRS in settings.py but still cannot get the django UI
in the login page and the admin dashboard.

Below is my settings:

OS: Fedora 11
Apache: 2.2 with mod_wsgi
Django: 1.1

--

Projects/App:

/var/www/mysite/
apache/
 myapp.wsgi
polls/
admin.py
__init__.py
models.py
tests.py
templates/
 admin/
  base_site.html
__init__.py
manage.py
settings.py
urls.py

--

 Settings.py

# Django settings for mysite project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@domain.com'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'postgresql_psycopg2'   #
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'mytestdb' # Or path to database file if
using sqlite3.
DATABASE_USER = 'postgres' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost.
Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com";, "http://example.com/media/";
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/";, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'rg+av$-m5%#hs47_^24c54wi!*gauqz4ya1o*^0vjo7&xh3=n&'

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'mysite.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/var/www/mysite/templates',
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'mysite.polls',
'django.contrib.admin'
)

--

myapp.wsgi

import os
import sys

sys.path.append('/var/www')

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

---

urls.py

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
)

---

When I typed in http://127.0.0.1:8000/myapp/admin in the browser when
the development server runs the code. The output is perfect.

When the development server is not running and I typed in
http://localhost/myapp/admin, it prompt me the login page but without
all the styling as before. I can login and go to the admin dashboard
page but aga

Re: Django admin templates not loading

2009-09-11 Thread Simon Lee

Hi Karen,

Thank you for pointing this out. I followed your advise and it works
beautifully.

As you see, I am a newbie to all these. On another subject, is there a
preferred location to put the production website(s) files/directories
on Linux? Is it right to put them in /var/www/ or should I put them
in /Users/my_name/??? How should I set the permission of the files/
directories under the production sites' directories? Should I set the
user/group to be apache, root, or just under my_name? Please advise.

Simon

On Sep 9, 7:52 pm, Karen Tracey  wrote:
> On Wed, Sep 9, 2009 at 7:23 AM, Simon Lee  wrote:
>
> > Hi All,
>
> > I am following the tutorial in the Django website (writing your first
> > django app) and get it to work on the development server. However,
> > when I port to Apache, the admin template is not loaded and thus I
> > could not get the nice Django UI with Apache. I try copying the
> > default django admin templates into my project root and add the path
> > to the TEMPLATE_DIRS in settings.py but still cannot get the django UI
> > in the login page and the admin dashboard.
>
> > Below is my settings:
>
> > OS: Fedora 11
> > Apache: 2.2 with mod_wsgi
> > Django: 1.1
>
> > [snip]
> >  Settings.py
>
> > [snip]
> > # URL prefix for admin media -- CSS, JavaScript and images. Make sure
> > to use a
> > # trailing slash.
> > # Examples: "http://foo.com/media/";, "/media/".
> > ADMIN_MEDIA_PREFIX = '/media/'
>
> > [snip]
>
> When I typed inhttp://127.0.0.1:8000/myapp/adminin the browser when> the 
> development server runs the code. The output is perfect.
>
> > When the development server is not running and I typed in
> >http://localhost/myapp/admin, it prompt me the login page but without
> > all the styling as before. I can login and go to the admin dashboard
> > page but again the display is not with the django admin template.
>
> Missing styling means missing CSS, and has nothing to do with templates.
> The fact that the pages are getting delivered without template not found
> exceptions means there is not a problem with templates (and you should un-do
> copying the admin templates into your own tree as that is likely just to
> cause confusion down the road.)
>
> You need to set up your Apache server to serve the admin media files (which
> will have urls starting with ADMIN_MEDIA_PREFIX).  These are static files
> and so not served by Django, except when you are running the development
> server there is an admin media server that automagically serves them out of
> the Django source tree.  The files are located under
> django/contrib/admin/media. The doc for setting up static file serving with
> mod_wsgi is here:
>
> http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/#servin...
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: fail_message 'changed' when updating form

2009-04-03 Thread Simon Greenwood



On Apr 3, 4:05 pm, Ayaz Ahmed Khan  wrote:
> On 03-Apr-09, at 7:43 PM, simong wrote:
>
> >   if request.method == 'POST':
> >       productform = ProductForm(request.POST, instance=product)
> >       productform.user = user
> >       if productform.is_valid:
>
> `is_valid` is a method bound to the BaseForm class. The expression in
> the snippet above _will_ evaluate to True because it will return a
> reference to the bound method, as opposed to return nothing, but will
> not, of course, execute the referenced method.
>

I have now removed the instance, which I suspected wasn't necessary
anyway, and I still get the same attribute error. It also occurs if I
create a new product, and there is still this lack of useful error
information.

It would appear that is_valid doesn't return False, or at least not
True as I seem to be reaching a contradictory traceback.

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



Re: fail_message 'changed' when updating form

2009-04-03 Thread Simon Greenwood



On Apr 3, 5:42 pm, Karen Tracey  wrote:
> On Fri, Apr 3, 2009 at 12:07 PM, Simon Greenwood wrote:
>
>
>
>
>
> > On Apr 3, 4:05 pm, Ayaz Ahmed Khan  wrote:
> > > On 03-Apr-09, at 7:43 PM, simong wrote:
>
> > > >   if request.method == 'POST':
> > > >       productform = ProductForm(request.POST, instance=product)
> > > >       productform.user = user
> > > >       if productform.is_valid:
>
> > > `is_valid` is a method bound to the BaseForm class. The expression in
> > > the snippet above _will_ evaluate to True because it will return a
> > > reference to the bound method, as opposed to return nothing, but will
> > > not, of course, execute the referenced method.
>
> > I have now removed the instance, which I suspected wasn't necessary
> > anyway, and I still get the same attribute error. It also occurs if I
> > create a new product, and there is still this lack of useful error
> > information.
>
> > It would appear that is_valid doesn't return False, or at least not
> > True as I seem to be reaching a contradictory traceback.
>
> Right, that's what Ayaz was trying to say.  is_valid is a method.
> productform.is_valid will always return true -- it's a reference to a
> method.  You need to call the method: productform.is_valid().  The code that
> you have right now is not even attempting to execute the validation logic.
>

Ah, that *is* me being dim. Serves me right for not paying attention
and cutting and pasting.

I now appear to be getting an error from mysql, so I can probably
track that down.

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



Re: Passing a dynamic ChoiceField response to a ForeignKey instance

2009-05-18 Thread Simon Greenwood



On May 15, 5:58 pm, simong  wrote:
> There's probably a very simple answer to this but I can't see it at
> the moment:
>
> This model:
>
> class Product(models.Model):
>         user = models.ForeignKey(User, related_name="product_list",
> editable=False)
>         productid = models.CharField(max_length=40, blank=True)
>         prodname = models.CharField(max_length=255, verbose_name='Product
> name')
>         proddesc = models.TextField(blank=True, verbose_name='Description')
>         prodtopcat = models.ForeignKey(ProductTopCategory,
> verbose_name='Product Main Category')
>         prodsubcat = models.ForeignKey(ProductSubCategory,
> verbose_name='Product Sub Category')
>         unit = models.ForeignKey(Units, verbose_name='Unit')
>         video = models.ManyToManyField('Video', blank=True,
> verbose_name='Video')
>         costperunit = models.DecimalField(max_digits=6, decimal_places=2,
> verbose_name='Cost per unit')
>         costperlot = models.DecimalField(max_digits=6, decimal_places=2,
> verbose_name='Cost per lot')
>         available = models.BooleanField(default=True)
>         featured = models.BooleanField(blank=True, null=True)
>
> is used to generate a ModelForm with two modified fields that enable
> the field 'prodsubcat' to be dynamically populated based on the
> selection of 'prodtopcat'.
>
> class DynamicChoiceField(forms.ChoiceField):
>         def clean(self, value):
>                 return value
>
> class ProductForm(ModelForm):
>         prodsubcat = DynamicChoiceField(widget=forms.Select(attrs=
> {'disabled': 'true'}), choices =(('-1', 'Select Top Category'),))
>
> I took this from an item I found on the web. I think setting the
> 'disabled' attribute is all I actually need.
>
> The dynamic lookup is performed using jQuery.getJSON with this view:
>
> def feeds_subcat(request, cat_id):
>         from django.core import serializers
>         json_subcat = serializers.serialize("json",
> ProductSubCategory.objects.filter(prodcat = cat_id), fields=('id',
> 'shortname', 'longname'))
>         return HttpResponse(json_subcat, mimetype="application/javascript")
>
> and the SELECT HTML is generated like this:
>
> options += '' + j[i].fields
> ['longname'] + '';
>
> This all works, but on submitting the form, I get the error 'Cannot
> assign "u'17'": "Product.prodsubcat" must be a "ProductSubCategory"
> instance' where "u'17'" is the option value of id_prodsubcat
>
> What type of variable should I be passing (I assume int) and where
> should I be converting it? In validation, in the pre-save signal, in
> the save signal? Or should I be trying to convert it on the form
> itself? Where is the ForeignKey instance save process documented?
>

To bump this and to add more detail: now, when I attempt to save the
form, I am getting the error 'Cannot assign "u'266'":
"Product.prodsubcat" must be a "ProductSubCategory" instance.' where
266 is the primary key of the ProductSubCategory object selected from
a list that is looked up by the selection of a ProductTopCategory
option as shown in the Product model above. How can I return a
ProductSubCategory instance from the variable at form save time?

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



Re: Passing a dynamic ChoiceField response to a ForeignKey instance

2009-05-18 Thread Simon Greenwood



On May 18, 12:02 pm, Simon Greenwood  wrote:
> On May 15, 5:58 pm, simong  wrote:
>
>
>
> > There's probably a very simple answer to this but I can't see it at
> > the moment:
>
> > This model:
>
> > class Product(models.Model):
> >         user = models.ForeignKey(User, related_name="product_list",
> > editable=False)
> >         productid = models.CharField(max_length=40, blank=True)
> >         prodname = models.CharField(max_length=255, verbose_name='Product
> > name')
> >         proddesc = models.TextField(blank=True, verbose_name='Description')
> >         prodtopcat = models.ForeignKey(ProductTopCategory,
> > verbose_name='Product Main Category')
> >         prodsubcat = models.ForeignKey(ProductSubCategory,
> > verbose_name='Product Sub Category')
> >         unit = models.ForeignKey(Units, verbose_name='Unit')
> >         video = models.ManyToManyField('Video', blank=True,
> > verbose_name='Video')
> >         costperunit = models.DecimalField(max_digits=6, decimal_places=2,
> > verbose_name='Cost per unit')
> >         costperlot = models.DecimalField(max_digits=6, decimal_places=2,
> > verbose_name='Cost per lot')
> >         available = models.BooleanField(default=True)
> >         featured = models.BooleanField(blank=True, null=True)
>
> > is used to generate a ModelForm with two modified fields that enable
> > the field 'prodsubcat' to be dynamically populated based on the
> > selection of 'prodtopcat'.
>
> > class DynamicChoiceField(forms.ChoiceField):
> >         def clean(self, value):
> >                 return value
>
> > class ProductForm(ModelForm):
> >         prodsubcat = DynamicChoiceField(widget=forms.Select(attrs=
> > {'disabled': 'true'}), choices =(('-1', 'Select Top Category'),))
>
> > I took this from an item I found on the web. I think setting the
> > 'disabled' attribute is all I actually need.
>
> > The dynamic lookup is performed using jQuery.getJSON with this view:
>
> > def feeds_subcat(request, cat_id):
> >         from django.core import serializers
> >         json_subcat = serializers.serialize("json",
> > ProductSubCategory.objects.filter(prodcat = cat_id), fields=('id',
> > 'shortname', 'longname'))
> >         return HttpResponse(json_subcat, mimetype="application/javascript")
>
> > and the SELECT HTML is generated like this:
>
> > options += '' + j[i].fields
> > ['longname'] + '';
>
> > This all works, but on submitting the form, I get the error 'Cannot
> > assign "u'17'": "Product.prodsubcat" must be a "ProductSubCategory"
> > instance' where "u'17'" is the option value of id_prodsubcat
>
> > What type of variable should I be passing (I assume int) and where
> > should I be converting it? In validation, in the pre-save signal, in
> > the save signal? Or should I be trying to convert it on the form
> > itself? Where is the ForeignKey instance save process documented?
>
> To bump this and to add more detail: now, when I attempt to save the
> form, I am getting the error 'Cannot assign "u'266'":
> "Product.prodsubcat" must be a "ProductSubCategory" instance.' where
> 266 is the primary key of the ProductSubCategory object selected from
> a list that is looked up by the selection of a ProductTopCategory
> option as shown in the Product model above. How can I return a
> ProductSubCategory instance from the variable at form save time?


To answer myself, this post: 
http://monogroncho.com/2008/10/django-gotchas-part-1/
is exactly what I was looking for, although the code as given seems
rather inelegant and gives me the AttributeError 'list' object has no
attribute 'widget'. My feeling is that I don't have to be returning a
list of ProductSubCategory objects, just the one that my choice
represents. Does anyone have a view on this? I can't be the only
person combining django and Ajax in this way.

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



Re: Passing a dynamic ChoiceField response to a ForeignKey instance

2009-05-19 Thread Simon Greenwood



On May 18, 3:32 pm, Simon Greenwood  wrote:
> On May 18, 12:02 pm, Simon Greenwood  wrote:
>
>
>
> > On May 15, 5:58 pm, simong  wrote:
>
> > > There's probably a very simple answer to this but I can't see it at
> > > the moment:
>
> > > This model:
>
> > > class Product(models.Model):
> > >         user = models.ForeignKey(User, related_name="product_list",
> > > editable=False)
> > >         productid = models.CharField(max_length=40, blank=True)
> > >         prodname = models.CharField(max_length=255, verbose_name='Product
> > > name')
> > >         proddesc = models.TextField(blank=True, 
> > > verbose_name='Description')
> > >         prodtopcat = models.ForeignKey(ProductTopCategory,
> > > verbose_name='Product Main Category')
> > >         prodsubcat = models.ForeignKey(ProductSubCategory,
> > > verbose_name='Product Sub Category')
> > >         unit = models.ForeignKey(Units, verbose_name='Unit')
> > >         video = models.ManyToManyField('Video', blank=True,
> > > verbose_name='Video')
> > >         costperunit = models.DecimalField(max_digits=6, decimal_places=2,
> > > verbose_name='Cost per unit')
> > >         costperlot = models.DecimalField(max_digits=6, decimal_places=2,
> > > verbose_name='Cost per lot')
> > >         available = models.BooleanField(default=True)
> > >         featured = models.BooleanField(blank=True, null=True)
>
> > > is used to generate a ModelForm with two modified fields that enable
> > > the field 'prodsubcat' to be dynamically populated based on the
> > > selection of 'prodtopcat'.
>
> > > class DynamicChoiceField(forms.ChoiceField):
> > >         def clean(self, value):
> > >                 return value
>
> > > class ProductForm(ModelForm):
> > >         prodsubcat = DynamicChoiceField(widget=forms.Select(attrs=
> > > {'disabled': 'true'}), choices =(('-1', 'Select Top Category'),))
>
> > > I took this from an item I found on the web. I think setting the
> > > 'disabled' attribute is all I actually need.
>
> > > The dynamic lookup is performed using jQuery.getJSON with this view:
>
> > > def feeds_subcat(request, cat_id):
> > >         from django.core import serializers
> > >         json_subcat = serializers.serialize("json",
> > > ProductSubCategory.objects.filter(prodcat = cat_id), fields=('id',
> > > 'shortname', 'longname'))
> > >         return HttpResponse(json_subcat, 
> > > mimetype="application/javascript")
>
> > > and the SELECT HTML is generated like this:
>
> > > options += '' + j[i].fields
> > > ['longname'] + '';
>
> > > This all works, but on submitting the form, I get the error 'Cannot
> > > assign "u'17'": "Product.prodsubcat" must be a "ProductSubCategory"
> > > instance' where "u'17'" is the option value of id_prodsubcat
>
> > > What type of variable should I be passing (I assume int) and where
> > > should I be converting it? In validation, in the pre-save signal, in
> > > the save signal? Or should I be trying to convert it on the form
> > > itself? Where is the ForeignKey instance save process documented?
>
> > To bump this and to add more detail: now, when I attempt to save the
> > form, I am getting the error 'Cannot assign "u'266'":
> > "Product.prodsubcat" must be a "ProductSubCategory" instance.' where
> > 266 is the primary key of the ProductSubCategory object selected from
> > a list that is looked up by the selection of a ProductTopCategory
> > option as shown in the Product model above. How can I return a
> > ProductSubCategory instance from the variable at form save time?
>
> To answer myself, this 
> post:http://monogroncho.com/2008/10/django-gotchas-part-1/
> is exactly what I was looking for, although the code as given seems
> rather inelegant and gives me the AttributeError 'list' object has no
> attribute 'widget'. My feeling is that I don't have to be returning a
> list of ProductSubCategory objects, just the one that my choice
> represents. Does anyone have a view on this? I can't be the only
> person co

setting choices on choice field dynamically according to objects current state

2009-05-25 Thread Simon Davies

I have a choices field called status in my model form which can be set
to a number of values, however the options available will be based on
its current state something like this, so it needs to refer to itself:

class ContractForm(ModelForm):

def getStatusChoices()
   if status == 'r':
return (('C', 'Confirmed'), ('N', 'Cancelled))
  elif status == 'C':
return (('M', 'Completed'), ('P', 'Paid'))
  

 status = fields.ChoiceField(choices=getStatusChoices())

I read in another thread that you can do this by accessing and setting
the self.fields['status'] which contains the status state  of the
current object and is created by the meta form class.  How do I access
self in the model function.  If i pass it in as a parameter to the
method as shown below what should the function call look like in the
status field, i.e. how do I refer to the current object to be passed.

def getStatusChoices(self):
if not self.key:
self.fields['STATUS'] = (('R', 'Requested'),
('C', 'Confirmed'))
elif self.fields['STATUS'] == 'R':
self.fields['STATUS'] = (('N', 'Cancelled'),
('C', 'Confirmed'))
return self

Thanks

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



Re: setting choices on choice field dynamically according to objects current state

2009-05-27 Thread Simon Davies

Thanks v

What you said echoes what I found on a posting on djangosnippet.org
about populating the choices in the init field.  It works fine now.

On May 26, 9:30 am, V  wrote:
> On May 25, 1:27 pm, Simon Davies  wrote:
>
>
>
> > I have a choices field called status in my model form which can be set
> > to a number of values, however the options available will be based on
> > its current state something like this, so it needs to refer to itself:
>
> > class ContractForm(ModelForm):
>
> > def getStatusChoices()
> >    if status == 'r':
> >             return (('C', 'Confirmed'), ('N', 'Cancelled))
> >   elif status == 'C':
> >             return (('M', 'Completed'), ('P', 'Paid'))
> >   
>
> >  status = fields.ChoiceField(choices=getStatusChoices())
>
> > I read in another thread that you can do this by accessing and setting
> > the self.fields['status'] which contains the status state  of the
> > current object and is created by the meta form class.  How do I access
> > self in the model function.  If i pass it in as a parameter to the
> > method as shown below what should the function call look like in the
> > status field, i.e. how do I refer to the current object to be passed.
>
> >         def getStatusChoices(self):
> >                 if not self.key:
> >                         self.fields['STATUS'] = (('R', 'Requested'),
> > ('C', 'Confirmed'))
> >                 elif self.fields['STATUS'] == 'R':
> >                         self.fields['STATUS'] = (('N', 'Cancelled'),
> > ('C', 'Confirmed'))
> >                 return self
>
> > Thanks
>
> > Simon
>
> Hi,
>
> it might help if you post a bit more from your form definition, but
> I'll try to answer. Take the following example:
>
> class MyForm(forms.Form):
>
>   status_choices = forms.ChoiceField(choices=(('0', 'False'),))
>
>   def __init__(self, *args, **kwargs):
>     super(MyForm, self).__init__(*args, **kwargs)
>     if kwargs.has_key('initial') and kwargs['initial'].has_key
> ('status'):
>       self.fields['status_choices'].choices = getStatusChoices(kwargs
> ['initial']['status']
>
> that is you would like to set the available choices for the
> status_choices field. You do this in the form's __init__ method. First
> you initialise the form as usual (see the super line), then you adjust
> the choices value of the status_choices field. Clearly, in my setting
> the getStatusChoices function should return a valid choices tuple.
>
> have a nice day
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: URL rewriting Middleware

2009-06-14 Thread JF Simon

OK, I found, I have to write the path in request.path_info !!!
It works !
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



MultiWidget fail to render without exception

2009-09-23 Thread JF Simon

Hi there !

I try to understand why my form doesn't render anything. No exception
is raised and i'm going crazy !
In my forms.py I got these (simplified for instance) classes :

class SignupPasswordWidget(forms.MultiWidget):

def __init__(self, attrs=None):
widgets = (
forms.PasswordInput(attrs={'class': 'first-password'}),
forms.PasswordInput(attrs={'class': 'second-password'})
)
super(SignupPasswordWidget, self).__init__(widgets, attrs)

def decompress(self, value):
return value


class SignupPasswordField(forms.MultiValueField):

widget = SignupPasswordWidget

def compress(self, data_list):
return data_list

def clean(self, value):
if len(value[0]) is 0:
raise forms.ValidationError(_(u"Vous devez spécifier votre
mot de passe"))
elif len(value[1]) is 0:
raise forms.ValidationError(_(u"Vous devez confirmer votre
mot de passe"))
if not value[0] == value[1]:
raise forms.ValidationError(_(u"Votre mot de passe et sa
confirmation doivent être identiques"))
return value[0]


class SignupForm(forms.Form):

password   = SignupPasswordField(label=_(u"Mot de passe"))


In my template I just put "form.as_table()". If I remove "widget =
SignupPasswordWidget" in "SignupPasswordField", I show my (single)
password field. What am I doing wrong ?? Why don't I get an
Exception ? I tried many things like implement format_output or render
methods, but I still get nothing.

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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MultiWidget fail to render without exception

2009-09-24 Thread JF Simon

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



Re: MultiWidget fail to render without exception

2009-09-24 Thread JF Simon

Ouh thanks ... because of the TEMPLATE_DEBUG setting, I though
exceptions within templates were raised ... my sentence seems weird.
Ill try that tonight.
Thanks again.

JF

On 24 sep, 14:42, Karen Tracey  wrote:
> On Thu, Sep 24, 2009 at 2:49 AM, JF Simon  wrote:
>
> > Hi there !
>
> > I try to understand why my form doesn't render anything. No exception
> > is raised and i'm going crazy !
> > In my forms.py I got these (simplified for instance) classes :
>
> > [snip code]
>
> > In my template I just put "form.as_table()". If I remove "widget =
> > SignupPasswordWidget" in "SignupPasswordField", I show my (single)
> > password field. What am I doing wrong ?? Why don't I get an
> > Exception ? I tried many things like implement format_output or render
> > methods, but I still get nothing.
>
> Template rendering suppresses exceptions raised by called methods.  So if
> form.as_table() raises an exception you won't see it in your template,
> you'll just get no output.  Try instantiating your form from a python
> manage.py shell session, and see what as_table() does when you call it
> there.  The results will likely point you toward the fact that having
> compress and decompress methods that simply return their arguments isn't
> going to work.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MultiWidget fail to render without exception

2009-09-24 Thread JF Simon

I launched form.as_table() in my terminal and the traceback is :

  File "", line 1, in ?
  File "/usr/lib/python2.4/site-packages/django/forms/forms.py", line
190, in as_table
return self._html_output(u'%(label)s%(errors)s%
(field)s%(help_text)s', u'%s',
'', u'%s', False)
  File "/usr/lib/python2.4/site-packages/django/forms/forms.py", line
165, in _html_output
output.append(normal_row % {'errors': force_unicode(bf_errors),
'label': force_unicode(label), 'field': unicode(bf), 'help_text':
help_text})
  File "/usr/lib/python2.4/site-packages/django/forms/forms.py", line
356, in __unicode__
return self.as_widget()
  File "/usr/lib/python2.4/site-packages/django/forms/forms.py", line
391, in as_widget
return widget.render(name, data, attrs=attrs)
  File "/usr/lib/python2.4/site-packages/django/forms/widgets.py",
line 647, in render
widget_value = value[i]

And now the famous error :

  TypeError: unsubscriptable object

It seems that "value" is not iterable or something like that ... I
don't understand.
I tried some things but I always get the same error.

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



Re: MultiWidget fail to render without exception

2009-09-24 Thread JF Simon

Ah I found something ...

In my forms.MultiWidget subclass, "decompress" method was returning
None and not a couple of values !
I just done that :

def decompress(self, value):
if value is None:
return (None, None)
return value

I don't know if it's the best way, but it's working !!
Thank you Karen for your support !!
I can now go to sleep
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Cannot build psycopg2 in x86_64

2009-09-28 Thread Simon Lee

I am trying to deploy the django app that from the django development
server to the Apache on Leopard. When I try to launch the app from my
browser, I got a "Internal Server Error". I checked the error_log and
here's the error:

[Mon Sep 28 00:43:29 2009] [error] [client 127.0.0.1]
ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/
simonlee/django/lib/python2.5/site-packages/psycopg2/_psycopg.so, 2):
no suitable image found.  Did find:
[Mon Sep 28 00:43:29 2009] [error] [client 127.0.0.1] \t/Users/
simonlee/django/lib/python2.5/site-packages/psycopg2/_psycopg.so: no
matching architecture in universal wrapper

I did google search and follow the advise on

http://ronny.haryan.to/archives/2008/09/12/psycopg2-and-64-bit-apache-on-leopard/

After the build as advise on that article, I only get _psycopg.so for
2 architectures: i386 and ppc7400, not x86_64. What can I do to build
x86_64 for psycopg2?

I am using the Apache that comes with Apple (I think it is in 64 bit).
I am also using the python2.5 that comes with Leopard. The PostgreSQL
was downloaded from www.postgresql.org under the Binary Packages for
Mac OSX. Any advise is greatly appreciated. Thanks.

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



Models in a package & syncdb

2009-10-05 Thread JF Simon

Hi,

I tried in vain to make it work !!! I've got some models modules in a
pckage named "models" in my app, I tried these 2 solutions (who are
mostly the sames) :
- http://www.acooke.org/cute/UsingaDire0.html
- 
http://www.ifisgeek.com/2009/01/26/splitting-django-models-into-separate-files/

So:
- I import the models classes in the package's __init__.py
- I declare them in the __all__

And syncdb still don't see my models classes. What am I missing ? Is
it due to the version of Django (i'm using the svn one) ?

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



Re: Models in a package & syncdb

2009-10-05 Thread JF Simon

I made some tests, it seems that imports don't work.

In th __init__ I tried:
from project.app.models.module import Class
... and Class is not imported

Is the project package in the python's path as  call manage.py
syncdb ?

GRRR


On 5 oct, 17:24, JF Simon  wrote:
> Hi,
>
> I tried in vain to make it work !!! I've got some models modules in a
> pckage named "models" in my app, I tried these 2 solutions (who are
> mostly the sames) :
> -http://www.acooke.org/cute/UsingaDire0.html
> -http://www.ifisgeek.com/2009/01/26/splitting-django-models-into-separ...
>
> So:
> - I import the models classes in the package's __init__.py
> - I declare them in the __all__
>
> And syncdb still don't see my models classes. What am I missing ? Is
> it due to the version of Django (i'm using the svn one) ?
>
> I'm desperate ...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Models in a package & syncdb

2009-10-05 Thread JF Simon

Ooops, it's me ... these tricks work perfectly, sorry !


On 5 oct, 17:37, JF Simon  wrote:
> I made some tests, it seems that imports don't work.
>
> In th __init__ I tried:
> from project.app.models.module import Class
> ... and Class is not imported
>
> Is the project package in the python's path as  call manage.py
> syncdb ?
>
> GRRR
>
> On 5 oct, 17:24, JF Simon  wrote:
>
> > Hi,
>
> > I tried in vain to make it work !!! I've got some models modules in a
> > pckage named "models" in my app, I tried these 2 solutions (who are
> > mostly the sames) :
> > -http://www.acooke.org/cute/UsingaDire0.html
> > -http://www.ifisgeek.com/2009/01/26/splitting-django-models-into-separ...
>
> > So:
> > - I import the models classes in the package's __init__.py
> > - I declare them in the __all__
>
> > And syncdb still don't see my models classes. What am I missing ? Is
> > it due to the version of Django (i'm using the svn one) ?
>
> > I'm desperate ...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin dashboard : hide and merge modules

2009-10-09 Thread JF Simon

A great new feature. It's exactly what I need, thanks !!


On 20 sep, 09:37, patrickk  wrote:
> you can now use GrappelliSite instead of AdminSite which gives you
> some options for the admin index page. take a look 
> athttp://code.google.com/p/django-grappelli/wiki/customizingindexfor
> more information.
>
> you can hide and merge modules. renaming is a bit more complicated
> since it affects subsites (like changelist and changeform).
>
> regards,
> patrick
>
> On 18 Aug., 07:40,JFSimon  wrote:
>
> > Thanks, I don't though about users perms !
> > Grappelli just turn your admin more pretty, you should 
> > try:http://code.google.com/p/django-grappelli/!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: can any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 'chiru'tha :
> hi..
> I'm new to Django, i need it in my project applications, can any one
> guide me to create a new model project(using MySql database). plz give
> the process in detail..

http://lmgtfy.com/?q=django+tutorial

-- 
Cheers,
Simon B.

--

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 any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 'chiru'tha :
> hey i've seen dat.. bt i cont able to create a new one.. i'm doing
> some mistake while setting settings. If u createed a project.. plz
> tell me the process in detail.. plz.
> thanku..

Sorry, but that *is* the process.

Why don't you tell us what went wrong? Perhaps we can help.

-- 
Cheers,
Simon B.

--

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 any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 chiranjeevi muttoju :
> i cont able to understand how to modify the settings for mysql..
> when i run the cammand 'python manage.py shell'
> it gives the error no modulr fing for No module named MySQLdb

You've not installed the database module that Python needs to talk to
MySql - see <http://bit.ly/7r0trL>.

-- 
Cheers,
Simon B.

--

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 any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 chiranjeevi muttoju :
> i've downloaded the mysql connector "MySQL-python-1.2.3c1.tar.gz'
> could u please tellme how to instal that in linux..

If you untar it, you should find installation instructions in the README.

-- 
Cheers,
Simon B.

--

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 any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 chiranjeevi muttoju :
> hey i installed django on one machine, and sql in another machine.. in which
> mechine i need to install the sql connector.

The Django machine.

-- 
Cheers,
Simon B.

--

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 any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 chiranjeevi muttoju :
> ImportError: No module named setuptools

Seems pretty self-evident to me. Try installing setuptools first.

-- 
Cheers,
Simon B.

--

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.




DKIM Email

2010-04-21 Thread Simon Meers
For anyone else who learned about DKIM recently [1], I've uploaded a
snippet for a DKIM-signing email backend [2].

[1] 
http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html
[2] http://www.djangosnippets.org/snippets/1995/

-- 
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 forums with polling

2010-05-09 Thread Simon Davies
Are there any django forum applications available which come packaged
with polling functionality?

Cheers

Simon

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



Class in a Class

2010-06-02 Thread JF Simon
Hello,

I'm lost in Python !!
If I write this 

class Dated(Behavior):

created_on = models.DateTimeField(_('Created on'))
updated_on = models.DateTimeField(_('Updated on'))

class Events:

def __init__(self):
super(Events, self).__init__()

 I get an error : NameError: global name 'Events' is not defined

Is not Events a real class ??
I don't understand, please help !

Thanks,
JF

-- 
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: Class in a Class

2010-06-02 Thread JF Simon
OK, Events is not in the 'global' scope !
Thanks (i'm tired)

On 3 juin, 07:18, Daemoneye  wrote:
> class A:
>         class B:
>                 pass
> a=A()
> B=A.B()
> you should add A. to control the class B
> ÔÚ Thu, 03 Jun 2010 12:50:06 +0800£¬JF Simon  дµÀ:
>
>
>
> > Hello,
>
> > I'm lost in Python !!
> > If I write this 
>
> > class Dated(Behavior):
>
> >     created_on = models.DateTimeField(_('Created on'))
> >     updated_on = models.DateTimeField(_('Updated on'))
>
> >     class Events:
>
> >         def __init__(self):
> >             super(Events, self).__init__()
>
> >  I get an error : NameError: global name 'Events' is not defined
>
> > Is not Events a real class ??
> > I don't understand, please help !
>
> > Thanks,
> > JF
>
> --
> ÎáѪ֮Ѫ°¡

-- 
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, Caching and PostgreSQL replication

2010-06-10 Thread Simon Riggs

fyi, PostgreSQL CHAR(10) conference has detailed coverage of
* Django and PostgreSQL replication
* PostgreSQL and memcache
* Latest PostgreSQL 9.0 replication features
* Slony and pgpool updates
* other technologies

CHAR(10) is being held in Oxford, UK on July 2-3.

You can register and/or pay online at
http://www.char10.org/

Please register in next two weeks to avoid late booking fees.

See you there!

-- 
 Simon Riggs   www.2ndQuadrant.com
 PostgreSQL Development, 24x7 Support, Training and 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.



Re: Force ContentType id

2010-06-22 Thread Simon Brunning
On 22 June 2010 09:58, donato.gr  wrote:
> I found some topics about tools such as 'django evolution' but I was
> wondering if Django itself provides a simpler way to make simple
> alterations...

It's not built in to Django, but it sounds like you want South -
<http://south.aeracode.org/>.

-- 
Cheers,
Simon B.

-- 
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: not able to install django development version

2010-06-22 Thread Simon Brunning
On 22 June 2010 12:33, samie  wrote:
> sir i am not able to install django development version on my machine
> i am using vista 32 basic..
>
> problem is occurring during svn checkout command,,

And the problem is?

-- 
Cheers,
Simon B.

-- 
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 L10N of DecimalField

2010-07-03 Thread Simon Westphahl
Hi,

I tried to implement a localized "DecimalField" but it doesn't seem to
work. When entering a decimal number with a German decimal seperator
( , ) the admin interface tells me to "Enter a number". Is there some
setting/middleware/etc. I overlooked?

My "settings.py" and test model look something like this:

### settings.py ###
[...]
LANGUAGE_CODE = 'de'
USE_I18N = True
USE_L10N = True
[...]
###

### models.py ###
from django.contrib import admin
from django.db import models

class DecTest(models.Model):
dec = models.DecimalField(max_digits=8, decimal_places=2)

admin.site.register(DecTest)
###

Thanks in advance!

Regards
Simon

-- 
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: Problem with L10N of DecimalField

2010-07-04 Thread Simon Westphahl
For clarification: The output in the admin list view is properly
localized. Only the input doesn't work.
I'm using Django 1.2.1 and a almost vanilla Django project only with
this one test app installed.

On 3 Jul., 22:07, Simon Westphahl  wrote:
> Hi,
>
> I tried to implement a localized "DecimalField" but it doesn't seem to
> work. When entering a decimal number with a German decimal seperator
> ( , ) the admin interface tells me to "Enter a number". Is there some
> setting/middleware/etc. I overlooked?
>
> My "settings.py" and test model look something like this:
>
> ### settings.py ###
> [...]
> LANGUAGE_CODE = 'de'
> USE_I18N = True
> USE_L10N = True
> [...]
> ###
>
> ### models.py ###
> from django.contrib import admin
> from django.db import models
>
> class DecTest(models.Model):
>     dec = models.DecimalField(max_digits=8, decimal_places=2)
>
> admin.site.register(DecTest)
> ###
>
> Thanks in advance!
>
> Regards
> Simon

-- 
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: Problem with L10N of DecimalField

2010-07-04 Thread Simon Westphahl
I figured out a way to get it working.

### models.py
[...]
class DecTest(models.Model):
dec = models.DecimalField(max_digits=8, decimal_places=2)

class LocalDecForm(forms.ModelForm):
dec = forms.DecimalField(max_digits=8, decimal_places=2,
localize=True)
class Meta:
model = DecTest

class DecAdmin(admin.ModelAdmin):
form = LocalDecForm
list_display = ('dec',)
[...]
###

But is this realy the way it's meant to work? A "DateTimeField" is
localized by default ...


On 4 Jul., 11:03, Simon Westphahl  wrote:
> For clarification: The output in the admin list view is properly
> localized. Only the input doesn't work.
> I'm using Django 1.2.1 and a almost vanilla Django project only with
> this one test app installed.
>
> On 3 Jul., 22:07, Simon Westphahl  wrote:
>
>
>
> > Hi,
>
> > I tried to implement a localized "DecimalField" but it doesn't seem to
> > work. When entering a decimal number with a German decimal seperator
> > ( , ) the admin interface tells me to "Enter a number". Is there some
> > setting/middleware/etc. I overlooked?
>
> > My "settings.py" and test model look something like this:
>
> > ### settings.py ###
> > [...]
> > LANGUAGE_CODE = 'de'
> > USE_I18N = True
> > USE_L10N = True
> > [...]
> > ###
>
> > ### models.py ###
> > from django.contrib import admin
> > from django.db import models
>
> > class DecTest(models.Model):
> >     dec = models.DecimalField(max_digits=8, decimal_places=2)
>
> > admin.site.register(DecTest)
> > ###
>
> > Thanks in advance!
>
> > Regards
> > Simon

-- 
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: Problem with L10N of DecimalField

2010-07-05 Thread Simon Westphahl
Hi,

I also tried your workaround and it fixes the input issue, but if you
edit your model again, the value in the input field is not properly
localized (uses a dot as decimal separator).

Ticket 13546 (ttp://code.djangoproject.com/ticket/13546) seems
relevant to our problem.
I only wonder why the DateTimeField is localized by default and the
DecimalField is not.

Regards
Simon

On 5 Jul., 19:33, saboter  wrote:
> I have mixed models with admin in my example. Sorry.
>
> It should be like this:
>
> ### models.py
> [...]
> class JobForm(ModelForm):
>     def __init__(self, *args, **kwargs):
>         super(JobForm,self).__init__(*args,**kwargs)
>         self.fields['price'].localize = True
> ...
> [...]
> ###
>
> ### admin.py
>
> class JobAdmin(admin.ModelAdmin):
>      form = JobForm
> ...
> [..]
> ###
>
> On 5. Júl, 15:48 h., saboter  wrote:
>
>
>
> > Hello,
>
> > i have the same problem, the decimal field input is not localized by
> > default in admin. (Works in changelist.)  So it shows and accepts only
> > dot as decimal separator.
>
> > It looks that admin doesnt set localize parameter in Field class init.
> > (Its False by default.)
> > I didnt found a ticket exactly for the "decimal issue", but this 
> > onehttp://code.djangoproject.com/ticket/13560 looks relevant to the
> > problem.
>
> > Thank you very much for posting your workaround.
>
> > I've used it this way:
>
> > ### models.py
> > [...]
> > class JobForm(ModelForm):
> >     def __init__(self, *args, **kwargs):
> >         super(JobForm,self).__init__(*args,**kwargs)
> >         self.fields['price'].localize = True
>
> > class JobAdmin(admin.ModelAdmin):
> >     form = JobForm
> >     ...
> > [...]
> > ###
>
> > Regards,
>
> > Martin
>
> > On 4. Júl, 13:39 h., Simon Westphahl  wrote:
>
> > > I figured out a way to get it working.
>
> > > ### models.py
> > > [...]
> > > class DecTest(models.Model):
> > >     dec = models.DecimalField(max_digits=8, decimal_places=2)
>
> > > class LocalDecForm(forms.ModelForm):
> > >     dec = forms.DecimalField(max_digits=8, decimal_places=2,
> > > localize=True)
> > >     class Meta:
> > >         model = DecTest
>
> > > class DecAdmin(admin.ModelAdmin):
> > >     form = LocalDecForm
> > >     list_display = ('dec',)
> > > [...]
> > > ###
>
> > > But is this realy the way it's meant to work? A "DateTimeField" is
> > > localized by default ...
>
> > > On 4 Jul., 11:03, Simon Westphahl  wrote:
>
> > > > For clarification: The output in the admin list view is properly
> > > > localized. Only the input doesn't work.
> > > > I'm using Django 1.2.1 and a almost vanilla Django project only with
> > > > this one test app installed.
>
> > > > On 3 Jul., 22:07, Simon Westphahl  wrote:
>
> > > > > Hi,
>
> > > > > I tried to implement a localized "DecimalField" but it doesn't seem to
> > > > > work. When entering a decimal number with a German decimal seperator
> > > > > ( , ) the admin interface tells me to "Enter a number". Is there some
> > > > > setting/middleware/etc. I overlooked?
>
> > > > > My "settings.py" and test model look something like this:
>
> > > > > ### settings.py ###
> > > > > [...]
> > > > > LANGUAGE_CODE = 'de'
> > > > > USE_I18N = True
> > > > > USE_L10N = True
> > > > > [...]
> > > > > ###
>
> > > > > ### models.py ###
> > > > > from django.contrib import admin
> > > > > from django.db import models
>
> > > > > class DecTest(models.Model):
> > > > >     dec = models.DecimalField(max_digits=8, decimal_places=2)
>
> > > > > admin.site.register(DecTest)
> > > > > ###
>
> > > > > Thanks in advance!
>
> > > > > Regards
> > > > > Simon

-- 
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: Problem with L10N of DecimalField

2010-07-06 Thread Simon Westphahl
I'm using Django 1.2.1 and it doesn't work any longer ;)
Just switched back to Django 1.2 and it works. But I think that's not
a solution.

Regards
Simon

On 6 Jul., 15:21, saboter  wrote:
> I used the workaround in project that runs under django 1.2 and it
> looks good in admin even after repeated editation.

-- 
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: Database systems

2010-07-16 Thread Simon Riggs
On Fri, 2010-07-16 at 20:33 +0530, Venkatraman S wrote:

> I thought South was DB agnostic.

It is, but databases provide different feature sets. If databases were
all the same there would not be so many to choose from.

-- 
 Simon Riggs   www.2ndQuadrant.com
 PostgreSQL Development, 24x7 Support, Training and 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.



Re: GAE + Django Authentication

2010-07-20 Thread Simon Holness
2nd Vote for Nonrel
http://www.allbuttonspressed.com/projects/django-nonrel

If you'd prefer not to use that, there's also Google's App Engine
Helper for Django -
http://code.google.com/p/google-app-engine-django/
http://code.google.com/appengine/articles/appengine_helper_for_django.html

But unlike Nonrel which leaves almost all of Django's model system
intact, the Helper instead reimplements some higher functionality
(e.g. auth) using Google's DB libs.
e.g.
http://code.google.com/p/google-app-engine-django/source/browse/#svn/trunk/appengine_django/auth

Haven't used either in anger, but having played around a bit with both
I preferred Nonrel.

On 20 July 2010 10:22, Nuno Maltez  wrote:
> Hi,
>
> Have you tried django-nonrel? -
> http://www.allbuttonspressed.com/projects/django-nonrel
>
>
> On Tue, Jul 20, 2010 at 6:59 AM, Venkatraman S  wrote:
>> Hi,
>>
>> Has anyone made inroads into django auth in GAE? I have been Googling around
>> for sometime and havent found a credible link on this.
>> Help would be great.
>>
>> Regards,
>> -V
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-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.
>
>

-- 
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 Question: Syntax Error - Form Class, trying to set e-mail field to required=False

2010-07-22 Thread Simon Holness
"e-mail" can't have a hyphen in it. Python thinks you're "assigning"
to the operation e - mail

just type into a shell to see.

e-mail = "blah"
SyntaxError: can't assign to operator

rename to e_mail or email or something and you should be good to go

On 22 July 2010 06:10, strayhand  wrote:
> I apologize in advance if i'm posting this question in the wrong area.
> I'm learning about django's form class in "The Definitive Guide To
> Django" and for some reason that's beyond me I keep getting a syntax
> error. I've been over my code a dozen times and I'm hoping that
> someone can point me in the right direction.
>
> (Taken from page 133-134)
>
> contactforms.py
>
> from django import forms
>
> class ContactForm(forms.Form):
>        subject = forms.CharField()
>        e-mail = forms.EmailField(required=False)
>        message = forms.CharField()
>
> When I jump into the shell and type the following I get the syntax
> error:
>
> from contactforms import ContactForms
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "/Users/bealtr/Personal/YLBBQ/Django Projects/ylbbq/
> contactforms.py", line 5
>    e-mail = forms.EmailField(required=False)
> SyntaxError: can't assign to operator
>
> What am I doing wrong?
>
> --
> 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: NotImplementedException when trying to log user in after registration

2010-07-23 Thread Simon Holness
Your authentication has failed somehow and authenticate() has returned
an AnonymousUser object.

calling .save() on this raises the exception

(code = 
http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/models.py#L399
)


On 22 July 2010 23:33, Jeff  wrote:
> Hi,
>
> I get a NotImplementedException when I try to log a user in right
> after they register.
>
> Here is the source code:
>
> def create_account(request):
>    if request.method == 'POST':
>        form = UserCreationForm(request.POST)
>        if form.is_valid():
>            user = form.save()
>            authenticated_user = authenticate(username=user.username,
>                password=user.password)
>            login(request, authenticated_user)
>            return redirect(profile)
>    else:
>        form = UserCreationForm()
>    return render_to_response('registration/create_account.html', {
>        'form': form,
>    }, context_instance=RequestContext(request))
>
> And here is the stack trace:
>
> File "/home/jeff/.virtualenvs/osl_main-website/lib/python2.6/site-
> packages/django/core/handlers/base.py" in get_response
>  100.                     response = callback(request,
> *callback_args, **callback_kwargs)
> File "/home/jeff/projects/osl-main-website/wluopensource/accounts/
> views.py" in create_account
>  17.             login(request, authenticated_user)
> File "/home/jeff/.virtualenvs/osl_main-website/lib/python2.6/site-
> packages/django/contrib/auth/__init__.py" in login
>  69.     user.save()
> File "/home/jeff/.virtualenvs/osl_main-website/lib/python2.6/site-
> packages/django/contrib/auth/models.py" in save
>  427.         raise NotImplementedError
>
> Exception Type: NotImplementedError at /accounts/create_account/
> Exception Value:
>
> Thanks in advance for any help you can provide!
>
> --
> 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: csv files

2010-08-18 Thread Simon Brunning
On 13 August 2010 17:59:01 UTC+1, Tony  wrote:
> My script right now basically just reads from a csv file and puts it
> into a dictionary for me.  However, when I make my own csv file (just
> the same as any I have seen), it acts inconsistently.  For example,
> sometimes it starts at the second line and another time it kept
> starting at the end of the file.

Are you sure that the CSV rows are being read on a strange order? Or
are you surmising this from looking at the dictionary once the load is
complete?

If it's the latter, then perhaps the problem is that dictionaries are
un-ordered data structures. If you iterate over the items in a
dictionary, you'll see its entries in an arbitrary order.

-- 
Cheers,
Simon B.

-- 
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: writing HTML Code into Template with render_to_response: How?

2010-08-25 Thread Simon Holness
Use the "safe" filter to disable the auto-escaping that templates
apply to all variables:
http://docs.djangoproject.com/en/1.2/ref/templates/builtins/#safe

-- 
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 find what is the current module directory?

2010-12-05 Thread Simon TITE

I'm looking for something analagous to the existing command:

sfConfig::get("sf_app_config_dir")

which gives me access to the config directory of the current application  
("apps/frontend/config"). I would like to do the same to access the config  
directory of the module, e.g. "apps/frontend/modules/homepage/config".  
Ideally, it would seem logical that there should be a command such as:


sfConfig::get("sf_module_config_dir")

although I am not too bothered about the final "/config" directory, I just  
want an easy way to find "/apps/frontend/modules/homepage/".


Can anybody help?

--
Simon Tite

--
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 find what is the current module directory?

2010-12-05 Thread Simon TITE
Ouch, many apologies, I sent the last message to the wrong mailing list!  
Can an admin delete it please?



--
Simon Tite

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



unicode encoding problem

2010-01-03 Thread Simon Davies
I know I'm missing something really simple really but I  keep getting
this error:

SyntaxError: Non-ASCII character '\xc2' in file /home/simon/
djangoprojects/bikerescue/bikeshop/models.py on line 46, but no
encoding declared; see http://www.python.org/peps/pep-0263.html for
details.  This is the model in question and I have the __unicode__
function in there

class Item(models.Model):
title = models.CharField(max_length=100)
description = models.CharField(max_length=500)
price = models.FloatField(max_length=10, verbose_name=u'Price (£)')

def __unicode__(self):
return self.title

def _get_disp_price(self):
return u"£" + self.price

disp_price = property(_get_disp_price)

I 've put the unicode u in both places where its required so why is it
still tripping up.

Many thanks

Simon

--

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: Saving several copies of an object

2010-01-06 Thread Simon Brunning
2010/1/5 pjmorse :
> It's a multi-language site: US, UK, DE. (Why US and UK are considered
> different languages is organizational politics beyond the scope of my
> work.)

UK and US English are enormously similar, but there are real
differences in vocabulary (e.g. lift versus elevator, bin versus trash
can), spelling (e.g. colour versus color), punctuation (e.g. with the
placement on puctuation in relation to quote marks), and occasionally
even grammar ("my bank are dreadful" versus "my bank is dreadful").

-- 
Cheers,
Simon B.
-- 
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: decimal is not json serializable.

2010-01-14 Thread Simon Brunning
2010/1/14 Meenu :
> Hello all,
>
> I'm following the "Serializing Django objects" documentation and have
> a view pretty much verbatim from the docs:
>
>        if xhr:
>            return HttpResponse(simplejson.dumps(form_data),
> mimetype='application/javascript')
>
> When I test the above view using the Django shell, it works, but when
> I try it via a browser request, I get this:
>
> Decimal("44.048708") is not JSON serializable
>
> Any help will be appreciated.

You can override the JSON encoder's behaviour, something like (untested):

class MyJsonEncoder(simplejson.JSONEncoder):
"""JSON encoder which understands decimals."""

def default(self, obj):
'''Convert object to JSON encodable type.'''
if isinstance(obj, decimal.Decimal):
return "%s" % obj

return super(MyJsonEncoder, self).default(self, obj)

The simplejson.dumps() method takes an optional cls keyword argument -
that's where you plug MyJsonEncoder in.

-- 
Cheers,
Simon B.
-- 
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: 'float' object is not iterable

2010-01-20 Thread Simon Brunning
2010/1/20 Christopher Bird :
> Hi
>
> Im trying iterating over a dictionary.
> i have no problem with this but when i get to the last key:value
> ( value is a list) i get the following error
>
>
> value= list
> TypeError: 'float' object is not iterable
>
>
>
> django code
>
>
> {% for states in prices_demand.items %}
>
> 
> {{ states.0 }}
> 
> {{ states.1.items.2.0 }}={{ states.1.items.2.1 }}
>
> {{ states.1.items.0.0 }}={{ states.1.items.0.1 }}
>
> {{ states.1.items.3.0 }}={{ states.1.items.3.1 }}
>
> {{ states.1.items.5.0 }}={{ states.1.items.5.1 }}
>
> {{ states.1.items.7.0 }}={{ states.1.items.7.1 }}
>
>
>
> {{ states.1.items.6.0 }}
>
>
> 
>
> {% for x in states.1.items.6.1 %}
>
> {{ x }}
>
> {% endfor %}
> {% endfor %}
>
>
> Am i asking django to do too much??

Looks to me like prices_demand.items is a dictionary, but whatever is
in states.1.items.6.1 is *not* a dictionary - it's a float, and
there's no sensible way to do a for loop over a float.

-- 
Cheers,
Simon B.
-- 
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.




now template tag

2010-01-26 Thread Simon Davies
Hi

I have been having some problems with the now date template tag.  I
want to use it in the url tag.  This works fine with the date tag:

{% url news_archive_month year=date|date:'Y' month=date|date:'m'
day=date|date:'d' %}

but if I want to use it with the current date using the now tag, it
doesn't, like this:

{% url news_archive_day now 'Y' now 'm' day.day %}

I get this error message:

Caught an exception while rendering: Reverse for 'news_archive_day'
with arguments '('', u'Y', '', u'm', 28)' and keyword arguments '{}'
not found.

Is there any way of using the current date without passing in an
additional variable from the view.  As its the default
django.views.generic.date_based.py, this would be rather difficult.

Regards

SImon

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



model design and derived classes - need advice please?

2010-02-02 Thread Simon Davies
Hi

I am writing a web shop.  I have a shopping cart class, which has a
many to many relationship to an item class, the item class has three
derived classes.  The basic schema is shown below:

class Item(models.Model):
title = models.CharField(max_length=100)
description = models.CharField(max_length=500)
price = models.DecimalField(max_digits=7, decimal_places=2,
verbose_name=u'Price (£)')

class Bike(Item):
manufacturer = models.CharField(max_length=50)

class BikePart(Item):
partType = models.CharField(max_length=50, choices=PARTTYPE_CHOICES)

class Accessory(Item):
accessoryType = models.CharField(max_length=50,
choices=ACCESSORYTYPE_CHOICES)

class Cart(models.Model):
   items = models.ManyToManyField(Item)

The cart has a manytomany relationship with the item superclass.  How
is it possible to get the derived class back though from the
superclass that is stored in the Cart.items field, or is there a
better way of doing this.  Will I have to resort to queries through
all of the derived classes checking for the id's that match those of
the objects in Cart.items so something like this:

for elem in cart.items.all():
   b = UsedBike.objects.all().filter(id=elem.id)

or is there a neater way of doing this.

Cheers

Simon



-- 
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: any suggestion about how to build Continuous testing for django project?

2010-02-02 Thread Simon Brunning
On 1 February 2010 17:25, pyleaf  wrote:
> I am new for django.
> any suggestion about how to build Continuous testing for django project?

If you build your Django app with buildout (<http://bit.ly/cmdMQy>)
you could try Hudson (<http://bit.ly/aSPpog>). I'm going to be giving
this approach a try myself over the next few days.

-- 
Cheers,
Simon B.

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



Additional fields not registered when subclassing Forms imported from other applications?

2010-02-09 Thread Simon Meers
This may be a python quirk I'm unaware of, or perhaps a Django bug, I'm not
sure:

#
# forms.py:
#
from django import forms
class TestForm(forms.Form):
test_field = forms.BooleanField()
#

#
# test.py:
#
# import the same class from two different locations:
from project_name.forms import TestForm
from project_name.some_module.forms import TestForm as TestForm2

class MyForm(TestForm):
extra_field = forms.BooleanField()

print MyForm().fields.keys()
# prints: ['test_field', 'extra_field'] as expected

class MyForm2(TestForm2):
extra_field = forms.BooleanField()

print MyForm2().fields.keys()
# prints: ['test_field']
# extra fields not registered if superclass imported from other
app/module!
#

Python 2.6.4, Django SVN-12401

What is going on here?

Simon

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



weird problem with django admin models and webfaction

2010-02-22 Thread Simon Davies
Hi

I'm still developing my app and I have just refactored my models in my
django app.  I dropped most of the existing tables on my local dev
machine and then completely rebuilt everything using syncdb,
everything worked fine, including the admin, no probs at all.

Then I updated everything on my webfaction account, dropped most of
the tables and ran syncdb.  Then I accessed the admin app.  Problem!!!

Things got really weird here,  its still seeing the old models
somehow, and it falls over when I click on any of the models.  The
errors result from the fact that I updated one of the models so
abstract = True, so it won't exist as a sql table and this is causing
the error:

Caught an exception while rendering: (1146, "Table
'simondav.bikeshop_item' doesn't exist")

Original Traceback (most recent call last):
  File "/home/simondav/webapps/django/lib/python2.5/django/template/
debug.py", line 71, in render_node
result = node.render(context)
  File "/home/simondav/webapps/django/lib/python2.5/django/template/
__init__.py", line 936, in render
dict = func(*args)
  File "/home/simondav/webapps/django/lib/python2.5/django/contrib/
admin/templatetags/admin_list.py", line 253, in result_list
'results': list(results(cl))}
  File "/home/simondav/webapps/django/lib/python2.5/django/contrib/
admin/templatetags/admin_list.py", line 247, in results
for res in cl.result_list:
  File "/home/simondav/webapps/django/lib/python2.5/django/db/models/
query.py", line 106, in _result_iter
self._fill_cache()
  File "/home/simondav/webapps/django/lib/python2.5/django/db/models/
query.py", line 692, in _fill_cache
self._result_cache.append(self._iter.next())
  File "/home/simondav/webapps/django/lib/python2.5/django/db/models/
query.py", line 238, in iterator
for row in self.query.results_iter():
  File "/home/simondav/webapps/django/lib/python2.5/django/db/models/
sql/query.py", line 287, in results_iter
for rows in self.execute_sql(MULTI):
  File "/home/simondav/webapps/django/lib/python2.5/django/db/models/
sql/query.py", line 2369, in execute_sql
cursor.execute(sql, params)
  File "/home/simondav/webapps/django/lib/python2.5/django/db/backends/
util.py", line 19, in execute
return self.cursor.execute(sql, params)
  File "/home/simondav/webapps/django/lib/python2.5/django/db/backends/
mysql/base.py", line 84, in execute
return self.cursor.execute(query, args)
  File "/usr/local/lib/python2.5/site-packages/MySQLdb/cursors.py",
line 166, in execute
self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.5/site-packages/MySQLdb/
connections.py", line 35, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (1146, "Table 'simondav.bikeshop_item' doesn't
exist")

which is correct in that the definition shouldn't exist in the
database any longer, but where is admin getting the model definition
from??

Both the models.py and admin.py files have been updated correctly, I
have completely trashed and rebuilt the whole database, yet it still
seems to be getting these ghost definitions on the webfaction server
somehow,  everything still works fine locally, so I'm puzzled.  Could
it be some kind of cache issue?, but surely anything would have been
deleted when I trashed the database.

Puzzled!!!

Thx in advance

Simon

-- 
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: weird problem with django admin models and webfaction

2010-02-22 Thread Simon Davies
Duh!!  yeah restarting apache did it.  How did I forget something so
simple!!

Thanks

Simon

On 22 Feb, 15:04, Shawn Milochik  wrote:
> Did you manually restart the Apache instance for this app?
>
> I had a similar problem, and it turned out that I had a bit of code in one of 
> my model that was pulling from a table that was no longer defined. Check for 
> that as well.

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



dynamically excluding fields in admin form

2010-02-28 Thread Simon Davies
Hi

I have a model which I access from the admin application.  I want to
exclude some fields dynamically.

My model looks like this:

class StockOrder(models.Model):
number_of_items_pending_order =
models.PositiveIntegerField(max_length=5, default=1)
number_of_items_ordered = models.PositiveIntegerField(max_length=5,
default=1)
number_of_items_delivered = models.PositiveIntegerField(max_length=5,
default=1)
order_date = models.DateTimeField(auto_now_add=True,
verbose_name=u'Date ordered')
confirmed = models.BooleanField(default=False)
confirmed_date = models.DateTimeField(verbose_name=u'Date confirmed',
null=True, blank=True)
cancelled = models.BooleanField(default=False)
cancel_date = models.DateTimeField(verbose_name=u'Date cancelled',
null=True, blank=True)
completed = models.BooleanField(default=False)
completion_date = models.DateTimeField(verbose_name=u'Date
completion', null=True, blank=True)

I want to exclude some fields depending on the state of others.  So if
completed is True I don't want to see the confirmed or cancelled
flags.

The options to exclude fields I understand are:

1: ModelAdmin.exclude attribute  in admin.py.  I can't see how this
can be manipulated dynamically however.

2.  I create my own Modelform and set the form attribute in admin.py
to the modelform, the modelform will look something like this:

class StockOrderForm(ModelForm):
class Meta:
model = StockOrder
exclude = ('cancelled',)

However I run into the same problem as in 1, how can I manipulate the
exclude parameter.  Is it possible to do so in __init__?

Thanks

Simon

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



  1   2   3   4   5   6   7   8   >