QUERYDICT immutable

2011-01-28 Thread sami nathan
HI
  I am NEWBIE  i am trying to run  an  server and my POST request is from
java api(client) and i cant able to see exact error in java api its just
showing HTML request is not accepting in java b coz django giving me error
iin html format but by some how i manage to print request.POST from my
request
-
--
http://schemas.xmlsoap.org/soap/envelope/
">http://flypp.infy.com/sms/v2010r1_0
">12345343661t1p1p2<
messa
ge>DICT test
']}>
--
--
now i want to change just message in my request.POST (denoted by red color
in above request) and i am helpless  i tried the following code

def recive_ShortMessage(request):
if request.method == 'POST':
 request=request.POST.QueryDict.copy()
 qt=request.QueryDict.copy()
 print qt
 qt['message'] = 'I am changing it!'
 return HttpResponse(qt)
_
_

As java api is not showing  what error i am having i can know error in this
program

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



Re: caching of Models (not the cache middleware)

2011-01-28 Thread Brian Craft
Thank you!

'set transaction isolation level read committed' had no effect, but
'set autocommit=1' appears to fix it.

I wondered if there was some more general way of doing this (I mean,
besides passing in raw sql). Perhaps the set_autocommit() method in
db.backends.creation?



On Fri, Jan 28, 2011 at 6:51 PM, Karen Tracey  wrote:
> On Fri, Jan 28, 2011 at 9:45 PM, Brian Craft 
> wrote:
>>
>> Digging into the problem I'm having with a standalone django script,
>> the problem seems to be that django doesn't see updates to the
>> database unless it writes to the database.
>
> Sounds a lot like:
> http://groups.google.com/group/django-users/browse_thread/thread/e25cec400598c06d/
>
> 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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: ANN: Server upgrade on djangoproject.com

2011-01-28 Thread Karen Tracey
On Fri, Jan 28, 2011 at 4:45 PM, Jacob Kaplan-Moss wrote:

> On Fri, Jan 28, 2011 at 3:33 PM, Jacob Kaplan-Moss 
> wrote:
> > I'm starting the switchover to the new djangoproject.com server right
> > now. Might be around 5 mins of downtime or so.
>
> Migration should be complete now. I'm still cleaning up a few
> last-minute things, but if you notice anything wrong please pop into
> #django-dev on freenode and let me know.


django-updates list seems to be dead since the migration?

Karen

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



Re: caching of Models (not the cache middleware)

2011-01-28 Thread Karen Tracey
On Fri, Jan 28, 2011 at 9:45 PM, Brian Craft wrote:

> Digging into the problem I'm having with a standalone django script,
> the problem seems to be that django doesn't see updates to the
> database unless it writes to the database.
>

Sounds a lot like:
http://groups.google.com/group/django-users/browse_thread/thread/e25cec400598c06d/

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



caching of Models (not the cache middleware)

2011-01-28 Thread Brian Craft
Digging into the problem I'm having with a standalone django script,
the problem seems to be that django doesn't see updates to the
database unless it writes to the database.

In the following lines,
   ss = engine.SessionStore(session_id)
   session=ss.load()

If session_id "abcd" has been added to the session table after the
script started, the load will not find it. Instead, it will create a
new session, say "wxyz" and write it to the table. After writing it to
the table, a subsequent load on "abcd" will succeed: it's now in sync
with the database, at least until another process writes to it.

Anyone know where this caching is happening? I have no caching
middleware enabled. Does django cache results of Model queries? Or
would the db layer be caching it? And how can I get django to sync
before looking up a session?

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



Are there any Django events we're missing on Lanyrd?

2011-01-28 Thread Simon Willison
Hi everyone,

My main project at the moment is Lanyrd, the social conference
directory. It's a site that helps you find conferences to attend or
speak at, and that enables you to build a profile of talks you've
given and events you've attended in the past.

There's just one problem: right now we only know of 5 upcoming Django
events, worldwide:

http://lanyrd.com/topics/django/

Compare to other technical topics, that's not very impressive:

http://lanyrd.com/topics/php/
http://lanyrd.com/topics/drupal/
http://lanyrd.com/topics/ruby/

Are there any events that we're missing? You can add them yourselves
(don't forget to attach the Django topic) or alternatively tip me off
via email and I'll add them myself.

We're also very interested in past events. We have 37 for Django at
the moment - again, if there are any missing I'd love to have them on
the site:

http://lanyrd.com/topics/django/past/

Finally, as a public service announcement we do have Atom feeds of
most of our pages, so if you want to hear about Django events as they
are announced you can subscribe directly to the above page.

We also collect videos / slides / etc - we have 47 session videos in
our Django collection which are worth browsing through, and we're keen
on gathering more:

http://lanyrd.com/topics/django/video/

We even have video from the first event after Django was released to
the public, way back in 2005! http://lanyrd.com/2005/snakes-and-rubies/

Cheers,

Simon

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



Re: DB-Views or read-only tables in models

2011-01-28 Thread bvdb
Thanks for describing the four possible reactions.
My main concern is organisation, alas I imagine a Django solution, not
just one for me.
So the model needs to know about the view, i.e. we'd need a read-only
attribute in models.py table definitions, so that
a) Developer sets the attribute manually in models.py
 or
b) manage.py inspect recognizes the views and sets the attribute

Then I can use the attribute in my code, and I'd expect admin to leave
away the Update/create option in this case.

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



Re: Adding an App to the Admin

2011-01-28 Thread Corey Richardson
On 01/28/2011 08:43 AM, Jonas Geiregat wrote:
>>>
>>> Are you logged in as a user with permission to change models in that app? 
>>> It 
>>> won't appear if not.
> 
> I once changed my admin.py file and after reloading nothing had changed.
> What did solve this issue was restarting the server or hard refreshing the 
> page (Shift + F5  or something like that, depending on the browser you're 
> using)
> But I'm guessing you've already done that.
> 

Did that too. I tried all the obvious (to me) things. Still stumped not
finding anything on google.

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



Re: Custom ModelAdmin form for distinct logged users

2011-01-28 Thread Daniel Roseman
On Friday, January 28, 2011 12:22:04 AM UTC, Mario8k wrote:
>
> Hello, 
>
> How can I customize a form by the user who is logged in? 
> For example, if the user is_superuser(), i need to display the 
> standard admin form, but if the user is another one, show only some 
> fields and not all model fields. For this, I coud use 
> ModelAdmin.fields (or exclude, or readonly_fields), but i don't know 
> how to make it conditional to the user. 
>
> Regards, Mario. 
>

Since this is in the admin, there's a hook especially for this 
-  ModelAdmin.get_form(). This is a method that you can override in your own 
ModelAdmin subclass - it's passed the request so you can check the value of 
request.user and return the appropriate form. See the code in 
django.contrib.admin.options.
--
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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



standalone session checking

2011-01-28 Thread Brian Craft
I'm trying to implement a stand-alone python script to check a session
cookie for group authorization. I cribbed from the auth and session
middleware, so I could take the sessionid from the cookie, look up the
session, look up the user, and get the list of groups.

This all basically works, except for the very first time a session is
seen. The first lookup always fails. I know the session is good (a
call to a django view via @login_required, for example, works fine).

I'm expecting this is some problem with a cache, or evaluation order,
such that my script doesn't have the latest info from the db until
I've queried it once. Anyone have a clue? Here's what the auth
checking routine looks like:


def authorized(session_id, group):
ss = engine.SessionStore(session_id)
session=ss.load()
try:
user_id = session[SESSION_KEY]
backend_path = session[BACKEND_SESSION_KEY]
backend = load_backend(backend_path)
user = backend.get_user(user_id) or AnonymousUser()
except KeyError:
user = AnonymousUser()
return user.groups.filter(name=group).count()


It's called from a "while 1" loop in a script that never exits. The
first time a session cookie goes through this routine, it always
fails. Second, and subsequent times 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Custom ModelAdmin form for distinct logged users

2011-01-28 Thread Moya, Mario
2011/1/28 hollando 

Hi hollando,

You can use proxy models. Refer to
>
> http://stackoverflow.com/questions/2223375/multiplue-modeladmins-views-for-same-model-in-django-admin
>

I can't set permissions for proxy models, i think because the table
auth_permissions doesn't have the proxy records.
That is, i have the Foo model and the FooProxy. Whe i loggin as superuser i
see both, Foo and FooProxy admin forms. But when i log as other user (supose
proxyuser), who only have the permission "Can change foo", only see Foo
admin forms.

How can i reach the way to login as proxyuser, and enter only to the
FooProxy admin forms?


>
> On 1月27日, 下午4时22分, Mario8k  wrote:
> > Hello,
> >
> > How can I customize a form by the user who is logged in?
> > For example, if the user is_superuser(), i need to display the
> > standard admin form, but if the user is another one, show only some
> > fields and not all model fields. For this, I coud use
> > ModelAdmin.fields (or exclude, or readonly_fields), but i don't know
> > how to make it conditional to the user.
> >
> > Regards, Mario.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Lic. Mario Moya
Tel: +54 299 4771196
Cel: +54 299 155023987
mm...@8ksoft.com.ar
Belgrano 167 - (8324) Cipolletti, Río Negro
http://www.8ksoft.com.ar


*Cuidar el medio ambiente depende de todos, imprime sólo lo necesario.*

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



Re: ANN: Server upgrade on djangoproject.com

2011-01-28 Thread Łukasz Rekucki
On 28 January 2011 21:33, Jacob Kaplan-Moss  wrote:
> Hi folks --
>
> I'm starting the switchover to the new djangoproject.com server right
> now. Might be around 5 mins of downtime or so.
>
> Jacob
>

Hurray for upgrading the Trac instance! Are there any additional Trac
features planned ? (like the Vote Plugin).

-- 
Łukasz Rekucki

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



Re: ANN: Server upgrade on djangoproject.com

2011-01-28 Thread Jacob Kaplan-Moss
On Fri, Jan 28, 2011 at 3:33 PM, Jacob Kaplan-Moss  wrote:
> I'm starting the switchover to the new djangoproject.com server right
> now. Might be around 5 mins of downtime or so.

Migration should be complete now. I'm still cleaning up a few
last-minute things, but if you notice anything wrong please pop into
#django-dev on freenode and let me know.

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



Re: Is it possible to log a user into a subdomain, from another domain??

2011-01-28 Thread PeteDK
Thanks :)

i used the idead behind remoteuserbackend and coded something
similar :) thanks again!

regards

Pete

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



ANN: Server upgrade on djangoproject.com

2011-01-28 Thread Jacob Kaplan-Moss
Hi folks --

I'm starting the switchover to the new djangoproject.com server right
now. Might be around 5 mins of downtime or so.

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



Word file Display and Save??

2011-01-28 Thread nicolas lubkov
Hello all, is there a way to display a word .doc in the user profile and let
the users edit it and save it to keep in their profile.??

-- 
Saludos.

Nicolas Lubkov
Ing. Informatica de gestion

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



Re: request.POST parsing without form

2011-01-28 Thread taso
On Jan 28, 11:15 am, Matias Aguirre  wrote:
> Excerpts from taso's message of Fri Jan 28 17:05:21 -0200 2011:

> > A user action triggers a POST that looks like:
>
> > action "update"
> > data    { "field1": 8,"id": 2 }
> > (copied from firebug)
>
> So, it's a POST with an "action" fiend and a "data" field that looks like
> a JSON value, right?

Absolutley right. I have the option of encoding the data on the
frontend to be passed as a JSON value. Currently that is off; that is,
the flag to encode as JSON is false so the data is supposed to be
passed as a "regular" POST parameter set, even if it looks like JSON.

> Did you tried un-encoding the JSON, like this:
>
>     from django.utils.simplejson import simplejson
>
>     data = simplejson.loads(request.POST['data'])
>     id = data['id']

>
> Regards,
> Matías
> --
> Matías Aguirre 

Absolutely works. My earlier attempt at parsing JSON was bad (new to
django + JSON). Thanks much Matías!

Best,
Taso

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



Re: Invalidate cached copy when changes are made.

2011-01-28 Thread Pranav
Thanks for the reply Matias. I'll give signals a try but pagination is
definitely a no go. I want to see all the members at a stretch.
Isn't there a simple way to tell the django cache to get a new copy,
if changes are made?

I'm sure the admin or something must have something like what i
want

On Jan 28, 9:25 am, Matias Aguirre  wrote:
> You could use signals[1] to update cache on save event, but I think you
> are approaching the issue in the wrong way, why not paginate[2] the
> result?
>
> Regards,
> Matías
>
> [1]:http://docs.djangoproject.com/en/dev/topics/signals/
> [2]:http://docs.djangoproject.com/en/dev/topics/pagination/
>
> Excerpts from Pranav's message of Fri Jan 28 01:36:02 -0200 2011:
>
> > Hi all,
>
> > I have a model that ruffly looks like so,
>
> > Class Member(model);
> >           member_id = model.Integerfield(primary_key=True)
> >           organization = model.foreignerkey(primary_key=True)
> >           transorg = model.foreignerkey()
> >           bo_name = model.foreignerkey()
> >          member_create_date = model.datetimefield()
> >          member_modified_date = model.datetimefield()
> >          ...
> >          class meta:
> >             db_table = 'Member'
> >             unique_together = ('member_id','organization')
>
> >        I have a view (display members) which allows user to search
> > based on multiple foreigner keys, the result ruffly returns about 811
> > Members and takes a long time to execute. So i started using cache
> > which resulted in faster serving of the page but when changes are made
> > to one of the Member the change is not shown on the display member
> > page, instead it still shows the cached page, i used decorator @cache-
> > control(must_revalidate=True) but i figured it has a max age. I
> > thought I'll use @condition(Etag_func,last_modified_func,) but i'm not
> > clear how to use it, since I'm filtering based on multiple fields,
> > also my result returns 811 members, so I'll have to check
> > member_modified_date of 811 members??? Is there a way i can use the
> > cache so that it gets a new copy when i make changes.
>
> --
> Matías Aguirre 

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



Re: request.POST parsing without form

2011-01-28 Thread Matias Aguirre
Excerpts from taso's message of Fri Jan 28 17:05:21 -0200 2011:
> Hi,

Hi,

> I am using django strictly as a backend for data processing. As such I
> am not using any forms or templates, just database tables as models.
> The page is js driven and POSTing data is causing me some issues.
> 
> A user action triggers a POST that looks like:
> 
> action "update"
> data{ "field1": 8,"id": 2 }
> (copied from firebug)

So, it's a POST with an "action" fiend and a "data" field that looks like
a JSON value, right?

> When I try to parse the POST data I get errors on every type of method
> I have tried. What I eventually would like to do is something like:
> 
> if request.POST.__getitem__('xaction') == 'update':
> mydata = request.POST.__getitem__('data')
> model_to_update = modelname.get(id=mydata['id']
> for k,v in mydata:
> setattr(model_to_update, k, v)
> model_to_update.save()
> 
> However every time I try to parse the "data" POST values I get errors.
> I wonder if I am missing some assumptions by not importing/using
> forms, or if there is a standard method to iterate through the POST
> data that I am missing. I have literally tried every \*get\* dict
> method from the docs and all throw errors (.list() throws numeric
> indicies errors, iteritems() throws not iterable, etc.)
> 
> Any thoughts?

Did you tried un-encoding the JSON, like this:

from django.utils.simplejson import simplejson

data = simplejson.loads(request.POST['data'])
id = data['id']
...

> Thanks
> Taso

Regards,
Matías
-- 
Matías Aguirre 

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



Re: request.POST parsing without form

2011-01-28 Thread Daniel Roseman
On Friday, January 28, 2011 7:05:21 PM UTC, taso wrote:
>
> Hi, 
>
> I am using django strictly as a backend for data processing. As such I 
> am not using any forms or templates, just database tables as models. 
> The page is js driven and POSTing data is causing me some issues. 
>
> A user action triggers a POST that looks like: 
>
> action "update" 
> data { "field1": 8,"id": 2 } 
> (copied from firebug) 
>
> When I try to parse the POST data I get errors on every type of method 
> I have tried. What I eventually would like to do is something like: 
>
> if request.POST.__getitem__('xaction') == 'update': 
> mydata = request.POST.__getitem__('data') 
> model_to_update = modelname.get(id=mydata['id'] 
> for k,v in mydata: 
> setattr(model_to_update, k, v) 
> model_to_update.save() 
>
> However every time I try to parse the "data" POST values I get errors. 
> I wonder if I am missing some assumptions by not importing/using 
> forms, or if there is a standard method to iterate through the POST 
> data that I am missing. I have literally tried every \*get\* dict 
> method from the docs and all throw errors (.list() throws numeric 
> indicies errors, iteritems() throws not iterable, etc.) 
>
> Any thoughts? 
>
> Thanks 
> Taso 
>

Why on earth do you want to use __getitem__? That's an internal 
implementation detail, which you should never need to access in your code 
unless you're overriding something. POST is a dictionary-like object, which 
defines __getitem__ so that you can access it with the usual Python 
dictionary access: request.POST['data'], and so on.

Secondly, if I'm understanding what you have posted, `data` is not an 
element of the POST dictionary - it *is* the POST dictionary. So rather than 
trying to access `request.POST['data']['id']`, you should be accessing 
`request.POST['id']`.
--
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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



request.POST parsing without form

2011-01-28 Thread taso
Hi,

I am using django strictly as a backend for data processing. As such I
am not using any forms or templates, just database tables as models.
The page is js driven and POSTing data is causing me some issues.

A user action triggers a POST that looks like:

action "update"
data{ "field1": 8,"id": 2 }
(copied from firebug)

When I try to parse the POST data I get errors on every type of method
I have tried. What I eventually would like to do is something like:

if request.POST.__getitem__('xaction') == 'update':
mydata = request.POST.__getitem__('data')
model_to_update = modelname.get(id=mydata['id']
for k,v in mydata:
setattr(model_to_update, k, v)
model_to_update.save()

However every time I try to parse the "data" POST values I get errors.
I wonder if I am missing some assumptions by not importing/using
forms, or if there is a standard method to iterate through the POST
data that I am missing. I have literally tried every \*get\* dict
method from the docs and all throw errors (.list() throws numeric
indicies errors, iteritems() throws not iterable, etc.)

Any thoughts?

Thanks
Taso

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



Re: use variable that is bound at an object's creation time at the object's creation time

2011-01-28 Thread bruno desthuilliers


On 28 jan, 16:46, Santiago Caracol  wrote:
(snip)

> Caught TypeError while rendering: 'NoneType' object is not iterable
>
> I think the problem in these cases is that when Python tries to
> execute self.variants() it does not yet have a value for
> self.spelling_variants.

Dont "think". You do have the full traceback - which you didn't post
(you didn't post the full code neither FWIW) - so read it and you'll
know.

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



Re: weird behavior in select_related

2011-01-28 Thread Daniel Roseman
On Saturday, January 22, 2011 1:38:22 PM UTC, maraujop wrote:
>
> Hi everyone,
>
> I have been working on reducing DB queries in my project with great 
> results. But I have realized that select_related in one of my models doesn't 
> preload all the ForeignKeys and OneToOneFields, it preloads 3 out of 5. 
> Actually the 3 preloaded are ForeignKeys and the other 2 are OneToOneFields. 
> Before trying to reproduce this problem in a simplified schema, I need 
> someone to confirm this is unusual.
>
> If I do a select_related('names', 'of', 'the', 'five', 'fks') everything is 
> loaded. Last thing I can say is that those OneToOneFields point models that 
> reference back to model pointing at them, for performance reasons. I reckon 
> this can be a bug.
>
> Thanks, best regards
>
> 
> Miguel Araujo
> @maraujop
>

It would have helped if you'd posted your model. If your relationships are 
defined as null=True, then select_related() doesn't follow them unless you 
specify them explicitly.
--
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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: weird behavior in select_related

2011-01-28 Thread Miguel Araujo
Hi,

Please anyone confirm if this is normal, so I can report it or not.

Thanks,  regards


Miguel Araujo
@maraujop

2011/1/22 Miguel Araujo 

> Hi everyone,
>
> I have been working on reducing DB queries in my project with great
> results. But I have realized that select_related in one of my models doesn't
> preload all the ForeignKeys and OneToOneFields, it preloads 3 out of 5.
> Actually the 3 preloaded are ForeignKeys and the other 2 are OneToOneFields.
> Before trying to reproduce this problem in a simplified schema, I need
> someone to confirm this is unusual.
>
> If I do a select_related('names', 'of', 'the', 'five', 'fks') everything is
> loaded. Last thing I can say is that those OneToOneFields point models that
> reference back to model pointing at them, for performance reasons. I reckon
> this can be a bug.
>
> Thanks, best regards
>
> 
> Miguel Araujo
> @maraujop
>

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



Re: Possible bug in model validation

2011-01-28 Thread Miguel Araujo
Well,

I'm just trying to figure out if this should be reported.

Thanks, regards


Miguel Araujo
@maraujop

2011/1/22 Miguel Araujo 

> Hi everyone,
>
> I have a model A that has a overwritten save method that updates a model
> B's field. Both (A & B) have model validation using full_clean method.
> Problem is that B model's validation fails when updating the field, because
> it raises an IntegrityError saying the primary key already exits,
> obviously.
>
> To fix this within my save method I have done:
>
> if kwargs.get('force_update') is False:
> self.full_clean()
>
> If this is the desired behavior, then just let me know, I don't think the
> primary key on an update should be validated this way.
>
> Thanks, best regards
>
> 
> Miguel Araujo
> @maraujop
>

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



Settings to Load CSS Files

2011-01-28 Thread octopusgrabbus
I am running Django 1.2.4 mod_wsgi. My admin site loads with its look
and feel. I am trying to add css to my application, which works fine.
I have looked through the docs, and cannot get a sample css file to
load. I would appreciate some pointers to get this working.

Here are the appropriate lines from the base template.




{% block title %}Town of Arlington Water Department AMR
System{% endblock %} 

   

Here are the appropriate lines from httpd.conf
DocumentRoot /usr/local/www/documents
AliasMatch ^/([^/]*\.css) /usr/local/www/documents/static/$1


Order deny,allow
Allow from all


Here are the appropriate lines from settings.py
# Main URL for the project
BASE_URL = 'http://localhost:8002'

# Absolute path to the directory that holds media
MEDIA_ROOT = '/usr/local/www/documents'

# URL that handles the media served from MEDIA_ROOT
MEDIA_URL = '/static/'

# URL prefix for admin media -- CSS, JavaScript and images.
ADMIN_MEDIA_PREFIX = BASE_URL + '/media/'

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



Re: account errors when create superuser on cygwin

2011-01-28 Thread Bill Freeman
Did you create a superuser when you originally ran syncdb?  If so, you
can work around the problem in the admin, logged in as that original
superuser, making additional superuser through the web.

Have you tried logging in as the "jack" user?  The fact that the name is
now already taken implies that something was written to the database.
You can also test for this in the shell, importing User from
django.contrib.auth.models and doing a get or filter with username="jack",
and then examine the object, say, by pretty printing it's __dict__.

The error is interesting, however.  I wonder if it's repeatable.  You can
rename (or remove) your database file, redo syncdb, then try the
createsuperuser.
If that fails in the same way, then we could start inserting pdb.set_trace(),
say, before line 200 of
/usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py
and poke around inside the Database object there to see what file it's going
to try to open, etc.

On Thu, Jan 27, 2011 at 7:26 PM, maki maki  wrote:
> Thanks for your replies.
> I had runned `manage.py syncdb` and the db file exists.
> I can open the db file in django's manage shell:
 f = open('./data/db.db')
 f
> 
> the permission of the db file is :-rwxrwxrwx
> the version of python on cygwin is
> Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
> [GCC 4.3.4 20090804 (release) 1] on cygwin
> also, I can use the APIs of models in manage shell, and sqlite3 can be
> imported.
 from polls.models import Poll
 Poll.objects.filter(id=1)
> []
 import sqlite3
 exit()
> but the error occurred when i run "python manage.py createsuperuser
> --username=jack --email=j...@f.com".
> although the error occurred, if i run the command again, it prompt: 'Error:
> That username is already taken.'
>
> On Fri, Jan 28, 2011 at 3:24 AM, Daniel Roseman 
> wrote:
>>
>> On Thursday, January 27, 2011 6:42:29 PM UTC, maki maki wrote:
>>>
>>> hi,
>>>
>>>   I execute the command: python manage.py createsuperuser --
>>> username=jack --email=ja...@f.com
>>>
>>> and an error occurred:
>>>
>>> Traceback (most recent call last):
>>>   File "manage.py", line 11, in 
>>> 
>>>   File "/usr/lib/python2.6/site-packages/django/db/backends/sqlite3/
>>> base.py", line 200, in execute
>>>     return Database.Cursor.execute(self, query, params)
>>> django.db.utils.DatabaseError: unable to open database file
>>>
>>>
>>> the database in settings.py is like this:
>>>
>>> DATABASES = {
>>>     'default': {
>>>         'ENGINE': 'django.db.backends.sqlite3', # Add
>>> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>>>         'NAME': '/home/jack/django/mysite/data/
>>> db.db',                      # Or path to database file if using
>>> sqlite3.
>>>         'USER': '',                      # Not used with sqlite3.
>>>         'PASSWORD': '',                  # Not used with sqlite3.
>>>         'HOST': '',                      # Set to empty string for
>>> localhost. Not used with sqlite3.
>>>         'PORT': '',                      # Set to empty string for
>>> default. Not used with sqlite3.
>>>     }
>>> }
>>>
>>> can someone tell me why the error occurred? Thanks.
>>
>> Have you run `manage.py syncdb` first? You need that to create the db and
>> the tables.
>> --
>> 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-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Django cache created in one function not available to another?

2011-01-28 Thread Lance Vick
So I have a function that sets cache (and successfully outputs it):

def push_cache:
cache.set('foo_cache', 'FUBAR!!!')
foodata = cache.get('foo_cache')
print(foodata) # this works

However when I try to access that cache from within a view and
directly output it it returns None:

def fetch_cache(request):
cache_data = cache.get('foo_cache')
return HttpResponse(cache_data) #this does not work.


Am i misunderstanding something fundamental in how cache works?

I am using the memcached backend in django 1.2.3

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



use variable that is bound at an object's creation time at the object's creation time

2011-01-28 Thread Santiago Caracol
Hello,

my model Product has an attribute spelling_variants and a property
variants:

class Product(models.Model):
   canonical_name = models.CharField(max_length=200)
   spelling_variants = models.ManyToManyField(String,
related_name="product spellings", blank=True)
   ...

   @property
   def variants(self):
  variants = []
  for v in self.spelling_variants:
 variants += paraphrase(v)
  return variants

The code works, if product instances are first saved without a vaue
for spelling_variants and later modified so as to have some spelling
variants. When I add spelling variants at the time when I create a
product in the admin interface, I get this error:

Caught TypeError while rendering: 'NoneType' object is not iterable

I think the problem in these cases is that when Python tries to
execute self.variants() it does not yet have a value for
self.spelling_variants.

How can I make sure that self.spelling_variants has a value when
self.variants() is executed?

Santiago

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



Re: admin won't load revisited

2011-01-28 Thread octopusgrabbus
I got the look and feel back by substituting this:

# URL prefix for admin media -- CSS, JavaScript and images.
ADMIN_MEDIA_PREFIX = BASE_URL + '/media/'

and yet the other value did work

ADMIN_MEDIA_PREFIX = BASE_URL + 'media/admin/'

Oh, well. Thanks for the answers.


On Jan 28, 10:04 am, octopusgrabbus  wrote:
> In addition, I can't get the built-in server to serve the admin's look
> and feel. I see that as a good thing, because clearly it's a wrong
> setting that affects both servers. Here are the settings again.
>
> # Main URL for the project
> BASE_URL = 'http://localhost:8002'
>
> # Absolute path to the directory that holds media
> MEDIA_ROOT = '/usr/local/www/documents/media'
>
> # URL that handles the media served from MEDIA_ROOT
> MEDIA_URL = '/media/'
>
> # URL prefix for admin media -- CSS, JavaScript and images.
> ADMIN_MEDIA_PREFIX = BASE_URL + 'media/admin/'
>
> Thanks.
> cmn
>
> On Jan 28, 8:49 am, octopusgrabbus  wrote:
>
> > After making this change, I got the admin interface's look and feel,
> > and then put back the original and did not get the look and feel, When
> > I put this change back ADMIN_MEDIA_PREFIX = BASE_URL + 'media/admin/',
> > I no longer get the look and feel. I've cleared the cache and
> > rebooted. It looks like there's a caching condition somewhere, but I'm
> > not aware of what it is. Any ideas? Thanks.
>
> > On Jan 27, 7:24 pm, OverKrik  wrote:
>
> > > Try this:
>
> > > ADMIN_MEDIA_PREFIX = BASE_URL + 'media/admin/'
>
> > > On Jan 28, 1:48 am,octopusgrabbus wrote:
>
> > > > I am referring to Django's admin site. By not loading correctly, I
> > > > mean the admin site works, but does not display the nice look and feel
> > > > that displays when using Django's built in web server.
>
> > > > "Do the static files (css, js) not load? Then maybe your paths in
> > > > settings.py are not configured properly. "
>
> > > > Yes, they do not load.
>
> > > > To the best of my knowledge, I have no ModelAdmin instances.
>
> > > > Here are the appropriate lines from project's settings.py
>
> > > > # Main URL for the project
> > > > BASE_URL = 'http://localhost:8002'
>
> > > > # Absolute path to the directory that holds media
> > > > #MEDIA_ROOT = '%s/media/' % BASE_PATH
> > > > MEDIA_ROOT = '/usr/local/www/documentation/media'
>
> > > > # URL that handles the media served from MEDIA_ROOT
> > > > MEDIA_URL = '/media/'
>
> > > > # URL prefix for admin media -- CSS, JavaScript and images.
> > > > #ADMIN_MEDIA_PREFIX = "%sadmin/" % MEDIA_URL
> > > > ADMIN_MEDIA_PREFIX = "admin/"
>
> > > > INSTALLED_APPS = (
> > > >     'django.contrib.auth',
> > > >     'django.contrib.contenttypes',
> > > >     'django.contrib.sessions',
> > > >     'django.contrib.sites',
> > > >     'django.contrib.messages',
> > > >     'amr.login',
> > > >     'amr.inventory_check',
> > > >     # Uncomment the next line to enable the admin:
> > > >     'django.contrib.admin',
> > > >     # Uncomment the next line to enable admin documentation:
> > > >     'django.contrib.admindocs',
> > > > )
>
> > > > Here are the appropriate settings from project's urls.py
>
> > > >     #(r'^css(?P.*)$', 'django.views.static.serve',
> > > > {'document_root': '/home/amr/django/amr'}),
> > > >     # Uncomment the admin/doc line below to enable admin
> > > > documentation:
> > > >     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> > > >     # Uncomment the next line to enable the admin:
> > > >     (r'^admin/', include(admin.site.urls)),
> > > > )
>
> > > > On Jan 27, 5:26 pm, Wim Feijen  wrote:
>
> > > > > Hi Octopus,
>
> > > > > What do you mean by: "won't load correctedly"?
>
> > > > > Is there an admin interface at /admin/ ? If not, did you enable the
> > > > > admin in your settings.py and in your urls.py?
>
> > > > > Is there one or more object missing from the admin interface? If there
> > > > > is one missing, maybe you've made an error in your admin.py file,
> > > > > which causes the object not to load in the admin. Comment your
> > > > > ModelAdmin instances and try again, if necessary go back to the most
> > > > > basic admin.site.register(MyModel)
>
> > > > > Do the static files (css, js) not load? Then maybe your paths in
> > > > > settings.py are not configured properly.
>
> > > > > Hope this helps, and if you need any further assistance please let us
> > > > > know what exactly is wrong.
>
> > > > > Good luck!
>
> > > > > Wim
>
> > > > > On Jan 27, 10:47 pm,octopusgrabbus wrote:
>
> > > > > > I am running Django 1.2.4 and mod_wsgi. My application is running
> > > > > > fine.
> > > > > > My admin won't load correctly.
>
> > > > > > wsgi_handler.py
> > > > > > ---
> > > > > > import os
> > > > > > import sys
>
> > > > > > PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
> > > > > > sys.path.append(PROJECT_ROOT)
> > > > > > 

Re: admin won't load revisited

2011-01-28 Thread octopusgrabbus
In addition, I can't get the built-in server to serve the admin's look
and feel. I see that as a good thing, because clearly it's a wrong
setting that affects both servers. Here are the settings again.

# Main URL for the project
BASE_URL = 'http://localhost:8002'

# Absolute path to the directory that holds media
MEDIA_ROOT = '/usr/local/www/documents/media'

# URL that handles the media served from MEDIA_ROOT
MEDIA_URL = '/media/'

# URL prefix for admin media -- CSS, JavaScript and images.
ADMIN_MEDIA_PREFIX = BASE_URL + 'media/admin/'


Thanks.
cmn

On Jan 28, 8:49 am, octopusgrabbus  wrote:
> After making this change, I got the admin interface's look and feel,
> and then put back the original and did not get the look and feel, When
> I put this change back ADMIN_MEDIA_PREFIX = BASE_URL + 'media/admin/',
> I no longer get the look and feel. I've cleared the cache and
> rebooted. It looks like there's a caching condition somewhere, but I'm
> not aware of what it is. Any ideas? Thanks.
>
> On Jan 27, 7:24 pm, OverKrik  wrote:
>
> > Try this:
>
> > ADMIN_MEDIA_PREFIX = BASE_URL + 'media/admin/'
>
> > On Jan 28, 1:48 am,octopusgrabbus wrote:
>
> > > I am referring to Django's admin site. By not loading correctly, I
> > > mean the admin site works, but does not display the nice look and feel
> > > that displays when using Django's built in web server.
>
> > > "Do the static files (css, js) not load? Then maybe your paths in
> > > settings.py are not configured properly. "
>
> > > Yes, they do not load.
>
> > > To the best of my knowledge, I have no ModelAdmin instances.
>
> > > Here are the appropriate lines from project's settings.py
>
> > > # Main URL for the project
> > > BASE_URL = 'http://localhost:8002'
>
> > > # Absolute path to the directory that holds media
> > > #MEDIA_ROOT = '%s/media/' % BASE_PATH
> > > MEDIA_ROOT = '/usr/local/www/documentation/media'
>
> > > # URL that handles the media served from MEDIA_ROOT
> > > MEDIA_URL = '/media/'
>
> > > # URL prefix for admin media -- CSS, JavaScript and images.
> > > #ADMIN_MEDIA_PREFIX = "%sadmin/" % MEDIA_URL
> > > ADMIN_MEDIA_PREFIX = "admin/"
>
> > > INSTALLED_APPS = (
> > >     'django.contrib.auth',
> > >     'django.contrib.contenttypes',
> > >     'django.contrib.sessions',
> > >     'django.contrib.sites',
> > >     'django.contrib.messages',
> > >     'amr.login',
> > >     'amr.inventory_check',
> > >     # Uncomment the next line to enable the admin:
> > >     'django.contrib.admin',
> > >     # Uncomment the next line to enable admin documentation:
> > >     'django.contrib.admindocs',
> > > )
>
> > > Here are the appropriate settings from project's urls.py
>
> > >     #(r'^css(?P.*)$', 'django.views.static.serve',
> > > {'document_root': '/home/amr/django/amr'}),
> > >     # Uncomment the admin/doc line below to enable admin
> > > documentation:
> > >     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> > >     # Uncomment the next line to enable the admin:
> > >     (r'^admin/', include(admin.site.urls)),
> > > )
>
> > > On Jan 27, 5:26 pm, Wim Feijen  wrote:
>
> > > > Hi Octopus,
>
> > > > What do you mean by: "won't load correctedly"?
>
> > > > Is there an admin interface at /admin/ ? If not, did you enable the
> > > > admin in your settings.py and in your urls.py?
>
> > > > Is there one or more object missing from the admin interface? If there
> > > > is one missing, maybe you've made an error in your admin.py file,
> > > > which causes the object not to load in the admin. Comment your
> > > > ModelAdmin instances and try again, if necessary go back to the most
> > > > basic admin.site.register(MyModel)
>
> > > > Do the static files (css, js) not load? Then maybe your paths in
> > > > settings.py are not configured properly.
>
> > > > Hope this helps, and if you need any further assistance please let us
> > > > know what exactly is wrong.
>
> > > > Good luck!
>
> > > > Wim
>
> > > > On Jan 27, 10:47 pm,octopusgrabbus wrote:
>
> > > > > I am running Django 1.2.4 and mod_wsgi. My application is running
> > > > > fine.
> > > > > My admin won't load correctly.
>
> > > > > wsgi_handler.py
> > > > > ---
> > > > > import os
> > > > > import sys
>
> > > > > PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
> > > > > sys.path.append(PROJECT_ROOT)
> > > > > sys.path.append(os.path.join('/home/amr/django'))
> > > > > sys.path.append(os.path.join('/home/amr/django/amr'))
> > > > > sys.path.append(os.path.join('/home/amr/bin'))
> > > > > sys.path.append(os.path.join('/usr/local/www/documents/media'))
>
> > > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'amr.settings'
> > > > > os.environ['PYTHON_EGG_CACHE'] = '/python_egg_cache'
>
> > > > > import django.core.handlers.wsgi
> > > > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > > > httpd.conf
> > > > > --
> 

Re: Screen Field Selected Data Lost When Submit Button clicked and screen error results

2011-01-28 Thread hank23
So in a case like this the value previously selected can't be put back
out to the screen when the errors are displayed, to avoid the user
having to reselect the same file again when he inputs the previously
missing data?

On Jan 27, 8:40 pm, Karen Tracey  wrote:
> On Thu, Jan 27, 2011 at 5:30 PM, hank23  wrote:
> > I have a file upload screen coded and working, whenever I enter all of
> > the data (original file selected from the browse button; as well as
> > target file path and name entered in a separate textbox) at one time.
> > But when I leave the destination file field blank after selecting the
> > original file an error is returned saying the destination field needs
> > to be input, however when that error is returned to the screen the
> > file previously selected using the file field and browse button, is
> > not being returned with it. Why is my original file being dropped?
>
> It's a browser security measure. Browsers will not allow a web-server to
> specify an initial value for a file input field, since that could lead to
> malicious servers easily tricking people into uploading sensitive
> information from their machines.
>
> 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What is a good app to use for a portfolio or images and videos?

2011-01-28 Thread mongoose
I downloaded the new django-cms and it's quite a great package. It
offers video and images plus many more plugins. It's overkill for a
smaller portfolio site but it offers everything.
Still just testing though, haven't had to edit much but think that
when I need to change things then the hard times will come.

On Jan 27, 4:17 pm, Stuart  wrote:
> Have a look at django-filer by Stefan Foulis. There's also a plug-in
> for use with django-cms, if you wish.
>
> https://github.com/stefanfoulis/django-filer
>
> --Stuart
>
> On Jan 27, 7:30 am, mongoose  wrote:
>
> > Hi hi,
>
> > Wanting to make a simple site that hosts images and videos. Like a
> > portfolio page.
> > Are there any good apps specifically for uploading a video and
> > displaying it in a nice player?
>
> > Or is the better option to just upload it with something like
> > filebrowser and embed the link into flatpages?
>
> > Any suggestions welcome.

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



Re: admin won't load revisited

2011-01-28 Thread octopusgrabbus
After making this change, I got the admin interface's look and feel,
and then put back the original and did not get the look and feel, When
I put this change back ADMIN_MEDIA_PREFIX = BASE_URL + 'media/admin/',
I no longer get the look and feel. I've cleared the cache and
rebooted. It looks like there's a caching condition somewhere, but I'm
not aware of what it is. Any ideas? Thanks.
Then, I put back what I had and tested again and di

On Jan 27, 7:24 pm, OverKrik  wrote:
> Try this:
>
> ADMIN_MEDIA_PREFIX = BASE_URL + 'media/admin/'
>
> On Jan 28, 1:48 am,octopusgrabbus wrote:
>
> > I am referring to Django's admin site. By not loading correctly, I
> > mean the admin site works, but does not display the nice look and feel
> > that displays when using Django's built in web server.
>
> > "Do the static files (css, js) not load? Then maybe your paths in
> > settings.py are not configured properly. "
>
> > Yes, they do not load.
>
> > To the best of my knowledge, I have no ModelAdmin instances.
>
> > Here are the appropriate lines from project's settings.py
>
> > # Main URL for the project
> > BASE_URL = 'http://localhost:8002'
>
> > # Absolute path to the directory that holds media
> > #MEDIA_ROOT = '%s/media/' % BASE_PATH
> > MEDIA_ROOT = '/usr/local/www/documentation/media'
>
> > # URL that handles the media served from MEDIA_ROOT
> > MEDIA_URL = '/media/'
>
> > # URL prefix for admin media -- CSS, JavaScript and images.
> > #ADMIN_MEDIA_PREFIX = "%sadmin/" % MEDIA_URL
> > ADMIN_MEDIA_PREFIX = "admin/"
>
> > INSTALLED_APPS = (
> >     'django.contrib.auth',
> >     'django.contrib.contenttypes',
> >     'django.contrib.sessions',
> >     'django.contrib.sites',
> >     'django.contrib.messages',
> >     'amr.login',
> >     'amr.inventory_check',
> >     # Uncomment the next line to enable the admin:
> >     'django.contrib.admin',
> >     # Uncomment the next line to enable admin documentation:
> >     'django.contrib.admindocs',
> > )
>
> > Here are the appropriate settings from project's urls.py
>
> >     #(r'^css(?P.*)$', 'django.views.static.serve',
> > {'document_root': '/home/amr/django/amr'}),
> >     # Uncomment the admin/doc line below to enable admin
> > documentation:
> >     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> >     # Uncomment the next line to enable the admin:
> >     (r'^admin/', include(admin.site.urls)),
> > )
>
> > On Jan 27, 5:26 pm, Wim Feijen  wrote:
>
> > > Hi Octopus,
>
> > > What do you mean by: "won't load correctedly"?
>
> > > Is there an admin interface at /admin/ ? If not, did you enable the
> > > admin in your settings.py and in your urls.py?
>
> > > Is there one or more object missing from the admin interface? If there
> > > is one missing, maybe you've made an error in your admin.py file,
> > > which causes the object not to load in the admin. Comment your
> > > ModelAdmin instances and try again, if necessary go back to the most
> > > basic admin.site.register(MyModel)
>
> > > Do the static files (css, js) not load? Then maybe your paths in
> > > settings.py are not configured properly.
>
> > > Hope this helps, and if you need any further assistance please let us
> > > know what exactly is wrong.
>
> > > Good luck!
>
> > > Wim
>
> > > On Jan 27, 10:47 pm,octopusgrabbus wrote:
>
> > > > I am running Django 1.2.4 and mod_wsgi. My application is running
> > > > fine.
> > > > My admin won't load correctly.
>
> > > > wsgi_handler.py
> > > > ---
> > > > import os
> > > > import sys
>
> > > > PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
> > > > sys.path.append(PROJECT_ROOT)
> > > > sys.path.append(os.path.join('/home/amr/django'))
> > > > sys.path.append(os.path.join('/home/amr/django/amr'))
> > > > sys.path.append(os.path.join('/home/amr/bin'))
> > > > sys.path.append(os.path.join('/usr/local/www/documents/media'))
>
> > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'amr.settings'
> > > > os.environ['PYTHON_EGG_CACHE'] = '/python_egg_cache'
>
> > > > import django.core.handlers.wsgi
> > > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > > httpd.conf
> > > > --
> > > > Listen 8002
> > > > 
> > > > DocumentRoot /usr/local/www/documents
> > > > 
> > > >     Order allow,deny
> > > >     Allow from all
> > > > 
>
> > > > Alias /media/ /usr/local/www/documents/media/
> > > > 
> > > > Order deny,allow
> > > > Allow from all
> > > > 
>
> > > > WSGIScriptAlias / /usr/local/www/wsgi-scripts/wsgi_handler.py
> > > > 
> > > >     Order allow,deny
> > > >     Allow from all
> > > > 
> > > > #
> > > > 
>
> > > > This link exists in /usr/local/www/documents/media
> > > > media -> /usr/local/lib/python2.6/site-packages/django/contrib/admin/
> > > > media
>
> > > > according to the documentation.
>
> > > > I'm missing something, and just cannot see it. Pointers in fixing this
> > > > would be appreciated.
> > > > 

Re: Adding an App to the Admin

2011-01-28 Thread Jonas Geiregat
>> 
>> Are you logged in as a user with permission to change models in that app? It 
>> won't appear if not.

I once changed my admin.py file and after reloading nothing had changed.
What did solve this issue was restarting the server or hard refreshing the page 
(Shift + F5  or something like that, depending on the browser you're using)
But I'm guessing you've already done that.

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



Re: Google maps

2011-01-28 Thread Michael
You might take a look at
https://launchpad.net/ubuntu-django-foundations/map

It's a fairly new project, but is actively being developed.

-- 
Michael 

On Thu, 2011-01-27 at 21:23 -0800, roy mukasa wrote:
> Hey guys does anyone know how i can embed google maps into django? i
> am new to django but i am trying to develop an app in which i will
> embed a google map of a particular area.
> 

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



Re: Google maps

2011-01-28 Thread Shawn Milochik
Just do a Google search for the Google Maps API. It's the same regardless of 
whether you're using Django or something else to generate the HTML pages. You 
mainly have to write JavaScript.

Also, search github and bitbucket to see if someone's created and shared some 
code for Django to easily generate the templates and JavaScript for you so you 
don't have to write much other than some lovely Python.

Shawn

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



Re: first time deploying django on apache with mod_python on fedora 8

2011-01-28 Thread ashwoods
is there any reason you are using mod_python instead of, say, wsgi?
modpython is deprecated and there are "better" alternatives.
id start with that. looking in apache logs to find out why you have
the 500 error might help.
(a hunch tells me it might be a python path error)

ash

On 28 Jan., 07:45, n0h8dy  wrote:
> Hi,
>
> I'm trying to get my first Django app up and running on amazon ec2
> fedora 8 instance on apache with mod_python. I've got mod_python MySQL-
> python python-devel Django mysql-server installed.
>
> I've got the homepage to show up, but its a very simple view that just
> returns text. Anything more complex produces a 500 error. I don't have
> any other views setup right now, but I need the admin to work, which
> also current produces a 500 error.
>
> I've got a basic django setup with one app inside of it that has
> models and admin stuff.
>
> This is what my httpd.conf file looks like:
>
> 
>
>   ServerName  first.django-app.com
>
>   DocumentRoot "/sites/django-app"
>
> 
>   Order allow,deny
>   Allow from all
> 
>
> 
>   SetHandler python-program
>   SetEnv DJANGO_SETTINGS_MODULE django-app.settings
>   PythonInterpreter django-app
>   PythonHandler django.core.handlers.modpython
>   PythonOption django.root /
>   PythonPath "['/sites','/sites/django-app'] + sys.path"
>   PythonDebug On
> 
>
> 
>   SetHandler None
> 
>
> 
>   Order allow,deny
>   Allow from all
> 
>
> 
>     SetHandler None
> 
>
> 
>
> Any hints, suggestions, ideas on how to get this to work would be
> great.
>
> 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to format a datetime in a webpage?

2011-01-28 Thread Jirka Vejrazka
>         {{record.ComplaintTime|time:"Y-m-d
> H:i"}}

>From the documentation:

"The time filter will only accept parameters in the format string that
relate to the time of day, not the date (for obvious reasons). If you
need to format a date, use the date filter."

  So, you need to use:
{{record.ComplaintTime|date:"Y-m-d H:i"}}

  instead of:
{{record.ComplaintTime|time:"Y-m-d H:i"}}

  Cheers

Jirka

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



Re: Adding an App to the Admin

2011-01-28 Thread Corey Richardson
On 01/28/2011 06:30 AM, Daniel Roseman wrote:
> On Friday, January 28, 2011 3:09:34 AM UTC, kb1pkl wrote:
>>
>> I'm following the tutorial at [1]. I'm trying to add the app to the
>> admin site. I've run manage.py syncdb, and I've restarted the dev
>> server. Any hints? The appropriate files that I was instructed to modify
>> can be seen at [2]. Request more information and I can provide it.
>>
>> Thank you!
>> ~Corey
>>
>> [1] - http://docs.djangoproject.com/en/1.2/intro/tutorial02/
>> [2] - http://bpaste.net/show/13260/
>>
> 
> Are you logged in as a user with permission to change models in that app? It 
> won't appear if not.
> --
> DR. 
> 

I was set as a superuser (still am). I manually gave myself the
permissions to add/change/remove a post, and still nothing.

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



How to format a datetime in a webpage?

2011-01-28 Thread Wayne Young
Hi all,

I have come across an error when I tried to format a datetime in a webpage.
This the part of webpage:

{% for record in records.object_list %}
  
{{record.ComplaintPhone}}
{{record.CustomerName}}
{{record.ComplaintTime|time:"Y-m-d
H:i"}}
{{record.ComplaintService}}
{{record.ComplaintDetail}}
{{record.CustomerArea}}
{{record.IsSolved}}
{{record.SolveTime|time:"Y-m-d H:i"}}
{{record.SolveMethod}}
{{record.Username}}
{{record.Remark}}
{{record.Intime|time:"Y-m-d
H:i"}}
   
{% endfor %}

The "records" here  is a QuerySet came from view:

 records = Report.objects.order_by('-Intime').all()



I tested in shell:

>>>record = Report.objects.get(pk=1)
>>>record.ComplaintTime.strftime('%Y-%m-%d %H:%M')
'2011-01-28 15:29'

It showed correctly. Also the attribution of "SolveTime" and "Intime". But
when I used "record.ComplaintTime.strftime('%Y-%m-%d %H:%M')" in webpage, it
said "Could not parse". So I changed to use "time" filter as above. But now
it shows nothing in those three time fields. I do not know why. Would
someone pleased to tell where I am wrong?

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



first time deploying django on apache with mod_python on fedora 8

2011-01-28 Thread n0h8dy
Hi,

I'm trying to get my first Django app up and running on amazon ec2
fedora 8 instance on apache with mod_python. I've got mod_python MySQL-
python python-devel Django mysql-server installed.

I've got the homepage to show up, but its a very simple view that just
returns text. Anything more complex produces a 500 error. I don't have
any other views setup right now, but I need the admin to work, which
also current produces a 500 error.

I've got a basic django setup with one app inside of it that has
models and admin stuff.

This is what my httpd.conf file looks like:



  ServerName  first.django-app.com

  DocumentRoot "/sites/django-app"


  Order allow,deny
  Allow from all



  SetHandler python-program
  SetEnv DJANGO_SETTINGS_MODULE django-app.settings
  PythonInterpreter django-app
  PythonHandler django.core.handlers.modpython
  PythonOption django.root /
  PythonPath "['/sites','/sites/django-app'] + sys.path"
  PythonDebug On



  SetHandler None



  Order allow,deny
  Allow from all



SetHandler None




Any hints, suggestions, ideas on how to get this to work would be
great.

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



Google maps

2011-01-28 Thread roy mukasa
Hey guys does anyone know how i can embed google maps into django? i
am new to django but i am trying to develop an app in which i will
embed a google map of a particular area.

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



Geodjango: ogrinspect on a Postgis layer?

2011-01-28 Thread Ryan Clark
I'm interested in using the ogrinspect command to help build a load.py
file for bringing data from one PostGIS table (in a legacy db) into my
Django project's db. What I can't seem to figure out is how to write the
data source location for a PostGIS layer. Can it be done?

I tried the following:
ogrinspect PG:"dbname=xxx host=xxx port=xxx user=xxx password=xxx"
modelname --mapping
... but that doesn't really make sense since it is pointing to a
database and not just a single layer. 

Any advice? 

Thanks,
Ryan



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



Re: Adding an App to the Admin

2011-01-28 Thread Daniel Roseman
On Friday, January 28, 2011 3:09:34 AM UTC, kb1pkl wrote:
>
> I'm following the tutorial at [1]. I'm trying to add the app to the
> admin site. I've run manage.py syncdb, and I've restarted the dev
> server. Any hints? The appropriate files that I was instructed to modify
> can be seen at [2]. Request more information and I can provide it.
>
> Thank you!
> ~Corey
>
> [1] - http://docs.djangoproject.com/en/1.2/intro/tutorial02/
> [2] - http://bpaste.net/show/13260/
>

Are you logged in as a user with permission to change models in that app? It 
won't appear if not.
--
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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Adding an App to the Admin

2011-01-28 Thread Corey Richardson
On 01/28/2011 03:43 AM, Jonas Geiregat wrote:
> 
> Op 28-jan-2011, om 04:09 heeft Corey Richardson het volgende geschreven:
> 
>> I'm following the tutorial at [1]. I'm trying to add the app to the
>> admin site. I've run manage.py syncdb, and I've restarted the dev
>> server. Any hints? The appropriate files that I was instructed to modify
>> can be seen at [2]. Request more information and I can provide it.
>>
>> Thank you!
>> ~Corey
>>
>> [1] - http://docs.djangoproject.com/en/1.2/intro/tutorial02/
>> [2] - http://bpaste.net/show/13260/
>>
> 
> Did you create a admin.py file in the application directory ?
> Because the only thing I see is your settings.py file.
> 
> 

Yes, that was the first 'file' in the pastebin. It has everything it
says I need. I've started branching from the tutorial to follow my own
whimsical project idea, but it didn't work when I was following the
tutorial to the letter either.

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



Re: Django and Oracle XE - Empty models file

2011-01-28 Thread Jani Tiainen
On Friday 28 January 2011 11:45:48 Nathan wrote:
> Cheers for the reply. The database in question is a remote database. I
> presume by Django user that you're referring to the local user account?
> Otherwise the user credentials in settings should be adequate.
> 
> I'm guessing the only resolution to this is to hand craft the models?

That is correct.

You just have to remember declare managed = False ni API, and from my 
experience (working with legacy Oracle DB for a good while), it's better to 
pick only what you need.

One special note: Oracle DATE field stores both - date and time with resolution 
of a second. 

There is no equivalent field in Django. If you use date.DateTimeField you get 
all kind of nasty exceptions when working with this kind of a legacy data 
because DateTimeField expects to find TIMESTAMP type (date/time with resolution 
of a fractions of a second)

We've worked around this by declaring our own custom field.

-- 

Jani Tiainen

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



Re: Error when subclassing models.ForeignKey field

2011-01-28 Thread roman


On 26 Jan., 18:33, Roman Klesel  wrote:

> Should I open a bug report?

That's what I just did:
http://code.djangoproject.com/ticket/15184

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



contrib.messages and HTML5 browsing context

2011-01-28 Thread Plovarna
Hello,
I just read Messages documentation 
(http://docs.djangoproject.com/en/1.2/ref/contrib/messages/#behavior-of-parallel-requests),
 and in the "Behavior of parallel requests" section is this note:

"...Note that this is typically not a problem in most applications and will 
become a non-issue in HTML5, where each window/tab will have its own browsing 
context."

What does it exactly mean please? For example, If I have website in HTML5 and 
have opened several tabs pointing to same website, there is no problem with 
"shared" cookie between tabs? So if application in first tab set  message in 
cookie, this cookie will be hidden from other tabs?

Thank you for clarification
Michal

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



RE: abstract base class and overwriting save()

2011-01-28 Thread Chris Matthews
The "save def save(self, *args, **kwargs):" should not have the leading save.

Also, if you are making a car system then this structure seems more appropriate:
class CarMake(models.Model):
   ...


class Car(models.Model):
   make = models.ForeignKey(CarMaker)
   ...
 def save(self, *args, **kwargs):
do_something()
super(Car, self).save(*args, **kwargs)



From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Daniel Roseman
Sent: 28 January 2011 11:36
To: django-users@googlegroups.com
Subject: Re: abstract base class and overwriting save()

On Friday, January 28, 2011 9:21:48 AM UTC, Jaroslav Dobrek wrote:
Hi,

if I have got several models that have identical code, except for
their save method, how can I use an abstract base class for them? Will
I have to overwrite save() for each model? Or is there a generic way
to define save(), i.e. a way that I have to use only once -- in the
abstract base class?

class BMW(models.Model):
   ...
  save def save(self, *args, **kwargs):
do_something()
super(BMW, self).save(*args, **kwargs)

class Fiat(models.Model):
   ...
  save def save(self, *args, **kwargs):
do_something()
super(Fiat, self).save(*args, **kwargs)

Jaroslav

The whole point of subclassing is that subclasses inherit models from the 
superclass. That's how the model save() method is definted in the first place, 
if you don't override it. What exactly are you having problems with?
--
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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

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



Re: Django and Oracle XE - Empty models file

2011-01-28 Thread Nathan
Cheers for the reply. The database in question is a remote database. I 
presume by Django user that you're referring to the local user account? 
Otherwise the user credentials in settings should be adequate. 

I'm guessing the only resolution to this is to hand craft the models?

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



Re: abstract base class and overwriting save()

2011-01-28 Thread Jaroslav Dobrek
> The whole point of subclassing is that subclasses inherit models from the
> superclass. That's how the model save() method is definted in the first
> place, if you don't override it. What exactly are you having problems with?

It seems that my problems were due to another mistake of mine. I was
thinking in a too complicated way. You are right: nothing has to be
done, just inherit. 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: abstract base class and overwriting save()

2011-01-28 Thread Daniel Roseman
On Friday, January 28, 2011 9:21:48 AM UTC, Jaroslav Dobrek wrote:
>
> Hi, 
>
> if I have got several models that have identical code, except for 
> their save method, how can I use an abstract base class for them? Will 
> I have to overwrite save() for each model? Or is there a generic way 
> to define save(), i.e. a way that I have to use only once -- in the 
> abstract base class? 
>
> class BMW(models.Model): 
>... 
>   save def save(self, *args, **kwargs): 
> do_something() 
> super(BMW, self).save(*args, **kwargs) 
>
> class Fiat(models.Model): 
>... 
>   save def save(self, *args, **kwargs): 
> do_something() 
> super(Fiat, self).save(*args, **kwargs) 
>
> Jaroslav


The whole point of subclassing is that subclasses inherit models from the 
superclass. That's how the model save() method is definted in the first 
place, if you don't override it. What exactly are you having problems with?
--
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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



abstract base class and overwriting save()

2011-01-28 Thread Jaroslav Dobrek
Hi,

if I have got several models that have identical code, except for
their save method, how can I use an abstract base class for them? Will
I have to overwrite save() for each model? Or is there a generic way
to define save(), i.e. a way that I have to use only once -- in the
abstract base class?

class BMW(models.Model):
   ...
  save def save(self, *args, **kwargs):
do_something()
super(BMW, self).save(*args, **kwargs)

class Fiat(models.Model):
   ...
  save def save(self, *args, **kwargs):
do_something()
super(Fiat, self).save(*args, **kwargs)

Jaroslav

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



Re: Adding an App to the Admin

2011-01-28 Thread Jonas Geiregat

Op 28-jan-2011, om 04:09 heeft Corey Richardson het volgende geschreven:

> I'm following the tutorial at [1]. I'm trying to add the app to the
> admin site. I've run manage.py syncdb, and I've restarted the dev
> server. Any hints? The appropriate files that I was instructed to modify
> can be seen at [2]. Request more information and I can provide it.
> 
> Thank you!
> ~Corey
> 
> [1] - http://docs.djangoproject.com/en/1.2/intro/tutorial02/
> [2] - http://bpaste.net/show/13260/
> 

Did you create a admin.py file in the application directory ?
Because the only thing I see is your settings.py file.


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