Booleans not being set in admin

2010-07-08 Thread Lee Hinde
I have a model, Store:

class Store(models.Model):
"""
 Store is use to link users and to provide a target for the weather report.
"""
name = models.CharField(max_length=50, help_text="Simple
Identifier for Store -")
zip_code = models.CharField(max_length=20,help_text = "Used to get
weather data for this store.")
visible = models.BooleanField(default=True,db_index=True,help_text
= "You can setup a store and make them invisible until they're ready
to play..")

objects = models.Manager()
are_visible = StoresAreVisible()

class Meta:
ordering = ('name',)

def __unicode__(self):
return self.name


With this admin.py setup:

class StoreOptions(admin.ModelAdmin):
save_on_top = True
list_display = ('name','zip_code')
inlines = [UserProfileStoreInline,]
search_fields = ['name','zip_code']


Regardless of the 'visible' value, it is always displayed in admin as
true - checked.  If I uncheck it, the database field doesn't change.
If I make the database value 0 'manually,' and play with various
settings, I can't get the database to update on that field.

I've made no other changes to the admin section.

I have other boolean fields which work fine.

Any thoughts on where else I should look?


TIA

 - Lee

-- 
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 can I Insert multiple records in one statement

2010-07-08 Thread Kenneth Gonsalves
On Friday 09 July 2010 07:18:30 Sells, Fred wrote:
> In MySQLdb you do something similar to 
> 
> Records = [ (1,2,3), (4,5,6), (7,8,9) , (11,22,33) ]
> 
> cursor.execute('insert to mytable (a,b,c) VALUES (%s, %s, %s)', Records)
> #untested.
> 
> This would insrt 4 rows
> 

it is two statements ;-). I suppose one needs a for loop:
given a model called Prefix - with one field: 'name'
pf = ['a','b','c']
for x in pf:
Prefix.objects.create(name='%s' %x)

of course it is three statements.
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

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



Calling remote API

2010-07-08 Thread james_027
hi all,
It will be my first time to create django app that requires calling
remote API. As far as I know django has no built in support for this.
I only way I know is URLLIB2, any good library for this purpose, which
easily send your request as get this parameters and also easily parse
the return results which could be xml or json?


thanks,
James

-- 
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: News on every page

2010-07-08 Thread Venkatraman S
On Fri, Jul 9, 2010 at 3:40 AM, Antoni Aloy  wrote:

> I would use a custom template tag with cache
>
I was planning to recommend the same, but i wasnt sure whether this is
efficient when compared with context-processor solution. I had used template
tags for a similar requirement for one of my clients.

Is the DB queried repeatedly in cases wherein a template tag is used across
pages? or is the data/query cached?

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



Re: v1.2 message framework - messages created outside of the request cycle

2010-07-08 Thread jyunis
Thanks, Mick. This will work well and I think is the "right" way to go
about this.

On Jul 8, 8:32 am, Mick  wrote:
> I've encountered same issue. My solution is simple model and
> middleware:
>
> class OfflineNotification(models.Model):
>     user = models.ForeignKey(User)
>     message = models.TextField()
>     level = models.PositiveSmallIntegerField(default=20)
>     created = models.DateTimeField(auto_now_add=True)
>
> class OfflineNotificationsMiddleware:
>
>     def process_request(self, request):
>         if request.user.is_authenticated():
>             notifications =
> OfflineNotification.objects.filter(user=request.user).distinct('message')
>             for notification in notifications:
>                 messages.add_message(request, notification.level,
> notification.message)
>
>             if notifications:
>
> OfflineNotification.objects.filter(user=request.user).delete()
>
> Hope it will help you.
>
> On Jul 8, 12:27 am, jyunis  wrote:
>
> > Hey all,
>
> > I'm currently developing an application using Django's deprecated user
> > messaging functionality and one of the features I depend on is the
> > ability to set messages for a particular user from a back-end process,
> > i.e. outside of the request cycle.  In my backend process, I have
> > access to the User object, but of course not the request object.
>
> > I see that the new Django 1.2 message framework does not support this,
> > but I am wondering if that use case has been addressed in any other
> > way.  I hate to continue development using a deprecated feature, but
> > the lack of offline messaging from the message framework is a
> > significant barrier to migration.
>
> > --
> > Jeremy

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



Passing argument to Template loader

2010-07-08 Thread zenWeasel
I have what I think is a common issue, but I have not seen a good
solution. I have tried various workarounds and got nowhere. So, here
what I would like to do and the problem I run into.

I want to have a template loader that looks for templates based upon a
user's current "site_profile", which is basically a version of what
site they are on. So I need the loader to look in:

templates/site_profile_name/template.html and return a 404 if it
doesn't exist.

Someone earlier had linked to
http://www.b-list.org/weblog/2007/nov/01/django-tips-template-loading-and-rendering/
but none of these really apply as they are at the view level and this
is not practical as I would need to make each and every view do a
select_template() for the site_profile string. A template loader seems
like a much more DRY approach. However I have to admit that, despite
hours of staring, I find the template loader code a little baffling.

The Django docs make a reference (in not recommending the
threads_local method) to calling a method/function that has access to
Request. But what would that be? I'm clearly not making some important
connection.

Thanks for any insight.

-- 
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 can I Insert multiple records in one statement

2010-07-08 Thread Sells, Fred
In MySQLdb you do something similar to 

Records = [ (1,2,3), (4,5,6), (7,8,9) , (11,22,33) ]

cursor.execute('insert to mytable (a,b,c) VALUES (%s, %s, %s)', Records)
#untested.

This would insrt 4 rows

-Original Message-
From: django-users@googlegroups.com
[mailto:django-us...@googlegroups.com] On Behalf Of Kenneth Gonsalves
Sent: Thursday, July 08, 2010 8:46 PM
To: django-users@googlegroups.com
Subject: Re: How can I Insert multiple records in one statement

On Friday 09 July 2010 06:03:09 Sells, Fred wrote:
> I know how to do this in raw MySQLdb and have been trying to find a
way
> to do it with the Django models but with no success.
> 

how do you do it in MySQLdb? What exactly do you mean by 'insert
multiple 
records in one statement'?
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

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



Error in Admin - can't seem to chain __unicode__'s for ForeignKeys

2010-07-08 Thread Victor Hooi
heya,

I have a small Django app that contains a list of Df (disk-free)
reports.

"DfReport" has a ForeignKey to "Filesystem" model, which has a
ForeignKey to "Device". (i.e. Devices has filesystems, each filesystem
has a DfReport).

I'm getting an error in the admin when I attempt to display the
list_display page for a "DfReport" model.

TemplateSyntaxError at /admin/report/dfreport/add/
Caught TypeError while rendering: coercing to Unicode: need string
or buffer, Device found

I've traced the error to the __unicode__ method for one of the
ForeignKey fields on DfReport being displayed.

The issue is, Filesystem has __unicode__ set to print the server on
which it's reporting. Using the following causes the
TemplateSyntaxError:

class Filesystem(models.Model):
name = models.CharField(max_length=50)
#description = models.CharField(max_length=100)
description = models.TextField()
server = models.ForeignKey(Device)

def __unicode__(self):
return self.name + ' on device ' + self.server

However, if I change self.server to "self.server.name", it works. The
weird thing is - Device (which server points to), has a __unicode__
method defined as well. Shouldn't calling self.server just use the
__unicode__ method on Device, instead of needing me to explicitly call
self.server.name?

class Device(models.Model):
name = models.CharField(max_length=50)
#description = models.CharField(max_length=100)
description = models.TextField()
location = models.ForeignKey(Location)

def __unicode__(self):
return self.name

class Meta:
ordering = ['name']

Or have I got a wrong understanding of how this works?

Cheers,
Victor

-- 
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: models.py import from other models.py

2010-07-08 Thread yugori
This problem is resolved.

What I did is
1.comment out "models.ManyToManyField" line and execute "manage.py
syncDB".
2.Back to code "models.ManyToManyField" line and execute "manage.py
evolve --hint --execute"
Then appli_master table was auto-generated.

I don't know why this way goes right.

But, now I have another problem.

I use ModelForm to deal the table, I try to submit and form.save()
then the data column is added Appli table successfully, but
appli_master table has no updated data.

orz..

On Jul 9, 2:15 am, Nuno Maltez  wrote:
> What error do you get when you execute  'manage.py syncDB'? Could you
> paste it here?
>
> Nuno
>
> On Thu, Jul 8, 2010 at 2:28 AM, yugori  wrote:
> > Hi, I'm beginner.
>
> > I tried to execute 'manage.py syncDB' command,
> > but it's not work.

-- 
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: list display based on logged-in user

2010-07-08 Thread rahul jain
anyone on this ?

On Thu, Jul 8, 2010 at 11:56 AM, rahul jain  wrote:
> I am not sure what I am doing wrong but this should work
>
> class TestAdmin(admin.ModelAdmin):
>
>        list_display = (field1, field2, field3, fileld4, field5,field6)
>
>
> class CustomTestAdmin(TestAdmin):
>
>        custom_list_display = (field1, field2, field3)     # showing less
> number of fields
>
>        def change_view(self, request, *args, **kwargs):
>                if not request.user.is_superuser:
>                        self.list_display = self.custom_list_display    # 
> setting list display
>                        return TestAdmin.change_view(self, request, *args, 
> **kwargs)
>                else:
>                        return TestAdmin.change_view(self, request, *args, 
> **kwargs)
>
> admin.site.register (Test, CustomTestAdmin)
>
> So even if the user is not super user display is same, all the fields :( .
>
> --RJ
>
>
>
>
>
>
>
>
>
> On Thu, Jul 8, 2010 at 6:56 AM, derek  wrote:
>> On Jul 7, 11:40 pm, rahul jain  wrote:
>>> Hi there !
>>>
>>> I would like to display model fields based on the logged-in user.
>>>
>>> If user is restricted user
>>>
>>> list_display = (field1, field2)
>>>
>>> else
>>>
>>> list_display = (field1, field2, field3, field4)
>>>
>>> How is it possible ?
>>>
>>
>> Also see:
>> http://stackoverflow.com/questions/2297377/how-do-i-prevent-permission-escalation-in-django-admin-when-granting-user-change
>>
>> --
>> 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: How can I Insert multiple records in one statement

2010-07-08 Thread Kenneth Gonsalves
On Friday 09 July 2010 06:03:09 Sells, Fred wrote:
> I know how to do this in raw MySQLdb and have been trying to find a way
> to do it with the Django models but with no success.
> 

how do you do it in MySQLdb? What exactly do you mean by 'insert multiple 
records in one statement'?
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

-- 
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 can I Insert multiple records in one statement

2010-07-08 Thread Sells, Fred
I know how to do this in raw MySQLdb and have been trying to find a way
to do it with the Django models but with no success.

Can it be done and if so, can someone point me to a link in the docs
please?

Everything looks so elegant with the models, I hate to drop into SQL if
I don't have to.

-- 
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: Ignoring fields in deserialization

2010-07-08 Thread Russell Keith-Magee
On Fri, Jul 9, 2010 at 6:50 AM, lfrodrigues  wrote:
> Hello,
>
> I had some copies of a model with 10 fields serialized in a file.
>
> I deleted some of the fields (since I don't need them anymore) now I
> can't deserialize the model.
>
> error: raise FieldDoesNotExist, '%s has no field named %r' %
> (self.object_name, name)

Ignoring non-existent fields is the subject of ticket #9279.

The only workaround for this issue at the moment is to manually edit
your fixtures to remove references to the deleted field. If you need
to do this a lot, you may find it easier to write a quick utility that
parses your fixture, deletes the field entry in memory, and outputs
the fixture again.

Yours,
Russ Magee %-)

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



Re: get_model()

2010-07-08 Thread Kenneth Gonsalves
On Thursday 08 July 2010 17:11:35 Russell Keith-Magee wrote:
> get_model() et al are intended utilities for metaprogramming -- for
> example, if you want to build an interface that can knows about other
> models in the project, get_model() and friends are the tools you use.
> 

thanks - a relief to know that get_model(), which I use fairly often, is not 
going away. I needed to see the docs when I was trying to debug a problem on 
IRC and kinda panicked when I saw not docs on this. btw, 
django.contrib.comments also has a get_model() which is documented.
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

-- 
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: default is_active to true on new users

2010-07-08 Thread Jacob Fenwick
I tried something like this:

*models.py
class MyUser(User):
pass

*admin.py
class MyUserAdminForm(forms.ModelForm):
is_staff = models.BooleanField(_('staff status'),
default=True, help_text=_("Test."))

class Meta:
model = User

class MyUserAdmin(UserAdmin):
form = PublisherAdminForm

admin.site.register(MyUser, MyUserAdmin)


Any idea why the help text wouldn't show up in the admin for this?

Jacob

On Thu, Jul 8, 2010 at 7:08 PM, Jacob Fenwick wrote:

> So one method I found is to use the custom validation from a form in the
> ModelAdmin:
>
> http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#adding-custom-validation-to-the-admin
>
> However, this only seems to work on edits, not on adds.
>
> How can I make this work on adds?
>
> Jacob
>
>
> On Thu, Jul 8, 2010 at 6:33 PM, Jacob Fenwick wrote:
>
>> I'm looking for a way to automatically set is_active to true for new users
>> that are added through the admin interface.
>>
>> I tried to subclass the User class and set the is_active default to true
>> but apparently you can't override fields in a parent model:
>>
>> http://docs.djangoproject.com/en/1.2/topics/db/models/#field-name-hiding-is-not-permitted
>>
>> Is there some sort of ModelAdmin magic that could solve this problem?
>>
>> Or is there some other method that can be arrived at through subclassing
>> the User object?
>>
>> Jacob
>>
>
>

-- 
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: News on every page

2010-07-08 Thread Kenneth Gonsalves
On Thursday 08 July 2010 21:37:58 Martin Tiršel wrote:
> I am programming a small CMS on Django, I have editable pages, now I want  
> to add news. I have a website where I want to display these news on every  
> page in right/left column. I have following questions:
> 
> 1.) Where is the right place to place news loader?  
> 

templatetags could help here - there is a good tutorial on b-list (about 3-4 
years old)
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

-- 
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: default is_active to true on new users

2010-07-08 Thread Jacob Fenwick
So one method I found is to use the custom validation from a form in the
ModelAdmin:
http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#adding-custom-validation-to-the-admin

However, this only seems to work on edits, not on adds.

How can I make this work on adds?

Jacob

On Thu, Jul 8, 2010 at 6:33 PM, Jacob Fenwick wrote:

> I'm looking for a way to automatically set is_active to true for new users
> that are added through the admin interface.
>
> I tried to subclass the User class and set the is_active default to true
> but apparently you can't override fields in a parent model:
>
> http://docs.djangoproject.com/en/1.2/topics/db/models/#field-name-hiding-is-not-permitted
>
> Is there some sort of ModelAdmin magic that could solve this problem?
>
> Or is there some other method that can be arrived at through subclassing
> the User object?
>
> Jacob
>

-- 
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: Get pk before commit

2010-07-08 Thread Kenneth Gonsalves
On Friday 09 July 2010 03:16:28 TheIvIaxx wrote:
> I'd like to save the image file into a folder based on the ID of the
> new instance.  The only thing i can think of is to create the new
> folder mid transaction.  I guess another way to do it would be to save
> a new instance with a temp file or set it to null=True, then create
> the folder, but that seems bad to me.
> 

there is a save(commit=False) which should do the trick.
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

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



Re: Django developer opening

2010-07-08 Thread Kenneth Gonsalves
On Friday 09 July 2010 03:59:50 j wrote:
> What exactly didn't you like about the add?
> 

maybe it sounds very corporate and enterprisy - which puts off a lot of people
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

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



Ignoring fields in deserialization

2010-07-08 Thread lfrodrigues
Hello,

I had some copies of a model with 10 fields serialized in a file.

I deleted some of the fields (since I don't need them anymore) now I
can't deserialize the model.

error: raise FieldDoesNotExist, '%s has no field named %r' %
(self.object_name, name)

Any help, please.

Luis

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



default is_active to true on new users

2010-07-08 Thread Jacob Fenwick
I'm looking for a way to automatically set is_active to true for new users
that are added through the admin interface.

I tried to subclass the User class and set the is_active default to true but
apparently you can't override fields in a parent model:
http://docs.djangoproject.com/en/1.2/topics/db/models/#field-name-hiding-is-not-permitted

Is there some sort of ModelAdmin magic that could solve this problem?

Or is there some other method that can be arrived at through subclassing the
User object?

Jacob

-- 
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: Is Django right for what I am trying to do

2010-07-08 Thread Martin Tiršel
On Thu, 08 Jul 2010 23:23:53 +0200, Bradley Hintze  
 wrote:



I guess I just don't like the model.py, views.py, templates, and
url.py. In the tutorial you have to edit all of these and THEN you get
something that you can send to the client. It's very confusing! How do
they tie together? I probably need to do the tutorial again. It seems
to me getting info from the user should be strait foreword but its not
as displayed by the rather lengthy tutorial. But than I'm new to
this...



Hi, I am a Django beginner too. If you don't have experiences with MVC  
programming pattern, it could be a lot harder, but as soon as you  
understand it, you will not see many things so complicated. Django is a  
framework which helps you to save time by not inventing a wheel again and  
again, you don't need to know how Django's blackboxes works, you only need  
to know how to use them to work for you. Forms are perfect example - you  
specify what fields a form should have, what data should every field  
contain and the boring part - displaying, validating and redisplaying you  
can let to Django. If there is something you need to do differently as  
default behaviour is, you can override it. Django is a little harder to  
learn as I expected, but my advice is not to give up and try to read  
documentation again and again until every part begins to fit together.


What I am missing on Django, are high quality or complex tutorials. There  
is only small tutorial on django home page and a little better (and older)  
on djangobook.com, then good reference manual on home page (but with few  
real examples) and many blog posts about specific problems. The beginning  
is the hardest part. Try to create a real application, e.g. Content  
Management System or Blog or Photo gallery or whatever you want and ask  
for a help on specific problem you encounter during development, there are  
many good people who will help you.


Regards,
Martin

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



Re: Django developer opening

2010-07-08 Thread j

What exactly didn't you like about the add?

On Jul 6, 6:55 pm, reduxdj  wrote:
> ew, u lost me at "The visuzlation"... sorry, lame ad.
>
> On Jul 6, 8:22 pm, j  wrote:
>
> > The Visualization & Reporting Engineer will contribute to the design
> > and implementation of Silver Peak’s dynamic reporting and charting
> > engine.  The reporting engine is a sophisticated component of Silver
> > Peak’s Global Management System used by customers to track trends,
> > monitor performance and diagnose bottlenecks in their IT
> > infrastructure.  The primary requirement for this position is a
> > demonstrable aptitude for developing intuitive and attractive
> > interactive web applications.  A basic understanding of networking
> > will be an asset but not a necessity.
>
> > Responsibilities
>
> >     * Design and implement a rich, intuitive and scalable reporting
> > application
> >     * Own design schedules, milestones and deliverables
> >     * Implement a highly unit testable code structure
>
> > Requirements
>
> >     * B.Sc. in Computer Science, Engineering or Mathematics
> >     * Evidence and examples of previously developed web interfaces
> >     * Minimum of 2 years professional experience
> >     * Experience using AJAX, JavaScript, JQuery, JSON, Python, Django
>
> >http://hire.jobvite.com/CompanyJobs/Careers.aspx?c=qHW9Vfwr=1=...

-- 
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: Is Django right for what I am trying to do

2010-07-08 Thread CLIFFORD ILKAY

On 07/08/2010 06:07 PM, Bradley Hintze wrote:

Thanks, that helps but I wish Django had more tutorial than one.


There is no shortage of Django tutorials and screencasts. Just Google 
for them. Showmedo.com, Vimeo, Blip.tv, and YouTube all have Django 
resources.

--
Regards,

Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada  M4N 3P6


+1 416-410-3326

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-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: Is Django right for what I am trying to do

2010-07-08 Thread Rolando Espinoza La Fuente
On Thu, Jul 8, 2010 at 5:23 PM, Bradley Hintze
 wrote:
> I guess I just don't like the model.py, views.py, templates, and
> url.py. In the tutorial you have to edit all of these and THEN you get
> something that you can send to the client. It's very confusing! How do
> they tie together? I probably need to do the tutorial again. It seems
> to me getting info from the user should be strait foreword but its not
> as displayed by the rather lengthy tutorial. But than I'm new to
> this...

I think tutorial tries to show off django's features and how easy is to get
a data-driven web app with few code.

Anyway, django doesn't do any magic at all. You don't need models if you don't
store the information in a database. You don't need use django's templates
if you don't want.

Usually, in your view _you_ tie together the model with the template and
return a response which django pass to the user doing all the http stuff.

Try this:

""" file mytest.py """
# you require to return a HttpResponse instance in your view
from django.http import HttpResponse
# handler* are required for the urlresolver
from django.conf.urls.defaults import patterns, handler404, handler500

# minimal settings
DEBUG = True
# tell django to use this file to find urlpatterns. see below
ROOT_URLCONF = "mytest"

# a basic callback to return something to the user. "view" in django's idiom
def myview(request):
# you can use html content if you want
return HttpResponse("Boo!")

# finally tie a url route to our view
urlpatterns = patterns("",
# the regex is used to match whatever after /
# ^$ means "nothing", so route the url / to our callback "myview"
(r"^$", myview),
)

# /end


That's all you need. Then run: (you are in linux?)

$ PYTHONPATH=.  django-admin.py runserver --settings=mytest

PYTONPATH=. <- needed to tell python where to find our mytest.py
--settings=mytest  <- needed to tell django where to find the
"project's settings"

If you want learn and/or have more control over all the things and
stay "close to the iron",
you can try a micro-framework or go directly to wsgi. Search for:
werkzeug, web.py, flask, etc

Regards,

~Rolando

-- 
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: Is Django right for what I am trying to do

2010-07-08 Thread Bradley Hintze
Thanks man!!

On Thu, Jul 8, 2010 at 6:11 PM, larsendt  wrote:
> Check out djangobook.com. It's a much longer tutorial, and really well
> written.
>
> On Jul 8, 4:07 pm, Bradley Hintze  wrote:
>> Thanks, that helps but I wish Django had more tutorial than one. I
>> seem to learn by example. I am trying to make an form for uploading
>> files but no matter how many times I read the documentation I cant
>> seem to get the form to the client, let alone how to store the file.
>> Do you know how to get objects from your model (FileForm) to your
>> template?
>>
>> On Thu, Jul 8, 2010 at 5:51 PM, CLIFFORD ILKAY
>>
>>
>>
>>
>>
>>  wrote:
>> > On 07/08/2010 05:23 PM, Bradley Hintze wrote:
>>
>> >> I guess I just don't like the model.py, views.py, templates, and
>> >> url.py. In the tutorial you have to edit all of these and THEN you get
>> >> something that you can send to the client. It's very confusing! How do
>> >> they tie together? I probably need to do the tutorial again. It seems
>> >> to me getting info from the user should be strait foreword but its not
>> >> as displayed by the rather lengthy tutorial. But than I'm new to
>> >> this...
>>
>> > It's actually pretty simple and logical. Here is a possibly over-simplified
>> > overview.
>>
>> > models.py is where you model your problem. If you have an entity "Books",
>> > you would have a Book model along with its attributes. From this model,
>> > Django will generate the database objects once you run syncdb.
>>
>> > urls.py is the place where you specify what happens when a particular URL 
>> > is
>> > requested. Django goes down the list of your regular expressions in there
>> > until it finds a match (or doesn't). Once it finds a match, the request is
>> > passed to the view function for that match. If it doesn't find a match,
>> > Django raises a 404 exception.
>>
>> > views.py is where you have the various functions that are invoked from
>> > urls.py handle the requests and pass the results to templates.
>>
>> > The templates are just HTML files with special tags embedded in them. Think
>> > of the tags as "holes" on the page that will eventually get filled by the
>> > data coming from view functions.
>>
>> > The Django framework ties all this together. For the purpose of the 
>> > tutorial
>> > and for writing apps, you really don't need to know the details of how it
>> > does that but of course if you want to, you can.
>> > --
>> > Regards,
>>
>> > Clifford Ilkay
>> > Dinamis
>> > 1419-3266 Yonge St.
>> > Toronto, ON
>> > Canada  M4N 3P6
>>
>> > 
>> > +1 416-410-3326
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups
>> > "Django users" group.
>> > To post to this group, send email to django-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.
>>
>> --
>> Bradley J. Hintze
>> Graduate Student
>> Duke University
>> School of Medicine
>> 801-712-8799
>
> --
> 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.
>
>



-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

-- 
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: Is Django right for what I am trying to do

2010-07-08 Thread larsendt
Check out djangobook.com. It's a much longer tutorial, and really well
written.

On Jul 8, 4:07 pm, Bradley Hintze  wrote:
> Thanks, that helps but I wish Django had more tutorial than one. I
> seem to learn by example. I am trying to make an form for uploading
> files but no matter how many times I read the documentation I cant
> seem to get the form to the client, let alone how to store the file.
> Do you know how to get objects from your model (FileForm) to your
> template?
>
> On Thu, Jul 8, 2010 at 5:51 PM, CLIFFORD ILKAY
>
>
>
>
>
>  wrote:
> > On 07/08/2010 05:23 PM, Bradley Hintze wrote:
>
> >> I guess I just don't like the model.py, views.py, templates, and
> >> url.py. In the tutorial you have to edit all of these and THEN you get
> >> something that you can send to the client. It's very confusing! How do
> >> they tie together? I probably need to do the tutorial again. It seems
> >> to me getting info from the user should be strait foreword but its not
> >> as displayed by the rather lengthy tutorial. But than I'm new to
> >> this...
>
> > It's actually pretty simple and logical. Here is a possibly over-simplified
> > overview.
>
> > models.py is where you model your problem. If you have an entity "Books",
> > you would have a Book model along with its attributes. From this model,
> > Django will generate the database objects once you run syncdb.
>
> > urls.py is the place where you specify what happens when a particular URL is
> > requested. Django goes down the list of your regular expressions in there
> > until it finds a match (or doesn't). Once it finds a match, the request is
> > passed to the view function for that match. If it doesn't find a match,
> > Django raises a 404 exception.
>
> > views.py is where you have the various functions that are invoked from
> > urls.py handle the requests and pass the results to templates.
>
> > The templates are just HTML files with special tags embedded in them. Think
> > of the tags as "holes" on the page that will eventually get filled by the
> > data coming from view functions.
>
> > The Django framework ties all this together. For the purpose of the tutorial
> > and for writing apps, you really don't need to know the details of how it
> > does that but of course if you want to, you can.
> > --
> > Regards,
>
> > Clifford Ilkay
> > Dinamis
> > 1419-3266 Yonge St.
> > Toronto, ON
> > Canada  M4N 3P6
>
> > 
> > +1 416-410-3326
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-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.
>
> --
> Bradley J. Hintze
> Graduate Student
> Duke University
> School of Medicine
> 801-712-8799

-- 
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: News on every page

2010-07-08 Thread Antoni Aloy
I would use a custom template tag with cache

El 08/07/2010 18:17, "Andy McKay"  escribió:

On 2010-07-08, at 9:07 AM, Martin Tiršel wrote:
> 1.) Where is the right place to place news loader?...
Middleware is not the appropriate place, a context processor is the
appropriate place.
--
 Andy McKay, @andymckay
 Django Consulting, Training and Support


-- 
You received this message because you are subscribed to the Google Groups
"Django users" group

-- 
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: Is Django right for what I am trying to do

2010-07-08 Thread Bradley Hintze
Thanks, that helps but I wish Django had more tutorial than one. I
seem to learn by example. I am trying to make an form for uploading
files but no matter how many times I read the documentation I cant
seem to get the form to the client, let alone how to store the file.
Do you know how to get objects from your model (FileForm) to your
template?

On Thu, Jul 8, 2010 at 5:51 PM, CLIFFORD ILKAY
 wrote:
> On 07/08/2010 05:23 PM, Bradley Hintze wrote:
>>
>> I guess I just don't like the model.py, views.py, templates, and
>> url.py. In the tutorial you have to edit all of these and THEN you get
>> something that you can send to the client. It's very confusing! How do
>> they tie together? I probably need to do the tutorial again. It seems
>> to me getting info from the user should be strait foreword but its not
>> as displayed by the rather lengthy tutorial. But than I'm new to
>> this...
>
> It's actually pretty simple and logical. Here is a possibly over-simplified
> overview.
>
> models.py is where you model your problem. If you have an entity "Books",
> you would have a Book model along with its attributes. From this model,
> Django will generate the database objects once you run syncdb.
>
> urls.py is the place where you specify what happens when a particular URL is
> requested. Django goes down the list of your regular expressions in there
> until it finds a match (or doesn't). Once it finds a match, the request is
> passed to the view function for that match. If it doesn't find a match,
> Django raises a 404 exception.
>
> views.py is where you have the various functions that are invoked from
> urls.py handle the requests and pass the results to templates.
>
> The templates are just HTML files with special tags embedded in them. Think
> of the tags as "holes" on the page that will eventually get filled by the
> data coming from view functions.
>
> The Django framework ties all this together. For the purpose of the tutorial
> and for writing apps, you really don't need to know the details of how it
> does that but of course if you want to, you can.
> --
> Regards,
>
> Clifford Ilkay
> Dinamis
> 1419-3266 Yonge St.
> Toronto, ON
> Canada  M4N 3P6
>
> 
> +1 416-410-3326
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.
>
>



-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

-- 
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: Is Django right for what I am trying to do

2010-07-08 Thread CLIFFORD ILKAY

On 07/08/2010 05:23 PM, Bradley Hintze wrote:

I guess I just don't like the model.py, views.py, templates, and
url.py. In the tutorial you have to edit all of these and THEN you get
something that you can send to the client. It's very confusing! How do
they tie together? I probably need to do the tutorial again. It seems
to me getting info from the user should be strait foreword but its not
as displayed by the rather lengthy tutorial. But than I'm new to
this...


It's actually pretty simple and logical. Here is a possibly 
over-simplified overview.


models.py is where you model your problem. If you have an entity 
"Books", you would have a Book model along with its attributes. From 
this model, Django will generate the database objects once you run syncdb.


urls.py is the place where you specify what happens when a particular 
URL is requested. Django goes down the list of your regular expressions 
in there until it finds a match (or doesn't). Once it finds a match, the 
request is passed to the view function for that match. If it doesn't 
find a match, Django raises a 404 exception.


views.py is where you have the various functions that are invoked from 
urls.py handle the requests and pass the results to templates.


The templates are just HTML files with special tags embedded in them. 
Think of the tags as "holes" on the page that will eventually get filled 
by the data coming from view functions.


The Django framework ties all this together. For the purpose of the 
tutorial and for writing apps, you really don't need to know the details 
of how it does that but of course if you want to, you can.

--
Regards,

Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada  M4N 3P6


+1 416-410-3326

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

2010-07-08 Thread TheIvIaxx
Lets say for a model i have the following:

class Image(models.Model):
image = models.ImageField()

>>> image = Image()
>>> # Somehow get ID
>>> destination = open('ID/name.jpg', 'wb+')
>>> for chunk in f.chunks():
...destination.write(chunk)
>>> destination.close()
>>> image.image = "ID/name.jpg"
>>> image.save()

I'd like to save the image file into a folder based on the ID of the
new instance.  The only thing i can think of is to create the new
folder mid transaction.  I guess another way to do it would be to save
a new instance with a temp file or set it to null=True, then create
the folder, but that seems bad to me.

Thanks

On May 29, 8:30 am, Praveen  wrote:
> Did you really mean for commit=FALSE or pre_save signal???
> Praveen
>
> On May 29, 5:22 pm, Euan Goddard 
> wrote:
>
>
>
> > Hi,
>
> > Could you explain the situation in a little more detail as I don't
> > quite follow what you mean. As far as I'm aware if you have something
> > like the following:
>
> > >>> my_inst = MyModel(foo="bar", ...)
> > >>> my_inst.save()
>
> > You'll have the pk at this point even if the transaction hasn't been
> > committed (providing you haven't specified a custom primary key
> > field). So you should be able to do:
>
> > >>> my_pk = my_inst.pk
>
> > and use this for the other field that you need to set. If the other
> > field is a foreign key to my_inst, then you should just be able to do:
>
> > >>> other_model_inst.related_object = my_inst
> > >>> other_model_inst.save()
>
> > I'm not sure how this is affected by transactions. Unless you have a
> > really good reason to, I'd let Django handle the transaction
> > management for you, then you don't need to worry about save points,
> > committing and rolling back.
>
> > Euan
>
> > On 29 May, 07:56,TheIvIaxx wrote:
>
> > > Hello, I am trying to figure out how to get a pk in the middle of a
> > > transaction. I need to set a field in the model based on the
> > > ID(default pk) to be given.  As far as a i know, this ID should be
> > > allocated during the transaction.  So i would imagine it would do the
> > > INSERT, then i could get the pk and do what i need to do, then proceed
> > > with the commit.
>
> > > Is this possible?
>
> > > Thanks

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



Re: Is Django right for what I am trying to do

2010-07-08 Thread Bradley Hintze
I guess I just don't like the model.py, views.py, templates, and
url.py. In the tutorial you have to edit all of these and THEN you get
something that you can send to the client. It's very confusing! How do
they tie together? I probably need to do the tutorial again. It seems
to me getting info from the user should be strait foreword but its not
as displayed by the rather lengthy tutorial. But than I'm new to
this...

On Thu, Jul 8, 2010 at 5:08 PM, Daniel Roseman  wrote:
> On Jul 8, 6:43 pm, Bradley Hintze  wrote:
>> Hi all
>>
>> I did the tutorial and I've spent the last two days in the
>> documentation trying, and failing, to figure out how to tie my model
>> to a view and ultimately a template that is served. The documentation
>> seems to do a lot of things (like write html) automatically which is
>> not what I want (seehttp://docs.djangoproject.com/en/dev/topics/forms/).  I 
>> am not
>> interested in admin sites, they make things easier but I am interested
>> in learning the code (i.e. the HTML and how it communicates with
>> python) rather than, in my view, just blackbox automation.
>>
>> I hope this makes sense. Please tell me if it doesn't.  I want to
>> simply upload a file and then process the file using code I already
>> have. I would like to write the HTML code myself rather then having
>> django automatically do it. This is because I want to learn how to
>> process forms and not have a black box do everything for me. Are there
>> methods to simply get post data from a form that I write rather the
>> django automatically creating it (an example maybe)? are models
>> necessary for what I'm explaining? Is django right for what I'm
>> explaining?
>>
>> --
>> Bradley J. Hintze
>> Graduate Student
>> Duke University
>> School of Medicine
>> 801-712-8799
>
> Django doesn't write any HTML for you. The admin is an automatically-
> created system, true, but that has nothing to do with the pages you
> serve to your users. And the forms documentation you point to shows
> how to generate a form and display it in the template without
> 'automatically creating it' - is there anything here:
> http://docs.djangoproject.com/en/dev/topics/forms/#customizing-the-form-template
> that doesn't make sense to you? The only thing 'automatic' about that
> example is that you type {{ form.subject }} and Django outputs  id="id_subject">.
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

-- 
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: Maintain separate i18n translation (.po) for different applications

2010-07-08 Thread Baurzhan Ismagulov
On Thu, Jul 08, 2010 at 10:39:25AM -0700, Behrooz Nobakht wrote:
> I am not an expert in Django/Python, so what I have at the moment is
> only mysite/locale/xx/django.po for both app1 and app2. But, actually
> I need to separately have mysite/app1/locale/xx/app1.po and mysite/
> app2/locale/xx/app2.po and then be able to merge them into mysite/
> locale/xx/django.po.

I've just tried running mkdir locale; ../manage.py makemessages -l ru in
mysite/app1, seems to work.

With kind regards,
Baurzhan.

-- 
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 X Media Temple (dedicated Virtual Server) How To?

2010-07-08 Thread heru
Hi,

I just got access to my DVS through Media Temple and I am lost as to
how to configure the database in django based on Media Temple's
plesk-8 interface. Note, I am first time user of Django. Thank You!

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



Re: Is Django right for what I am trying to do

2010-07-08 Thread Daniel Roseman
On Jul 8, 6:43 pm, Bradley Hintze  wrote:
> Hi all
>
> I did the tutorial and I've spent the last two days in the
> documentation trying, and failing, to figure out how to tie my model
> to a view and ultimately a template that is served. The documentation
> seems to do a lot of things (like write html) automatically which is
> not what I want (seehttp://docs.djangoproject.com/en/dev/topics/forms/).  I 
> am not
> interested in admin sites, they make things easier but I am interested
> in learning the code (i.e. the HTML and how it communicates with
> python) rather than, in my view, just blackbox automation.
>
> I hope this makes sense. Please tell me if it doesn't.  I want to
> simply upload a file and then process the file using code I already
> have. I would like to write the HTML code myself rather then having
> django automatically do it. This is because I want to learn how to
> process forms and not have a black box do everything for me. Are there
> methods to simply get post data from a form that I write rather the
> django automatically creating it (an example maybe)? are models
> necessary for what I'm explaining? Is django right for what I'm
> explaining?
>
> --
> Bradley J. Hintze
> Graduate Student
> Duke University
> School of Medicine
> 801-712-8799

Django doesn't write any HTML for you. The admin is an automatically-
created system, true, but that has nothing to do with the pages you
serve to your users. And the forms documentation you point to shows
how to generate a form and display it in the template without
'automatically creating it' - is there anything here:
http://docs.djangoproject.com/en/dev/topics/forms/#customizing-the-form-template
that doesn't make sense to you? The only thing 'automatic' about that
example is that you type {{ form.subject }} and Django outputs .
--
DR.

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



translation for variables

2010-07-08 Thread Börni
Hello together,
i'm using the trans tpl tag for translation a value from database. If
i'm adding this value to my django.po file and run makemessages
afterwards, my changes got lost.

I wonder how it's possible to handle such situations?

Thank you very much,
Börni

-- 
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: Overwhelmed by File upload instructions

2010-07-08 Thread Daniel Roseman
On Jul 8, 6:28 pm, Rodion Raskolnikiv  wrote:
> Good morning!
> I have been wanting to design a model (to be administered via the
> admin area) which would allow for file uploads. I have not been able
> to grasp a singular, simple approach to this. Perhaps things are
> complicated by Django's preference for serving media files under a
> different domain, but this is pretty crucial to my project and I was
> hoping that someone could point me in the right direction.
>
> This post seems most 
> helpful:http://groups.google.com/group/django-users/msg/02cf3d1a838e7e46
>
> but I don't want to blindly copy it and end up with a batch system! I
> am just looking to make a simple file uploader.
>
> The model might look like this:
>
> class UploadedFile(models.Model):
>     title = models.CharField(max_length=250)
>     file = forms.FileField() # I don't know if this is how to define
> it
>     file_type = models.CharField(max_length=25)
>     date_created = models.DateTimeField()
>
> I am a huge fan of Python and Django, and I am often surprised by how
> simple and elegant the solutions are, my problem is usually that I am
> trying to do things the difficult way...
>
> Any assistance would be greatly appreciated!

The documentation for file uploads is indeed complicated, but in order
to enable file uploads in the admin you don't need to worry about any
of that.

However you seem to be trying to declare a form field within a model.
You should of course use the models.FileField, which is fully
documented here:
http://docs.djangoproject.com/en/1.2/ref/models/fields/#filefield
Note that the only thing you *need* to do is to set a value for
upload_to.
--
DR.

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



Re: Overwhelmed by File upload instructions

2010-07-08 Thread Rodion Raskolnikiv
I was totally on the wrong trail!

Hopefully this post can serve others who were in my dilemma:

If you are looking to have a file as part of your model definition,
look here:
http://docs.djangoproject.com/en/dev/topics/files/


Looking in these locations did not supply what I was after:
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#topics-http-file-uploads
http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

I don't have it entirely working just yet, but this is what I was
looking to do.

On Jul 8, 11:25 am, Rodion Raskolnikiv  wrote:
> To be more specific, here is what I have tried:
>
> # in models.py
> from django import forms
>
> class UploadFileForm(forms.Form):
>     title = forms.CharField(max_length=50)
>     file  = forms.FileField()
>
> # in admin.py
> from proj.app.models import UploadFileForm
>
> admin.site.register(UploadFileForm)
>
> Which gives me the error message:
> TypeError at /admin/
> 'DeclarativeFieldsMetaclass' object is not iterable
>
> Am I heading in the wrong direction?
>
> On Jul 8, 10:28 am, Rodion Raskolnikiv  wrote:
>
>
>
> > Good morning!
> > I have been wanting to design a model (to be administered via the
> > admin area) which would allow for file uploads. I have not been able
> > to grasp a singular, simple approach to this. Perhaps things are
> > complicated by Django's preference for serving media files under a
> > different domain, but this is pretty crucial to my project and I was
> > hoping that someone could point me in the right direction.
>
> > This post seems most 
> > helpful:http://groups.google.com/group/django-users/msg/02cf3d1a838e7e46
>
> > but I don't want to blindly copy it and end up with a batch system! I
> > am just looking to make a simple file uploader.
>
> > The model might look like this:
>
> > class UploadedFile(models.Model):
> >     title = models.CharField(max_length=250)
> >     file = forms.FileField() # I don't know if this is how to define
> > it
> >     file_type = models.CharField(max_length=25)
> >     date_created = models.DateTimeField()
>
> > I am a huge fan of Python and Django, and I am often surprised by how
> > simple and elegant the solutions are, my problem is usually that I am
> > trying to do things the difficult way...
>
> > Any assistance would be greatly appreciated!

-- 
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: Overwhelmed by File upload instructions

2010-07-08 Thread Daniel Roseman
On Jul 8, 7:25 pm, Rodion Raskolnikiv  wrote:
> To be more specific, here is what I have tried:
>
> # in models.py
> from django import forms
>
> class UploadFileForm(forms.Form):
>     title = forms.CharField(max_length=50)
>     file  = forms.FileField()
>
> # in admin.py
> from proj.app.models import UploadFileForm
>
> admin.site.register(UploadFileForm)
>
> Which gives me the error message:
> TypeError at /admin/
> 'DeclarativeFieldsMetaclass' object is not iterable
>
> Am I heading in the wrong direction?

I don't know what this message has to do with your original question
about file uploads. This is simply a matter of admin configuration -
for some reason you are trying to register a Form as a model in the
admin, which of course won't work. If you revert to the syntax of
declaring the class as a subclass of models.Model, and the fields as
models.CharField and models.FileField etc, all should be well.
--
DR.

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



Re: reportlab pdf creation: HTML textarea input formatting doesn't seem to work with Paragraph

2010-07-08 Thread thusjanthan
Basically what I am doing right now as a workaround is I wrote a
function to parse/wrap the value before printing it out. Anyone else
have a better solution please do let me know.

def preformat_html_textarea(value,endwidth=135):
''' since reportlab doesn't provide a way to keep the  of
what ever
is entered in the html textarea. This is manual way to text
wrap.
'''
import textwrap
new_value = value.replace('\r','')
new_values = new_value.split('\n')
result = ""
for line in new_values:
result += textwrap.fill(line,endwidth) + "\n"

return result


Thusjanthan


On Jul 8, 11:53 am, thusjanthan  wrote:
> Hi,
>
> I have a user that enters some formatted text in a html textarea. I
> would like to use reportlab to display that and other fields in a PDF.
> However when I wrap the text in a Paragraph type it alters the
> formatting. Can anyone suggest how to keep the formatting that the
> user enters into the textarea such as spaces and new lines etc.
>
> Example:
>
> objectives:
> Hi
>
> My name is blah etc..
>
> endcontent
>
> PythonCode:
>
> Story.append(Paragraph("%s" % objectives,styles['NormalIndent']))
>
> However the pdf outputs this as all clumped together like: "Hi My name
> is blah etc.. endcontent"
>
> Any thoughts?
>
> Cheers,
> Nathan.

-- 
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 caching and multi db

2010-07-08 Thread tiemonster
I was able to fix the issue using the TEST_MIRROR database setting
(http://docs.djangoproject.com/en/1.2/topics/testing/#testing-master-
slave-configurations). While this relationship isn't exactly master-
slave in our situation, the datastore connection is indeed read-only.
Using this setting allowed me to run the unit tests successfully.

-- 
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: list display based on logged-in user

2010-07-08 Thread rahul jain
I am not sure what I am doing wrong but this should work

class TestAdmin(admin.ModelAdmin):

list_display = (field1, field2, field3, fileld4, field5,field6)


class CustomTestAdmin(TestAdmin):

custom_list_display = (field1, field2, field3) # showing less
number of fields

def change_view(self, request, *args, **kwargs):
if not request.user.is_superuser:
self.list_display = self.custom_list_display# 
setting list display
return TestAdmin.change_view(self, request, *args, 
**kwargs)
else:
return TestAdmin.change_view(self, request, *args, 
**kwargs)

admin.site.register (Test, CustomTestAdmin)

So even if the user is not super user display is same, all the fields :( .

--RJ









On Thu, Jul 8, 2010 at 6:56 AM, derek  wrote:
> On Jul 7, 11:40 pm, rahul jain  wrote:
>> Hi there !
>>
>> I would like to display model fields based on the logged-in user.
>>
>> If user is restricted user
>>
>> list_display = (field1, field2)
>>
>> else
>>
>> list_display = (field1, field2, field3, field4)
>>
>> How is it possible ?
>>
>
> Also see:
> http://stackoverflow.com/questions/2297377/how-do-i-prevent-permission-escalation-in-django-admin-when-granting-user-change
>
> --
> 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.



reportlab pdf creation: HTML textarea input formatting doesn't seem to work with Paragraph

2010-07-08 Thread thusjanthan
Hi,

I have a user that enters some formatted text in a html textarea. I
would like to use reportlab to display that and other fields in a PDF.
However when I wrap the text in a Paragraph type it alters the
formatting. Can anyone suggest how to keep the formatting that the
user enters into the textarea such as spaces and new lines etc.

Example:

objectives:
Hi

My name is blah etc..


endcontent


PythonCode:

Story.append(Paragraph("%s" % objectives,styles['NormalIndent']))

However the pdf outputs this as all clumped together like: "Hi My name
is blah etc.. endcontent"

Any thoughts?

Cheers,
Nathan.

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



Bank Street College is looking for a Senior Agile Web Developer

2010-07-08 Thread Michael
Contact Christina or Arshad: cdaie...@bankstreet.edu,
aah...@bankstreet.edu

Location: New York City, NY

Bank Street is a small college with a big voice in education, one
heard and respected far and wide. Bank Street was founded in 1916 in
New York City by visionary educator Lucy Sprague Mitchell. Over the
years it has grown into an internationally-recognized leader in early
childhood education, a pioneer in improving the quality of classroom
education and teacher preparation, and a national advocate for
children and families. It has also had a national impact on American
education through its key roles in the design of such innovative
programs as Head Start and Follow Through, as well as through its
ongoing work in public school systems. Bank Street educates children,
the educators who teach them, parents, school leaders, and those who
make policy. The College is a rich source of innovative ideas and
practices for all who care about children and their education. Bank
Street College is based in the Upper West side on 112th street and
Broadway, NYC.
Bank Street is currently taking on an ambitious redesign project for
bankstreet.edu. We’re on the hunt for experienced, professional, and
highly motivated Senior LAMP/Python Engineers to join our team.
Experience with Python, MySQL, Apache, AJAX, and an eye for great
design and functionality are all needed for this position. If you love
coding, working on big cutting edge web projects, and want to be part
of a progressive institution that has been defining education in the
past 100 years, we want to hear from you!

Responsibilities:
•   Lead development of the bankstreet.edu redesign project
•   Integration with internal organizational systems and Learning
Management Systems
•   Technological leadership of the website project and the ability to
lead and mentor junior developers
•   Work with Open Source libraries, customizing them and potentially
contributing back to them

Experience:
•   Minimum 3 years of experience writing top quality server-side code
at high traffic websites
•   Strong skills in agile web development frameworks (Django, Rails,
Grails and the likes) and with their CMS implementation and
customization
•   Strong MySQL skills
•   Strong up-to-date working knowledge of front-end technologies (HTML,
CSS, Ajax, Javascript, JQuery)
•   Commitment to standard compliant front end code and strong
experience in cross-browser optimization
•   Experience with Java
•   Experience with J2EE, Liferay and the Java Portlet specification
(JSR168, JSR286) a plus
•   Some management experience and/or web design experience are a plus
•   Demonstrated ability to work independently as part of a small team
•   Technical aptitude and problem-solving skills through cooperative
approaches.
•   BS/MS/PhD in CS or equivalent

-- 
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: No module named site - error deploying a django-jython war in tomcat

2010-07-08 Thread Rafael Nunes
Same problem here.

Any thoughts?

On Jun 29, 10:50 am, tobycatlin  wrote:
> Hello everybody,
>
> I have followed the install instructions for the latest versions of
> the following: jython (version: jython-2.5.2b1), django (1.2.1) and
> jython-django (version 1.1.1) and have built a war of my very simple
> test application.
>
> Oh i built the war on my linux box and have tested in tomcat on both
> windows and linux machines. When i went to the url i got a 500
> exception:
>
> javax.servlet.ServletException: Exception creating modjy servlet:
> ImportError: No module named site
>
>         com.xhaus.modjy.ModjyJServlet.init(ModjyJServlet.java:124)
>         javax.servlet.GenericServlet.init(GenericServlet.java:211)
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
> 105)
>         org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
> 541)
>
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
> 148)
>         org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
> 869)
>         org.apache.coyote.http11.Http11BaseProtocol
> $Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:
> 664)
>
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:
> 527)
>
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:
> 80)
>         org.apache.tomcat.util.threads.ThreadPool
> $ControlRunnable.run(ThreadPool.java:684)
>         java.lang.Thread.run(Thread.java:619)
>
> I have managed to find a fair amount of documentation on building the
> war but all the docs say "just deploy the war normally" so i guess i
> have missed something in building the war itself. I set a JYTHONPATH
> env var, is there anything else i should have done?
>
> I can supply the war file, but it is 30mb so if it helps i'll post a
> link to it for folk to download
>
> Thanks for any and all help
>
> toby

-- 
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: Overwhelmed by File upload instructions

2010-07-08 Thread Rodion Raskolnikiv
To be more specific, here is what I have tried:

# in models.py
from django import forms

class UploadFileForm(forms.Form):
title = forms.CharField(max_length=50)
file  = forms.FileField()

# in admin.py
from proj.app.models import UploadFileForm

admin.site.register(UploadFileForm)

Which gives me the error message:
TypeError at /admin/
'DeclarativeFieldsMetaclass' object is not iterable

Am I heading in the wrong direction?


On Jul 8, 10:28 am, Rodion Raskolnikiv  wrote:
> Good morning!
> I have been wanting to design a model (to be administered via the
> admin area) which would allow for file uploads. I have not been able
> to grasp a singular, simple approach to this. Perhaps things are
> complicated by Django's preference for serving media files under a
> different domain, but this is pretty crucial to my project and I was
> hoping that someone could point me in the right direction.
>
> This post seems most 
> helpful:http://groups.google.com/group/django-users/msg/02cf3d1a838e7e46
>
> but I don't want to blindly copy it and end up with a batch system! I
> am just looking to make a simple file uploader.
>
> The model might look like this:
>
> class UploadedFile(models.Model):
>     title = models.CharField(max_length=250)
>     file = forms.FileField() # I don't know if this is how to define
> it
>     file_type = models.CharField(max_length=25)
>     date_created = models.DateTimeField()
>
> I am a huge fan of Python and Django, and I am often surprised by how
> simple and elegant the solutions are, my problem is usually that I am
> trying to do things the difficult way...
>
> Any assistance would be greatly appreciated!

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



PostgreSQL 7.4/8.0/8.1 EOL

2010-07-08 Thread Joshua D. Drake
Hello,

I wanted to let the Django community know that PostgreSQL has stated an
EOL (End of Life) for PostgreSQL versions 7.4, 8.0, and 8.1.

If you are running any version of PostgreSQL 7.4, 8.0 or 8.1, it is time
to upgrade to 8.3 or 8.4. The versions 7.4 and 8.0 are slated for end of
life at the end of this month. The 8.1 version is slated for end of life
in November.

This is not an item to take lightly. Once a version is end of life you
will not be able to get support (easily), there will be no more security
updates and no bug fixes even if they are data loss bugs.

Sincerely,

Joshua D. Drake
-- 
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering

-- 
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: context porcessors request.context media_url breaks admin

2010-07-08 Thread Rolando Espinoza La Fuente
On Thu, Jul 8, 2010 at 8:21 AM, justin jools  wrote:
> Wow... django docs can be so confusing...
>
> I could not believe it worked just by using upper case MEDIA_URL

{{ MEDIA_URL }} is already present in the templates because the
django.core.context_processors.media  context processor which
is enabled by default*.

You didn't need to create a media_url context processor at all.
And templates tags are called with {% %} .e.g {% media_url %}

Regards

~Rolando

* http://docs.djangoproject.com/en/dev/ref/templates/api/#id1

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



Is Django right for what I am trying to do

2010-07-08 Thread Bradley Hintze
Hi all

I did the tutorial and I've spent the last two days in the
documentation trying, and failing, to figure out how to tie my model
to a view and ultimately a template that is served. The documentation
seems to do a lot of things (like write html) automatically which is
not what I want (see
http://docs.djangoproject.com/en/dev/topics/forms/).  I am not
interested in admin sites, they make things easier but I am interested
in learning the code (i.e. the HTML and how it communicates with
python) rather than, in my view, just blackbox automation.

I hope this makes sense. Please tell me if it doesn't.  I want to
simply upload a file and then process the file using code I already
have. I would like to write the HTML code myself rather then having
django automatically do it. This is because I want to learn how to
process forms and not have a black box do everything for me. Are there
methods to simply get post data from a form that I write rather the
django automatically creating it (an example maybe)? are models
necessary for what I'm explaining? Is django right for what I'm
explaining?

-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

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



Database caching and multi db

2010-07-08 Thread tiemonster
It seems that when running unit tests, the test runner not only
creates all tables on both of my connections (which it should not do,
if I read the documentation correctly), but also tries to create the
cache table twice, causing the error below. Please let me know if I'm
missing something here. I have two MySQL connections, called default
and datastore, and have my CACHE_BACKEND set to db://cache_table.


Traceback (most recent call last):
  File "./manage.py", line 11, in 
execute_manager(settings)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/base.py", line 218, in execute
output = self.handle(*args, **options)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/commands/test.py", line 37, in handle
failures = test_runner.run_tests(test_labels)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/test/simple.py", line 313, in run_tests
old_config = self.setup_databases()
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/test/simple.py", line 270, in setup_databases
connection.creation.create_test_db(self.verbosity, autoclobber=not
self.interactive)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/db/backends/creation.py", line 358, in create_test_db
call_command('createcachetable', cache_name)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/base.py", line 218, in execute
output = self.handle(*args, **options)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/base.py", line 318, in handle
label_output = self.handle_label(label, **options)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/commands/createcachetable.py", line 50, in
handle_label
curs.execute("\n".join(full_statement))
  File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/db/backends/mysql/base.py", line 86, in execute
return self.cursor.execute(query, args)
  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in
execute
self.errorhandler(self, exc, value)
  File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35,
in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1050, "Table 'cache_table'
already exists")

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



Maintain separate i18n translation (.po) for different applications

2010-07-08 Thread Behrooz Nobakht
Hi,

Consider the following sample:

mysite
--app1
locale
--app2
locale
--locale

What I need is to be able to maintain different translation files for
each application I have in the site, and finally use makemessages and
compilesmessages to merge them together as the django.po/mo
translation files.

I am not an expert in Django/Python, so what I have at the moment is
only mysite/locale/xx/django.po for both app1 and app2. But, actually
I need to separately have mysite/app1/locale/xx/app1.po and mysite/
app2/locale/xx/app2.po and then be able to merge them into mysite/
locale/xx/django.po.

Is there any solution I could use?
Thanks in advance.

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



Overwhelmed by File upload instructions

2010-07-08 Thread Rodion Raskolnikiv
Good morning!
I have been wanting to design a model (to be administered via the
admin area) which would allow for file uploads. I have not been able
to grasp a singular, simple approach to this. Perhaps things are
complicated by Django's preference for serving media files under a
different domain, but this is pretty crucial to my project and I was
hoping that someone could point me in the right direction.

This post seems most helpful:
http://groups.google.com/group/django-users/msg/02cf3d1a838e7e46

but I don't want to blindly copy it and end up with a batch system! I
am just looking to make a simple file uploader.

The model might look like this:

class UploadedFile(models.Model):
title = models.CharField(max_length=250)
file = forms.FileField() # I don't know if this is how to define
it
file_type = models.CharField(max_length=25)
date_created = models.DateTimeField()

I am a huge fan of Python and Django, and I am often surprised by how
simple and elegant the solutions are, my problem is usually that I am
trying to do things the difficult way...

Any assistance would be greatly appreciated!

-- 
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: models.py import from other models.py

2010-07-08 Thread Nuno Maltez
What error do you get when you execute  'manage.py syncDB'? Could you
paste it here?

Nuno

On Thu, Jul 8, 2010 at 2:28 AM, yugori  wrote:
> Hi, I'm beginner.
>
> I tried to execute 'manage.py syncDB' command,
> but it's not work.

-- 
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: Tutorial Help

2010-07-08 Thread david
Bradley,

I think there's a typing error somewhere there, search for where  you
have pollsdjango within your script, you might have mistakenly join
some text together.

David

On Jul 6, 4:56 pm, Bradley Hintze  wrote:
> Hi all,
>
> I am following the tutorial part 2
> (http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02)
> and I am stuck. I uncommented the 'django.contrib.admin' as directed
> and ran 'python manage.py syncdb' and got the following error:
>
> Error: No module named pollsdjango.contrib.admin
>
> Any ideas?
>
> --
> Bradley J. Hintze

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



FormWizard

2010-07-08 Thread rupert
Can you register a formwizard app in the admin tool for editing?

-- 
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: www.djangoproject.com

2010-07-08 Thread Nick Raptis
Sorry for the rant but I can finally express my delayed frustration on 
this bug..


I first I spent some 2-3 hours trying to find out if this problem came 
from a broken ipv6 configuration.
Then, I actually had to delete all my profile files (delete half, find 
out if it solves it, restore, delete half again) until I knew that 
prefs.js (the about:config file) was responsible.
I then checked the more than a 6000 lines of that file in the same 
manner (deleting half the lines each time) to find the offending option.

At that time I thought half my hair had gone grey!

The only two sites affected by this was djangoproject.com and 
djangobook.com Could be a django configuration issue on those, as other 
django powered sites behaved normally.


I'm SO glad that my frustrating time hunting this down actually helped 
another soul! :D


I don't know why my profile had the locale option as such. I've migrated 
this profile from windows, then ubuntu karmic to ubuntu lucid, and I'm 
also using weave sync so I can't tell for sure. Hopefully, once you know 
it's there you can easily fix it :)


I'm also sorry for double-posting the last mail. I have both mail 
accounts configured for the  list and thought only one would go through 
as the first answer I sent lagged significantly. I hope this gets sent 
properly.


Glad i could be of help, Nick

On 07/08/2010 06:32 PM, Andi wrote:

On Jul 8, 5:12 pm, Nick Raptis  wrote:
   

If there is a non-standard value there (perhaps "/etc/locale/prefs.conf"
or something) instead of a locale like en-US,
some django pages won't ever display.
 

That's it.  You have to *remove* this non-standard value, it's not
sufficient to add another locale to the first position.

Thank you very much, I would never have found this.
--
Bye, Andi

   


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



Creating an admin for with a list of foreign key

2010-07-08 Thread glacasse

Hi,
Let's say I create an entity named foo and an entity name bar. Bar has a
ForeignKey relationship to Foo (in model.py).
Now, I want to create many bars that are associated to a foo.
Is it possible to create an admin form for foo that will allow to create
many bar entities (which will be automatically associated to this foo) from
foo's admin page?

thank you!
-- 
View this message in context: 
http://old.nabble.com/Creating-an-admin-for-with-a-list-of-foreign-key-tp29108688p29108688.html
Sent from the django-users mailing list archive at Nabble.com.

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



Re: News on every page

2010-07-08 Thread Andy McKay
On 2010-07-08, at 9:07 AM, Martin Tiršel wrote:
> 1.) Where is the right place to place news loader? 
> TEMPLATE_CONTEXT_PROCESSORS seems to be a good place and easy to implement. 
> Another possibility is a middleware, I feel, that it should go there instead 
> of TEMPLATE_CONTEXT_PROCESSORS.


Middleware is not the appropriate place, a context processor is the appropriate 
place.
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

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



News on every page

2010-07-08 Thread Martin Tiršel

Hello,

I am programming a small CMS on Django, I have editable pages, now I want  
to add news. I have a website where I want to display these news on every  
page in right/left column. I have following questions:


1.) Where is the right place to place news loader?  
TEMPLATE_CONTEXT_PROCESSORS seems to be a good place and easy to  
implement. Another possibility is a middleware, I feel, that it should go  
there instead of TEMPLATE_CONTEXT_PROCESSORS.


2.) If I use middleware, how do I smuggle variables into templates? It has  
something to do with the request object, but I don't know how to use it  
for that thing. What should I do in a middleware to have e.g {{ news }}  
template variable containing last x news?


Thanks for your advices,
Martin

--
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: www.djangoproject.com

2010-07-08 Thread Andi
On Jul 8, 5:12 pm, Nick Raptis  wrote:
> If there is a non-standard value there (perhaps "/etc/locale/prefs.conf"
> or something) instead of a locale like en-US,
> some django pages won't ever display.

That's it.  You have to *remove* this non-standard value, it's not
sufficient to add another locale to the first position.

Thank you very much, I would never have found this.
--
Bye, Andi

-- 
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: www.djangoproject.com

2010-07-08 Thread Nick Raptis
Hey, haven't read the whole thread but I spend a whole day last month 
troubleshooting something like this.


In firefox, check your preffered language settings, in the content tab.

If there is a non-standard value there (perhaps "/etc/locale/prefs.conf" 
or something) instead of a locale like en-US,

some django pages won't ever display.

Nick

On 07/08/2010 04:11 PM, eon wrote:

Same for me. The problem is in the firefox profile (maybe due to the
switch from 3.5 to 3.6 ?)

Start-up with a new profile (backport plugins, bookmarks argh...)
resolves the issue

On 5 juil, 20:52, Andi  wrote:


On Jul 2, 10:44 pm, Bill Freeman  wrote:



What might be of help is adding the IP address to /etc/hosts, if you are
on linux.


I have the same problem regarding djangoproject.com (Firefox 3.6.6 on
Ubuntu).  Everything works but Firefox using my default profile: host
and nslookup succeed in resolving the domain name.  Adding the IP to /
etc/hosts or accessing the IP address directly in firefox doesn't
help.  Opera, chromium, arora, w3m, elinks, lynx and konqueror are not
affected.  Firefoxes on other hosts within the same LAN can connect to
djangoproject.com without a problem.  Disabling all add-ons living in
my Firefox doesn't have an effect -- but starting with a fresh profile
does: djangoproject.com loads successfully.

It's a very strange problem, because there is no problem with the
other thousands of websites I've visited during the last days.  It's
the combination djangoproject.com + my main Firefox profile which
produces the problem exclusively.

--
Andi





--
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: www.djangoproject.com

2010-07-08 Thread Nick Raptis
Hey, haven't read the whole thread but I spend a whole day last month 
troubleshooting something like this.


In firefox, check your preffered language settings, in the content tab.

If there is a non-standard value there (perhaps "/etc/locale/prefs.conf" 
or something) instead of a locale like en-US,

some django pages won't ever display.

Nick

On 07/08/2010 04:11 PM, eon wrote:

Same for me. The problem is in the firefox profile (maybe due to the
switch from 3.5 to 3.6 ?)

Start-up with a new profile (backport plugins, bookmarks argh...)
resolves the issue

On 5 juil, 20:52, Andi  wrote:
   

On Jul 2, 10:44 pm, Bill Freeman  wrote:

 

What might be of help is adding the IP address to /etc/hosts, if you are
on linux.
   

I have the same problem regarding djangoproject.com (Firefox 3.6.6 on
Ubuntu).  Everything works but Firefox using my default profile: host
and nslookup succeed in resolving the domain name.  Adding the IP to /
etc/hosts or accessing the IP address directly in firefox doesn't
help.  Opera, chromium, arora, w3m, elinks, lynx and konqueror are not
affected.  Firefoxes on other hosts within the same LAN can connect to
djangoproject.com without a problem.  Disabling all add-ons living in
my Firefox doesn't have an effect -- but starting with a fresh profile
does: djangoproject.com loads successfully.

It's a very strange problem, because there is no problem with the
other thousands of websites I've visited during the last days.  It's
the combination djangoproject.com + my main Firefox profile which
produces the problem exclusively.

--
Andi
 
   


--
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: [Offtopic] Design introduction

2010-07-08 Thread Chris Czub
Much like programming, it will come from experience. Practice a lot. You'll
make a lot of things you aren't happy with, probably like your first bits of
code :) Try to imitate things you like, and see the techniques they use to
create cool designs. It, like anything else worth doing, will be easier with
experience. The best way is to just do. See if you have any artistic friends
that can give feedback on what you're creating. Try to identify what colors
work well together(a site like colourlovers.com is nice for finding color
schemes) and work with those.

On Thu, Jul 8, 2010 at 10:27 AM, Matias  wrote:

> Sorry for this completely offtopic question.
>
> I'm a systems administrator with programming experience (mostly python and
> C) and I love web applications design/programming and I'm pretty good with
> html, javascript, css, etc... but I have a really weak point when it comes
> to "images" desing. I mean, I'd love to learn how to do images like this:
> http://www.freecsstemplates.org/previews/solutions/images/img01.gif
>
> (from the template http://www.freecsstemplates.org/preview/solutions/)
>
> I understand the basics, and I use quite frequently Gimp, but this is not
> like coding, when you code, most of the times it is easy to understand what
> is happenning (except if the code you are reading is perl :-P ) and thus,
> you can learn but I still can't "read" images I see out there, so, I
> guess there should be any learning path for this also or maybe is that just
> the creative half of my brain is missing.
>
> Would you recommend any book? any website? or some other way to learn to do
> "nice 3d looking menus, buttons"..etc?
>
> Thanks for your help, and sorry for the offtopic, but I didn't find a
> better place to ask this. (didn't look for a lot also...)
>
>
> Thanks!
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



[Offtopic] Design introduction

2010-07-08 Thread Matias

Sorry for this completely offtopic question.

I'm a systems administrator with programming experience (mostly python 
and C) and I love web applications design/programming and I'm pretty 
good with html, javascript, css, etc... but I have a really weak point 
when it comes to "images" desing. I mean, I'd love to learn how to do 
images like this:

http://www.freecsstemplates.org/previews/solutions/images/img01.gif

(from the template http://www.freecsstemplates.org/preview/solutions/)

I understand the basics, and I use quite frequently Gimp, but this is 
not like coding, when you code, most of the times it is easy to 
understand what is happenning (except if the code you are reading is 
perl :-P ) and thus, you can learn but I still can't "read" images I 
see out there, so, I guess there should be any learning path for this 
also or maybe is that just the creative half of my brain is missing.


Would you recommend any book? any website? or some other way to learn to 
do "nice 3d looking menus, buttons"..etc?


Thanks for your help, and sorry for the offtopic, but I didn't find a 
better place to ask this. (didn't look for a lot also...)



Thanks!


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



Re: list display based on logged-in user

2010-07-08 Thread derek
On Jul 7, 11:40 pm, rahul jain  wrote:
> Hi there !
>
> I would like to display model fields based on the logged-in user.
>
> If user is restricted user
>
> list_display = (field1, field2)
>
> else
>
> list_display = (field1, field2, field3, field4)
>
> How is it possible ?
>

Also see:
http://stackoverflow.com/questions/2297377/how-do-i-prevent-permission-escalation-in-django-admin-when-granting-user-change

-- 
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: v1.2 message framework - messages created outside of the request cycle

2010-07-08 Thread Mick
I've encountered same issue. My solution is simple model and
middleware:

class OfflineNotification(models.Model):
user = models.ForeignKey(User)
message = models.TextField()
level = models.PositiveSmallIntegerField(default=20)
created = models.DateTimeField(auto_now_add=True)

class OfflineNotificationsMiddleware:

def process_request(self, request):
if request.user.is_authenticated():
notifications =
OfflineNotification.objects.filter(user=request.user).distinct('message')
for notification in notifications:
messages.add_message(request, notification.level,
notification.message)

if notifications:
 
OfflineNotification.objects.filter(user=request.user).delete()

Hope it will help you.

On Jul 8, 12:27 am, jyunis  wrote:
> Hey all,
>
> I'm currently developing an application using Django's deprecated user
> messaging functionality and one of the features I depend on is the
> ability to set messages for a particular user from a back-end process,
> i.e. outside of the request cycle.  In my backend process, I have
> access to the User object, but of course not the request object.
>
> I see that the new Django 1.2 message framework does not support this,
> but I am wondering if that use case has been addressed in any other
> way.  I hate to continue development using a deprecated feature, but
> the lack of offline messaging from the message framework is a
> significant barrier to migration.
>
> --
> Jeremy

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



Accessing settings from mysite from registration module

2010-07-08 Thread reduxdj
Hello Django helpers,

So, I am using the django registration module, and I have it in it's
own project, when I go to send an activation e-mail, apparently the
settings are not configured properly to be found from other projects,
and it can't load mysite variable - so it throws an error.

>From the docs it says I need to this, i think:

django-admin.py syncdb --settings=huntgather.settings

then I get the following (maybe I didn't set this up correctly with a
start project in the first place):

Could not import settings 'huntgather.settings' (Is it on sys.path?
Does it have syntax errors?): No module named huntgather.settings

This link looks promising:

http://codespatter.com/2009/04/10/how-to-add-locations-to-python-path-for-reusable-django-apps/

Is this what I want to do is the following, I'm not sure, so I'll just
paste the example:

import os
import sys
PROJECT_ROOT = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(PROJECT_ROOT, "apps"))

I'm primarily a ui guy but really interested in understanding Django,
so thanks for helping a django n00b.

Patrick

-- 
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: www.djangoproject.com

2010-07-08 Thread eon
Same for me. The problem is in the firefox profile (maybe due to the
switch from 3.5 to 3.6 ?)

Start-up with a new profile (backport plugins, bookmarks argh...)
resolves the issue

On 5 juil, 20:52, Andi  wrote:
> On Jul 2, 10:44 pm, Bill Freeman  wrote:
>
> > What might be of help is adding the IP address to /etc/hosts, if you are
> > on linux.
>
> I have the same problem regarding djangoproject.com (Firefox 3.6.6 on
> Ubuntu).  Everything works but Firefox using my default profile: host
> and nslookup succeed in resolving the domain name.  Adding the IP to /
> etc/hosts or accessing the IP address directly in firefox doesn't
> help.  Opera, chromium, arora, w3m, elinks, lynx and konqueror are not
> affected.  Firefoxes on other hosts within the same LAN can connect to
> djangoproject.com without a problem.  Disabling all add-ons living in
> my Firefox doesn't have an effect -- but starting with a fresh profile
> does: djangoproject.com loads successfully.
>
> It's a very strange problem, because there is no problem with the
> other thousands of websites I've visited during the last days.  It's
> the combination djangoproject.com + my main Firefox profile which
> produces the problem exclusively.
>
> --
> Andi

-- 
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: Tutorial Help

2010-07-08 Thread Venkatraman S
On Thu, Jul 8, 2010 at 12:39 PM, David Ally  wrote:

> Hi,
>
> I need some help on part2 of the Django tutorial, I know python is
> particular about spaces and the fieldsets composition;
>
> Class PollAdmin(admin.ModelAdmin):
> fieldsets = [
> (None,   {'fields': ['question']}),
> ('Date information', {'fields': ['pub_date']}),
> ]
>
> admin.site.register(Poll, PollAdmin)
>
> And the subsequent similar composition gave me syntax error, the traceback 
> said something about "None", Please help me to get past this stage
>
> David
>
>
Please create a new thread if you a specific Q.

To answer your Q above, it would be better(and nicer) if you can share the
traceback exception.

-V
http://theindianstreet.blogspot.com/

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

2010-07-08 Thread Karen Tracey
On Thu, Jul 8, 2010 at 3:09 AM, David Ally  wrote:
>
> And the subsequent similar composition gave me syntax error, the traceback
said something about "None", Please help me to get past this stage

It will help people help you if you post the actual code you are trying to
get to work (not something "similar" that does work), and the full
traceback, not just a paraphrase of the error message.

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

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



Re: context porcessors request.context media_url breaks admin

2010-07-08 Thread justin jools
Wow... django docs can be so confusing...

I could not believe it worked just by using upper case MEDIA_URL

Thanks so much :) :)

I spent a day trying figure this out...

On 8 July, 13:14, Daniel Roseman  wrote:
> On Jul 8, 12:57 pm, justin jools  wrote:
>
>
>
>
>
> > Thank for your quick response Daniel.
> > I'm just confused about using media_url with generic views, I have
> > done it previously with:
>
> > from django.conf import settings        # for media_url
> > media_url = settings.MEDIA_URL
>
> > def dblist(request):
> >     obj_list_menu = dbModel1.objects.all()
> >     return render_to_response('products/dblist.html', {'make_list':
> > obj_list_menu, 'media_url': media_url })
>
> > but with generic views, have no views.py obviously, so I put it in
> > settings.py:
>
> > from django.conf import settings        # for media_url
> > media_url = settings.MEDIA_URL
>
> > and in my base.html template:
>
> > {{ media_url }}css/base.css
>
> > but it's not picking it up?  do i need to pass it with generic views?
>
> But you don't need to set anything! As I said, generic views already
> have access to MEDIA_URL, as long as you don't remove it from the list
> of installed context processors. So I don't know why you want to
> define another variable called "media_url". Just use the existing
> upper-case one.
> --
> DR.- Hide quoted text -
>
> - Show quoted text -

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



Re: context porcessors request.context media_url breaks admin

2010-07-08 Thread justin jools
The 2 methods of using media_url with generic views I have tried:

1. 
http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/
This knocked out my admin, but media_url did work

2. using templatetags
yourApp/templatetags/media_url.py:

from django.template import Library
from yourapp.settings import MEDIA_URL
register = Library()

@register.simple_tag
def media_url():
return MEDIA_URL
And in my template file:

{% load media_url %}


I could not get either of these methods to work, can you give best
guideline for this,

Thanks,
Justin Jools

On 8 July, 12:35, Daniel Roseman  wrote:
> On Jul 8, 11:40 am, justin jools  wrote:
>
> > Thanks for that. I did read something about having to add services
> > back in to the context processors.
> > The reason I am doing this way is because I could not pass the {media
> > url} with generic views.
> > I did a search for trying to do this and hit a couple of posts saying
> > it is not possible to use {media url} with generic views.
>
> > If you have a solution I would be happy to hear this.
>
> I'd be interested to know where you read this, because in fact the
> opposite is true. Generic views all use the RequestContext, which
> means they automatically gain access to all the existing context
> processors - including the default
> "django.core.context_processors.media" processor. So, all generic
> views *already* have access to MEDIA_URL.
> --
> DR.

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



Re: Query raises a DoesNotExist error

2010-07-08 Thread Tom Evans
On Wed, Jul 7, 2010 at 6:22 PM, Nick  wrote:
> I am working on a form to resend an account activation email for newly
> registered users who did not receive their first email.
>
> The form is currently raising a DoesNotExist error and I can't figure
> out why:
>
> Here is the activation code:
>
> class resend_activation(forms.Form):
>    email = forms.EmailField(label="E-Email")
>
>    def clean_email(self):
>        email = self.cleaned_data["email"]
>
>        try:
>            FullProfile.objects.get(email=email)
>        except FullProfile.DoesNotExist:
>
>         test =
> FullProfile.objects.get(email=self.cleaned_data['email'])
>         raise forms.ValidationError("%s" % (test))

It's tricky to see with the line wrapping:

1) You try to get a FullProfile object
2) If it doesn't exist, you try to get it again. This causes the
uncaught DoesNotExist exception.
3) If it does exist, you immediately raise a validation error.

Looks like your logic is incorrect.

>
>    def send(self):
>        email = self.cleaned_data['email']
>        user = FullProfile.objects.get(email=email)
>        thread = Thread(target=send_activation, args=[user])
>        thread.setDaemon(True)
>        thread.start()
>
> Here is the view:
>
> def resend(request):
>    if request.method == 'POST':
>        form = resend_activation(request.POST)
>        if form.is_valid():
>            resend = form.send()
>
>
>            return HttpResponseRedirect("../activate_message")
>    else:
>        form = resend_activation()
>
>    return render_to_response("registration/resend.html", {'form':
> form })
>
> Everytime I try to use the form I get a "FullProfile matching query
> does not exist." error. But in the above code I added a little test to
> see if the query was returning any values and it is. I have no clue
> why this portion of process is holding up everything else.
>

I see no little test.

Cheers

Tom

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



Re: context porcessors request.context media_url breaks admin

2010-07-08 Thread Daniel Roseman
On Jul 8, 12:57 pm, justin jools  wrote:
> Thank for your quick response Daniel.
> I'm just confused about using media_url with generic views, I have
> done it previously with:
>
> from django.conf import settings        # for media_url
> media_url = settings.MEDIA_URL
>
> def dblist(request):
>     obj_list_menu = dbModel1.objects.all()
>     return render_to_response('products/dblist.html', {'make_list':
> obj_list_menu, 'media_url': media_url })
>
> but with generic views, have no views.py obviously, so I put it in
> settings.py:
>
> from django.conf import settings        # for media_url
> media_url = settings.MEDIA_URL
>
> and in my base.html template:
>
> {{ media_url }}css/base.css
>
> but it's not picking it up?  do i need to pass it with generic views?

But you don't need to set anything! As I said, generic views already
have access to MEDIA_URL, as long as you don't remove it from the list
of installed context processors. So I don't know why you want to
define another variable called "media_url". Just use the existing
upper-case one.
--
DR.

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



Django admin modelForms, not getting the add model plus sign

2010-07-08 Thread Dushyant
Hi

I have a form being generated in admin with modelForms. Now what I
want is that whenever there is a foreignkey field, there should be a
add new model field sign next to it, as there is in the form generated
using fieldset in admin.

I was able to get the Date widget, but I am not able to get the add
new model sign/widget.

Here is my pseudo code

class TicketFormClosed(ModelForm):
class Meta:
model = Ticket
fields =
('status','call_sheet_number','diagnose','solution','call_attend_date',)
def __init__(self, *args, **kwargs):
super(TicketFormClosed, self).__init__(*args, **kwargs)
self.fields['call_attend_date'].widget = 
widgets.AdminDateWidget()


class TicketAdmin(admin.ModelAdmin):


def get_form(self, request, obj=None, **kwargs):
form = super(TicketAdmin, self).get_form(request, obj, **kwargs)
if obj == None or obj.status=='Open':
form = TicketForm
else:
form = TicketFormClosed
return form

Thanks

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



Re: Tutorial Help

2010-07-08 Thread David Ally
Hi,

I need some help on part2 of the Django tutorial, I know python is particular 
about spaces and the fieldsets composition;


Class PollAdmin(admin.ModelAdmin):
fieldsets = [
(None,   {'fields': ['question']}),
('Date information', {'fields': ['pub_date']}),
]

admin.site.register(Poll, PollAdmin)

And the subsequent similar composition gave me syntax error, the traceback said 
something about "None", Please help me to get past this stage

David









From: James Bennett 
To: django-users@googlegroups.com
Sent: Tue, July 6, 2010 5:03:50 PM
Subject: Re: Tutorial Help

On Tue, Jul 6, 2010 at 10:56 AM, Bradley Hintze
 wrote:
> Error: No module named pollsdjango.contrib.admin

Look at your INSTALLED_APPS setting. You're missing a comma between
the polls app and the admin app.


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

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


  

-- 
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: context porcessors request.context media_url breaks admin

2010-07-08 Thread justin jools
Thank for your quick response Daniel.
I'm just confused about using media_url with generic views, I have
done it previously with:

from django.conf import settings# for media_url
media_url = settings.MEDIA_URL

def dblist(request):
obj_list_menu = dbModel1.objects.all()
return render_to_response('products/dblist.html', {'make_list':
obj_list_menu, 'media_url': media_url })

but with generic views, have no views.py obviously, so I put it in
settings.py:

from django.conf import settings# for media_url
media_url = settings.MEDIA_URL

and in my base.html template:

{{ media_url }}css/base.css

but it's not picking it up?  do i need to pass it with generic views?

On 8 July, 12:35, Daniel Roseman  wrote:
> On Jul 8, 11:40 am, justin jools  wrote:
>
> > Thanks for that. I did read something about having to add services
> > back in to the context processors.
> > The reason I am doing this way is because I could not pass the {media
> > url} with generic views.
> > I did a search for trying to do this and hit a couple of posts saying
> > it is not possible to use {media url} with generic views.
>
> > If you have a solution I would be happy to hear this.
>
> I'd be interested to know where you read this, because in fact the
> opposite is true. Generic views all use the RequestContext, which
> means they automatically gain access to all the existing context
> processors - including the default
> "django.core.context_processors.media" processor. So, all generic
> views *already* have access to MEDIA_URL.
> --
> DR.

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



Re: get_model()

2010-07-08 Thread Russell Keith-Magee
> On Jul 8, 7:25 am, Kenneth Gonsalves  wrote:
>>
>> any reason why get_model() in django.db.models is not documented? Or is it
>> just that I cannot find it?

No - it isn't documented. The app/model loading APIs are in the same
category as _meta -- API that is fairly important for
meta-programming, but that has never been formally stabilized. The
simple reason for this is that nobody has pressed the issue. However,
they could be considered psuedo-stable -- they're sufficiently
entrenched that we're not going to change them without a very good
reason.

That said -- there is a GSoC project that is currently looking at the
application loading process, and one of the upshots from that may be
some changes to the get_model family of APIs. Hopefully those changes
won't be too widespread, or at the very least, the old interface will
remain (with warnings) for transition purposes.

On Thu, Jul 8, 2010 at 5:29 PM, euan.godd...@googlemail.com
 wrote:
> I've never found any documentation. It's pretty useful if you're
> having import issues.

I'm not entirely sure what sort of import issues you're referring to
here, but get_models() isn't intended as a solution for import issues.
If you're having import issues, that should generally be considered a
bug, either in your own code, or possibly in Django itself.

get_model() et al are intended utilities for metaprogramming -- for
example, if you want to build an interface that can knows about other
models in the project, get_model() and friends are the tools you use.

Yours,
Russ Magee %-)

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



Re: context porcessors request.context media_url breaks admin

2010-07-08 Thread Daniel Roseman
On Jul 8, 11:40 am, justin jools  wrote:
> Thanks for that. I did read something about having to add services
> back in to the context processors.
> The reason I am doing this way is because I could not pass the {media
> url} with generic views.
> I did a search for trying to do this and hit a couple of posts saying
> it is not possible to use {media url} with generic views.
>
> If you have a solution I would be happy to hear this.

I'd be interested to know where you read this, because in fact the
opposite is true. Generic views all use the RequestContext, which
means they automatically gain access to all the existing context
processors - including the default
"django.core.context_processors.media" processor. So, all generic
views *already* have access to MEDIA_URL.
--
DR.

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



Re: context porcessors request.context media_url breaks admin

2010-07-08 Thread justin jools
Thanks for that. I did read something about having to add services
back in to the context processors.
The reason I am doing this way is because I could not pass the {media
url} with generic views.
I did a search for trying to do this and hit a couple of posts saying
it is not possible to use {media url} with generic views.

If you have a solution I would be happy to hear this.

On 29 June, 13:55, Daniel Roseman  wrote:
> On Jun 29, 1:41 pm, justin jools  wrote:
>
> > Hi Tom if you read my original post you will realise that the error is
> > being caused by setting of context processors to media_url (see
> > original post).
> > When context processors are active the {media_url} tag works
> > perfectly, but breaks the admin.
>
> > If I comment out :
> > settings.py
> > #TEMPLATE_CONTEXT_PROCESSORS =
> > ('portfolio.context_processors.media_url',)
> > and
> > urls.py
> > #from django.template import RequestContext
>
> > the admin then works.
>
> You have completely overridden the default template context
> processors. All the functionality that the admin depends on -
> authentication, csrf protection, internationalisation, messages - has
> all now gone thanks to this setting.
>
> You should just *add* your processor to the existing list. However, I
> don't understand why you want to do this at all, given that the
> default list already includes the
> "django.core.context_processors.media" processor which does exactly
> the same as your version.
> --
> DR.

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



Re: Log errors to file

2010-07-08 Thread euan.godd...@googlemail.com
I have created a decorator for Django views which handles AJAX
tracebacks and sends the traceback back to the AJAX application as
JSON, e.g.

{'status':'error', 'message': }

It uses the traceback module to output the full traceback. Obviously
you need to have a handler that receives this data and displays in on
the page (although you can inspect it in firebug).

If you'd like the code for it, I can ask my company whether they'd be
happy with me publishing it.

Cheers, Euan

On Jul 7, 10:35 pm, Jonathan Hayward
 wrote:
> I'm working on a view made to output JSON for Ajax use. My log has:
>
> [07/Jul/2010 17:47:13] "POST /ajax/login HTTP/1.1" 500 50678
>
> That looks like Django gave a helpful and detailed stacktrace page, albeit
> to jQuery expecting JSON.
>
> How can I ask Django to log uncaught exceptions to a file or equivalent? The
> test server has no MTA so I can't really ask it to email me exceptions.
>
> TIA,
> --
> → Jonathan Hayward, christos.jonathan.hayw...@gmail.com
> → An Orthodox Christian author: theology, literature, et cetera.
> → My award-winning collection is available for free reading online:
> ☩ I invite you to visit my main site athttp://JonathansCorner.com/

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



Re: get_model()

2010-07-08 Thread euan.godd...@googlemail.com
I've never found any documentation. It's pretty useful if you're
having import issues.

On Jul 8, 7:25 am, Kenneth Gonsalves  wrote:
> hi,
>
> any reason why get_model() in django.db.models is not documented? Or is it
> just that I cannot find it?
> --
> Regards
> Kenneth Gonsalves
> Senior Associate
> NRC-FOSS at AU-KBC

-- 
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: Question about django admin customization

2010-07-08 Thread ankit rai
you just need to add one function

in your models.py

def somename(self):

  return  "click
here"%(self.id) 
  somename.allow_tags = True
  somename.short_description = "My field"



in you admin.py

 list_display=['somename',]



i think this would help you to display extra fields with what you want.In
this allow_html_tags =true will load the html tags


On Thu, Jul 8, 2010 at 2:05 PM, 玉东  wrote:

> Hi all,
>
> Now I am trying to do a simple admin customization:
>
> I have a model called 'host', and I have a corresponding admin class
> called hostAdmin and got registered.
>
> I put some fields of the 'host' model into the list_display of
> hostAdmin so that we can get it shown in the
>
> admin site. And it is an easy and common way to get fields shown.
>
> The question is that I want to show a little more: an extra column
> with links in each row. Each link is related
>
> to one field of the model. For example, the 'host' model has a field
> called 'id' and one value of it is '1090'
>
> so I hope the link would be http://www.somesite.com/admin/?q=1090.
>
> Should I extend some admin templates to do this? Or what should I do?
>
> Any help is appreciated :)
>



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



Question about django admin customization

2010-07-08 Thread 玉东
Hi all,

Now I am trying to do a simple admin customization:

I have a model called 'host', and I have a corresponding admin class
called hostAdmin and got registered.

I put some fields of the 'host' model into the list_display of
hostAdmin so that we can get it shown in the

admin site. And it is an easy and common way to get fields shown.

The question is that I want to show a little more: an extra column
with links in each row. Each link is related

to one field of the model. For example, the 'host' model has a field
called 'id' and one value of it is '1090'

so I hope the link would be http://www.somesite.com/admin/?q=1090.

Should I extend some admin templates to do this? Or what should I do?

Any help is appreciated :)

-- 
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: Easiest way to pass variables between modelforms (genericforms)

2010-07-08 Thread derek
On Jul 7, 12:44 am, Erich  wrote:
> I am using create_update.create_object to handle my forms (generic
> forms both use modelforms). I have two forms. The second relies on the
> pk of the first as a fk. I can't figure out what is the best practice
> to A: save the pk as a variable or into the session, then B: pull that
> variable either out of the session or another place, such as a global
> variable.
>
> I could write the forms manually, but this does not seem to be the
> most efficient way, unless create_object was meant for very simple
> forms. I have tried using extra_context to call another function, but
> I dont know if that is the best way either.

Maybe have a look at:
http://www.petersanchez.com/2008/09/26/django-formwizard-passing-data-between-forms/

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



Re: filtering admin data

2010-07-08 Thread derek
On Jul 4, 3:06 pm, djnubbio  wrote:
> hi all; sorry for wasting your preciouse tume.
>
> I'm trouble with the following:
>
> class A(models.Model):
> .
> .
> .
>
> class B(models.Model):
> .
> .
> .
> a= models.ForeignKey(A)
>
> class C(models.Model):
> .
> .
> .
> b= models.ForeignKey(B)
>
> How can i filter data that belongs to an A instance, while editing
> class C instances, using django Admin?

You have not given enough details to work out what you are actually
trying to do.

A filter can filter from a parent in the hierarchy, using a notation
such as:

C.objects.filter(b__a__name__icontains="spam")

-- 
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: Is Django admin's "delete confirmation" considered RESTful?

2010-07-08 Thread Massimiliano della Rovere
I did not read the sources of the admin module devoted to deleting an
item, but I think the problem is not in the admin interface but in
html forms.

Html forms allow only GET and POST, but no DELETE and PUT. Given the
REST common-sense rule "whenever you POST, ask the user" the admin
interface - a web, html interface - behaves properly: a destructive
post checks the user's will.

On the other side, when we will have XForms 1.1 and Xhtml 2.0 we'll be
able to issue PUT and DELETE without the need for AJAX support:
var request = new XMLHttpRequest();
request.open("DELETE", "http://yoururl/page.html;, True);

If you want to REST-ise your app, you could have a look at piston:
http://bitbucket.org/jespern/django-piston/wiki/Home




On Wed, Jul 7, 2010 at 17:10, Margie Roginski  wrote:
> Actually, the confirmation page is not accessed via a GET.  Using the
> admin's auth model as an example: the user does a GET to something
> like www.example.com://admin/auth/user to get a list of users.  Then
> they checkmark the users they want to delete, select the "delete"
> action, and then click on "go", which does a POST to ://admin/auth/
> user.  The server code for the post does a render_to_response and
> simply renders a delete confirmation page, resulting in the user
> seeing the delete confirmation.  The url that the user sees with this
> delete confirmation is the same, //admin/auth/user.  From the delete
> confirmation page, the users clicks "Yes I'm Sure" and this does
> another post to ://admin/auth/user.  On the server side the code
> detects the "Yes I'm Sure" input and does its thing (deletes the
> selected uesrs), and then redirects back to ://admin/auth/user.  This
> redirect is a GET, so it now displays the list of users, again at ://
> admin/auth/user.
>
> It seems that that url www.example.com://admin/auth/user is getting
> used for one GET and two POSTS.  My question is pretty much: Is this a
> good way to do this?  Is it ok to have different pages (ie the user
> list and the user delete confirmation) all show up with the same url?
> If there is some better way, what is it?  Hypothesizing on other ways:
> when the server side does the render_to_response to display the delete
> confirmation, should it be replacing the url that the user sees?  IE,
> instead of showing ://admin/auth/user, show ://admin/auth/
> user_delete_confirmation?  And if so, how does one do this?  I don't
> think you can replace the url with render_to_response, right?  I could
> do a redirect, but if I did that, I would have to save the ids of the
> users being deleted (in the session I guess).
>
> Margie
>
>
>
> On Jul 7, 3:00 am, "euan.godd...@googlemail.com"
>  wrote:
>> I'm not entirely sure whether you're asking one question or two here.
>>
>> Firstly, I think that in the RESTful sense, there's nothing wrong with
>> having a confirmation page that uses the same URL to perform an action
>> *providing* the HTTP verb is different. In this case the confirmation
>> page is accessed via a GET (I assume) and the actual delete is
>> performed via a POST.
>>
>> I guess that strictly speaking to be truly RESTful, the view should be
>> using the DELETE verb. However, since some browsers don't support
>> DELETE and PUT, most web apps use just GET and POST.
>>
>> I'm not sure whether that answers your question, but hopefully clears
>> it up a bit.
>>
>> Euan
>>
>> On Jul 7, 2:49 am, Margie Roginski  wrote:
>>
>> > I have an app that is modeled after the django admin app.  In general
>> > it seems to me that the admin app is RESTful.  However, I am
>> > encountering a situation that is similar to the admin apps delete
>> > confirmation process, and I'm curious if anyone out there could
>> > comment on whether this particular part is considered "RESTful", or if
>> > not "RESful", I guess I'd just like opinions on if it's a good way to
>> > do things.  Let me describe my question more.
>>
>> > In the django admin, you can click on a bunch of objects and then
>> > select the "delete" action, and then click "go".  This takes you to a
>> > delete confirmation page that asks if you are sure.  You can click
>> > "I'm sure" to proceed with your delete. This delete confirmation page
>> > has the same url as the objects changelist page.  And that's the core
>> > of my question - is that a good thing?
>>
>> > I have a situation that is quite similar, but a bit more complex.  To
>> > give a hopefully simple analogy, suppose that the admin's delete
>> > confirmation page had an input field associated with each object,
>> > which required the user to put in a "reason" prior to clicking "I'm
>> > sure".  And if the user doesn't put in a reason, imagine they should
>> > be presented with the same delete confirmation page, but with an error
>> > on the fields where no reason was supplied.   Should this page also be
>> > at the same changlist url?
>>
>> > I *think* the answer to this 

many to many and different requests - Strange behavior?

2010-07-08 Thread zweb
I am seeing unexpected strange behaviour.

I have two tables:  student and study_class which have many to many
relationship.

1. when user A (student a) logs in, in run time he does,

student_a.study_classs = [class_physics]   #in DB, this student does
not have class_physics

#does not Save.


2. User B logs into separate browser.

 Student.objects.get(Study_class__exact = class_physics)

It returns "student_a" as one of the students even though student_a
above never saved.

3. User A logs out without saving. User B again does
Student.objects.get(study_class__exact = class_physics). This time
student_a is not returned.

Why this happening? (I use wsgi with django 1.1.1 and python 2.5 on
apache.)

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



get_model()

2010-07-08 Thread Kenneth Gonsalves
hi,

any reason why get_model() in django.db.models is not documented? Or is it 
just that I cannot find it?
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

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