Re: Problem with generic views in tutorial example

2008-08-24 Thread Rodney Topor

> Anurag, Thanks.  That worked for me too.  But it's hardly a solution.
> Now I can't use admin.  I want both.  Is that asking too much?  Has
> anyone else any ideas?

OK, I've solved all my problems.  It was my mistake.  For some reason,
I had these two lines in urls.py in the reverse order:

(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/(.*)', admin.site.root),

Now I can have a public and admin interface, whether or not I use a
separate admin.py file.  Sorry to have bothered you.  It seems generic
views work after all!  But it was useful for me to learn about
admin.py - it seems a good idea to use a separate admin.py file.

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



Re: APPEND_SLASH and Apache

2008-08-24 Thread [EMAIL PROTECTED]

I was having this exact same problem.

I found a solution in chapter 20 of the Django book
http://www.djangobook.com/en/1.0/chapter20/
or see the highlighted section of the same page
http://www.diigo.com/annotated/dc0730e6af51d60cbcc6ff6a8daf847b

According to it
"If you deploy Django at a subdirectory — that is, somewhere deeper
than “/” — Django won’t trim the URL prefix off of your URLpatterns."

I simply moved my Django app to the / path of my Virtual Host and
adjusted my Apache config to look like:


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE whaler.settings
PythonOption django.root /whaler
PythonDebug On
PythonInterpreter whaler
PythonPath "['/home/jgourneau/whaler.com'] + sys.path"


After I did this slashes were append to my urls like I expected.  I am
using revision 8533 of Django.  I hope this helps.

--josh


On Jul 28, 8:41 pm, Torsten Bronger <[EMAIL PROTECTED]>
wrote:
> Hallöchen!
>
> While APPEND_SLASH works with the Django testserver, I can't get it
> working with Apache.  My httpd.conf says:
>
> 
>     PythonOption django.root /mysite
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>     PythonDebug On
>     PythonPath "['/home/bronger/src/mysite/current', 
> '/home/bronger/src/mysite/current/mysite'] + sys.path"
> 
>
> I use a current SVN-Django.  Any ideas why Apache and testserver
> behave differently here?
>
> Tschö,
> Torsten.
>
> --
> Torsten Bronger, aquisgrana, europa vetus
>                    Jabber ID: [EMAIL PROTECTED]

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



Re: threadedforum: Anybody that uses it?

2008-08-24 Thread Gus

I'm looking at using this as well,
have you got it working? any feedback?

g

On Jul 30, 6:29 am, Berco Beute <[EMAIL PROTECTED]> wrote:
> threadedforum(http://code.google.com/p/django-threadedforum/) seems
> like a good forum application for my site, but the documentation is
> very minimal (to say the least). My friend google knows of no examples
> of succesfully using it. Unfortunately the current head of the trunk
> still has some bugs.
>
> Anybody here that uses thethreadedforumapplication and cares to
> share some insights? Or maybe someone knows a decent alternative.
>
> 2B
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Example of template tag I can modify?

2008-08-24 Thread Leaf

It's me again. After yelling, "I HATE WINDOWS!", switching to Mac, and
not thinking about Django again until I upgraded to OS X 10.5 (with
Python 2.5 and SQLite 3 included), I've decided to rewrite my Dj
Styles application to brush up on my skills.

One of the fundamental concepts of Dj Styles is putting content in
"blocks" with headers and bodies, so I was wondering if anyone could
give me examples of custom template tags that could simply echo HTML
code to make it easier on template authors to write the blocks. I'm
thinking of something like:

{% blockhead %}
becoming:


Can anyone give me a skeleton template tag that I can put my own
custom HTML into?

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



Re: Example of template tag I can modify?

2008-08-24 Thread Erik Allik

If you consult the documentation, you will see it has code examples.  
It seems to me that what you're looking for are inclusion tags. Django  
is famous for its high quality documentation so I doubt it can't help  
you.

Erik

P.S. no HTML tables for layout! :)

On 25.08.2008, at 3:05, Leaf wrote:

>
> Also, I was wondering if you could provide me with one could do the
> same thing, but with a variable.
>
> I'm sorry if this seems a bit freeloader, but I don't quite understand
> the custom tag docs and think it would be easier to learn by example
> with tags that do the kind of things I'd write tags to do.
>
> Regards,
> Leaf
>
> On Aug 24, 8:01 pm, Leaf <[EMAIL PROTECTED]> wrote:
>> It's me again. After yelling, "I HATE WINDOWS!", switching to Mac,  
>> and
>> not thinking about Django again until I upgraded to OS X 10.5 (with
>> Python 2.5 and SQLite 3 included), I've decided to rewrite my Dj
>> Styles application to brush up on my skills.
>>
>> One of the fundamental concepts of Dj Styles is putting content in
>> "blocks" with headers and bodies, so I was wondering if anyone could
>> give me examples of custom template tags that could simply echo HTML
>> code to make it easier on template authors to write the blocks. I'm
>> thinking of something like:
>>
>> {% blockhead %}
>> becoming:
>> 
>>
>> Can anyone give me a skeleton template tag that I can put my own
>> custom HTML into?
>>
>> Regards,
>> Leaf
> >


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



Re: ANN: django-morsels

2008-08-24 Thread Itai Tavor

Hi Richard,

Can you provide more information? What URL did you enter in the  
morsel, and at what URL are you viewing the template that tries to  
include the morsel? Also, does your SITE_ID setting match the site you  
selected in the morsel?

Itai


On 24/08/2008, at 9:11 PM, Richard Ward wrote:

>
> I too am unable to display the morsels.
>
> I believe it is install correctly.
>
> I can add morsels.
> The morsel tag generates no error when the template is generated.
>
> This is my context setting:
> TEMPLATE_CONTEXT_PROCESSORS = (
>"django.core.context_processors.auth",
>"django.core.context_processors.debug",
>"django.core.context_processors.i18n",
>"django.core.context_processors.media",
>"django.core.context_processors.request",
> )
>
> I do not know how to debug the installation.
>
>
> Thanks
> Richard
>
> On Sat, Aug 23, 2008 at 12:04 AM, Itai Tavor <[EMAIL PROTECTED]>  
> wrote:
>>
>> Apologies to everyone who got bit by this. I updated the INSTALL
>> instructions with the requirement of adding 'request' to the context.
>>
>> Itai
>>
>>
>> On 23/08/2008, at 6:26 AM, lingrlongr wrote:
>>
>>>
>>> Recommended fix @ http://code.google.com/p/django-morsels/issues/detail?id=1
>>>
>>> On Aug 22, 2:51 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
 If I change my view to this, it works:

 # views.py
 def myview(request):
return object_list(
request,
queryset=Stuff.objects.all(),
extra_context = {
  'request': request,
}
)

 Is this supposed to be the right way to use morsels?

 Keith

 On Aug 22, 12:50 pm, lingrlongr <[EMAIL PROTECTED]> wrote:

> I can't get this to work at all.  Seems to bomb here:

> class MorselManager(models.Manager):
>def get_for_current(self, context, name, inherit=False):
>if not context.has_key('request'):  <-- key never
> seems to exist
>return None

> I have a morsel defined with a URL of "/mypage/".

> # urls.py
> (r'^mypage/$', myview),

> # views.py
> def myview(request):
>return object_list(
>request,
>queryset=Stuff.objects.all(),
>)

> I have this in my template:
> {% load morsel_tags %}
> {% morsel %}

> Am I missing something?

> Keith

> On Aug 21, 5:19 am, Itai Tavor <[EMAIL PROTECTED]> wrote:

>> At first glance (and, quite possibly, second and third) django-
>> morsels
>> might look like a clone of django-chunks 
>> (http://code.google.com/p/django-chunks/
>> ). Both apps attempt to solve the same problem, and in fact, I
>> wrote
>> this app after seeing and trying out django-chunks (so thanks,
>> Clint
>> Ecker!). But the feature set and functions differ enough to  
>> justify
>> the existence of a second implementation.

>> These apps provide a way to store partial page content in the
>> database, and manage it in the admin app, when this content is
>> integrated in pages that also contain dynamic features. I always
>> dealt
>> with this using FlatPages and templatetags (custom-written for  
>> each
>> new project) that included them in templates. Looking at django-
>> chunks, I realized a few things:

>> 1) The templatetags I've already written worked better, for my  
>> own
>> use, than the key-based approach of django-chunks.
>> 2) Using a dedicated model for this type of content made a lot of
>> sense.
>> 3) Merging this model and all those custom templatetags I already
>> had
>> into a reusable app also made sense.
>> 4) I needed a name that didn't have "chunks" in it.

>> The main features of django-morselsare:

>> * Each morsel can be tied to a site page by specifying the page's
>> URL
>> in the morsel.

>> * Differentmorselscan be used in the same page by adding  
>> arbitrary
>> names to the morsel's URL.

>> *Morselscan be inherited from higher levels in the site's URL
>> hierarchy. This allows the content of a single morsel to be
>> displayed
>> in a whole site section, while being overriden by othermorselsin
>> specific pages within the section.

>> *Morselscan include an optional title, which may be used to
>> identify
>> the morsel and may also be displayed in templates using the  
>> morsel.

>> * Two custom templatetags - morsel and withmorsel -  
>> allowmorselsto
>> be used in various, flexible ways.

>> *Morselscan be locked, which prevents them from being deleted.  
>> This
>> is intended to prevent accidental deletion of requiredmorsels, as
>> having to explicitly unlock a morsel before deleting it should  
>> make
>> the user think twice about it.

>> * If the typogrify app 

Re: Example of template tag I can modify?

2008-08-24 Thread Leaf

Also, I was wondering if you could provide me with one could do the
same thing, but with a variable.

I'm sorry if this seems a bit freeloader, but I don't quite understand
the custom tag docs and think it would be easier to learn by example
with tags that do the kind of things I'd write tags to do.

Regards,
Leaf

On Aug 24, 8:01 pm, Leaf <[EMAIL PROTECTED]> wrote:
> It's me again. After yelling, "I HATE WINDOWS!", switching to Mac, and
> not thinking about Django again until I upgraded to OS X 10.5 (with
> Python 2.5 and SQLite 3 included), I've decided to rewrite my Dj
> Styles application to brush up on my skills.
>
> One of the fundamental concepts of Dj Styles is putting content in
> "blocks" with headers and bodies, so I was wondering if anyone could
> give me examples of custom template tags that could simply echo HTML
> code to make it easier on template authors to write the blocks. I'm
> thinking of something like:
>
> {% blockhead %}
> becoming:
> 
>
> Can anyone give me a skeleton template tag that I can put my own
> custom HTML into?
>
> Regards,
> Leaf
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: locale name conflict (deploy issue)

2008-08-24 Thread msaelices

Maybe you have an __init__.py inside locale directory?

On 16 ago, 13:12, dcoy <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to deploy my django project to my VPN (CentOS 5 python
> 2.4). I'm having ALL kinds of issues, nothing seems to work after
> following the steps in the installation documentation at
> djangoproject.com. Anyways now I've tracked down an issue that I don't
> really know how to solve:
>
> When running  "# python manage.py" at my django project root I get:
> .
> File "/usr/lib/python2.4/gettext.py", line 128, in _expand_lang
> from locale import normalize
> ImportError: cannot import name normalize
>
> So after some investigation I realize that it is my locale directory
> under $PROJECTPATH  that screw things up since it is first in the
> sys.path(s).
>
> My locale is set up according to django i18n doc as
> # $PROJECTPATH/locale//LC_MESSAGES/django.(po|mo)
> but when gettext.py is trying to import from locale it is looking at
> my project locale, not in the /usr/lib/python2.4/locale.py.
>
> I confirmed this by temporarily renaming my $PROJECTPATH/locale.
>
> Can someone help me out? I don't know the correct course to take here.
>
> Thanks,
> Calle
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: list_filter for my own views

2008-08-24 Thread timc3

Well I implemented it using a queryset.

TemplateTag that includes a template to build the filter, then a
function that will parse the queryset and apply the querystring to the
list_detail view.

I also changed my paginator templatetag so that it could parse the
Querystring through to build up the pagination.

On Aug 23, 8:44 pm, timc3 <[EMAIL PROTECTED]> wrote:
> On quite a few pages I am using the standard generic views, mostly
> wrapped, but not always.
>
> Anyway I would like to use a list_filter on my own views, much like
> the admins - filter by date, by boolean or whatever.
>
> I can see the long way around of building up a query, though this will
> probably end up in the urls, but I was wondering if there was a
> standard already defined way of doing this.
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Saving an unbound form

2008-08-24 Thread Karen Tracey
On Sun, Aug 24, 2008 at 4:56 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote:

>
> Hello,
>
> I have a form that I have created and it works fine. I am now trying
> to save this form. The data returned from the form spans a
> relationship and should update 2 tables associated by a foreign key.
>
> From what I have read on the docs, because it is an unbound form I
> need to write my own save method. This is what I have been trying:
>
> from django import forms
> from project.pastebin.models import loggenerator
> from project.pastebin.models import entry
> from project.pastebin.models import submittedlog
>
>
> class pasteForm(forms.Form):
>loggenerator = forms.ModelChoiceField(loggenerator.objects.all())
>log = forms.CharField(widget=forms.Textarea)
>
>def save(self):
>newlog = project.objects.entry(sessionhash=sessionhash,
>uniqueurl=uniqueurl)
>return newlog
>
> And it's not working. The above is code I am trying that to avoid
> complication at this stage with the relationship I was hoping would
> just update one table, but the code doesn't work. I can't find
> anything really detailed about saving forms that are unbound to
> models. If anyone can link me something that might put me on track I'd
> be grateful.
>
>
First, I think there's some terminology confusion here.  An 'unbound' form
in the context of Django forms means the form has no data filled in (see:
http://www.djangoproject.com/documentation/forms/#creating-form-instances),
so it doesn't make any sense to 'save' an unbound form.

I think what you are saying is you have a form that is not a ModelForm and
so there is no database object automatically associated with the form?  But
you want to make some database updates based on the data in the form?

If so, that's certainly possible, and you could (though I don't think you
must) do it by implementing and calling a save() method for your form.
save() could do the work of creating/updating the model object(s)
represented in your form.  It's hard to guess why what you are doing isn't
working so far because 'not working' is way too vague a desciption of the
problems you are running into.  What exactly do you do and what happens vs.
what you expect?  If you provide a few more details on what 'not working'
means and someone may be able to help.

Karen

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



Re: Noob: form class location

2008-08-24 Thread Gerard Petersen

True, but it took me some figuring out and there's still some 'spaghetti'.

The import of models was needed on more then one place (next to views.py) 
because of the meta class.

myforms.py:

from models import *

class CustomerForm(ModelForm):
class Meta:
model = Customer

Regards,

Gerard.

phillc wrote:
> if im moving my form related logic to another file, i wouldnt really
> need to import forms else where? ;)
> 
> On Aug 23, 9:10 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> wrote:
>> On Sat, Aug 23, 2008 at 8:59 PM, Julien Phalip <[EMAIL PROTECTED]> wrote:
>>
>>> Hi,
>>> In Django there are no 'standard' as such. You'd talk more about
>>> 'conventions'.
>>> One common way is to put all your forms in forms.py. But that's just
>>> for cleanliness.
>> While this is a common convention, I would point out that it is not
>> without problems. If you have a local 'forms.py' module, you leave
>> yourself open to name clashes if you use 'from django import forms' in
>> your code.
>>
>> However, the rest of your advice is correct - there is not set rule,
>> just conventions, and as long as Python can import it, the code will
>> work the same regardless of the location.
>>
>> Yours,
>> Russ Magee %-)
> > 

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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



Re: Audit Trail

2008-08-24 Thread Larrik Jaerico

Sérgio,

Sorry about the **kwargs thing, my fault. I'm the one who patched
AuditTrail to reflect the newest version of Django, but since I have
some custom code in there I had to go line-by-line and figure out what
to bring back to the website. I missed the **kwargs thing, though, it
seems.

-Larrik Jaerico

On Aug 21, 10:25 am, Sérgio Durand <[EMAIL PROTECTED]> wrote:
> Hi Erick,
>
> It was working on r8339.
> I've updated django this morning to r8460 to and still working !!
>
> What is "history Manager" that you said ?
>
> look how i'm using audit trail:
> 1) i have my 'ordinary' model (without audit trail feature)
> 2) i get the audit trail code and drop it into site-packages python
> directory (it works if you put on root dir of your django project too)
> 3) put import line on your model
> 4) put an 'extra' attribute in your model (that i called 'history') to
> use audit trail.
> 5) and finnaly, run the magic command 'syncdb'.. or, sqlall ,
> you should see all the sql generated by django.
>
> follows my (very) simple example:http://dpaste.com/hold/72943/
>
> Try again with a simple example like that ... if did't work, send the
> error message...
>
> Good luck!!! ;)
>
> Sergio Durand
>
> erikcw escreveu:
>
> > Hi Sergio,
>
> > I updated my code with your changes, and it still doesn't seem to be
> > working.  I don't have the history Manager in my model.
>
> > Is it working for you?  Are you using the latest trunk?
>
> > Thanks!
> > Erik
>
> > On Aug 19, 12:15 pm, Sérgio Durand <[EMAIL PROTECTED]> wrote:
>
> >> Hi people,
>
> >> Finally i've got Audit Trail [1] working again !!! :)
> >> I'm not a django/python expert (i've started studying 2 months ago), but
> >> after fighting with "python manage.py validate" and searching in google,
> >> i've got the solution... the problem basically was missing **kwargs
> >> arguments in some handler functions (because changes made in r8223).
> >> Maybe this problem is very simple (in fact i think it is), but i've
> >> spent several hours (and learned a lot of things too) to get this working.
> >> This was my first code contribution and i'm very glad for that!!
>
> >> Sergio Durand
>
> >> [1]:http://code.djangoproject.com/wiki/AuditTrail
>
> >> ps: i hope i didn't make a code mistake and sorry my english !!! ;

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



Saving an unbound form

2008-08-24 Thread [EMAIL PROTECTED]

Hello,

I have a form that I have created and it works fine. I am now trying
to save this form. The data returned from the form spans a
relationship and should update 2 tables associated by a foreign key.

>From what I have read on the docs, because it is an unbound form I
need to write my own save method. This is what I have been trying:

from django import forms
from project.pastebin.models import loggenerator
from project.pastebin.models import entry
from project.pastebin.models import submittedlog


class pasteForm(forms.Form):
loggenerator = forms.ModelChoiceField(loggenerator.objects.all())
log = forms.CharField(widget=forms.Textarea)

def save(self):
newlog = project.objects.entry(sessionhash=sessionhash,
uniqueurl=uniqueurl)
return newlog

And it's not working. The above is code I am trying that to avoid
complication at this stage with the relationship I was hoping would
just update one table, but the code doesn't work. I can't find
anything really detailed about saving forms that are unbound to
models. If anyone can link me something that might put me on track I'd
be grateful.

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



Re: urlpatterns and generic views cheatsheet

2008-08-24 Thread Idan

Useful! Thank you. :)

-I

On Aug 23, 3:11 pm, DavidY <[EMAIL PROTECTED]> wrote:
> Here is a summary of all the tutorials and docs that I have read on
> urlpatterns and generic views. It is a 2 page, concise, example code
> based cheat sheet.
>
> http://www.scribd.com/doc/4975790/urlpatterns-for-django-cheatsheet
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



limiting choices in admin.ModelAdmin based on request.user

2008-08-24 Thread Patrick J. Anderson

How should I limit choices for ForeignKey fields in admin.ModelAdmin 
instances based on request.user attributes, since I can't pass a request 
object to the forms.ModelForm constructor?


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



Changing Login Page for Admin

2008-08-24 Thread Tim Sawyer

Hi,

I'm using the newforms admin stuff, and I'd like to use my own URL for the 
login page for the admin site.

So, if someone goes to /admin on my site (which is where the admin site is 
located), I'd like to redirect to /private/login/?next=/admin.

(The reason I want to do that is that I have some custom code on the login 
that looks for and removes a suffix before passing through to the user 
authentication code.)

Is this straightforward?

Thanks,

Tim.

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



Re: Noob: form class location

2008-08-24 Thread phillc

if im moving my form related logic to another file, i wouldnt really
need to import forms else where? ;)

On Aug 23, 9:10 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Sat, Aug 23, 2008 at 8:59 PM, Julien Phalip <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > In Django there are no 'standard' as such. You'd talk more about
> > 'conventions'.
> > One common way is to put all your forms in forms.py. But that's just
> > for cleanliness.
>
> While this is a common convention, I would point out that it is not
> without problems. If you have a local 'forms.py' module, you leave
> yourself open to name clashes if you use 'from django import forms' in
> your code.
>
> However, the rest of your advice is correct - there is not set rule,
> just conventions, and as long as Python can import it, the code will
> work the same regardless of the location.
>
> 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: FormWizard Problems

2008-08-24 Thread lingrlongr

Looks like my models are working.  (YAY!)   My save routine failed
though, but I finally figured it out.  So the done() function looks
like this now:

def done(self, request, form_list):
  o = PurchaseApplication()
  for form in form_list:
form.instance = o
form.save(commit=False)

  o.site = Site.objects.get_current()
  o.save()

Inheriting from a form doesn't seem to work.  But I'll work on that...

class A(ApplicationForm)
class B(A)  <-- not working - fields don't populate from parent obj

On Aug 23, 9:40 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> It looks like these ModelForms are going to work well for me.  I have
> a lot less code now.  I actually created 2 other classes to help out
> with the field ordering.  I haven't tested these yet...
>
> class OrderedForm(ModelForm):
>     def __init__(self, ordered_fields, *args, **kwargs):
>         super(OrderedForm, self).__init__(*args, **kwargs)
>         self.fields.keyOrder = ordered_fields
>         for f in self.fields:
>             self.fields[f].label = self.fields[f].help_text
>             self.fields[f].help_text = None
>
> class ApplicationForm(OrderedForm):
>     def __init__(self, *args, **kwargs):
>         try:
>             ordered_fields = list(self.Meta.fields)
>         except:
>             ordered_fields = []
>         super(ApplicationForm, self).__init__(ordered_fields, *args,
> **kwargs)
>
> I'll just inherit from ApplicationForm for all my forms.  I'm not sure
> how its going to work with ModelForm inheritance yet though...
>
> I don't understand how I'm going to use this forms with the form
> wizard though, particularly in the done() function.  Each form in the
> wizard contains some of the fields for the model.
>
> o = MyObject()
>
> for form in form_list:
>   f = form_list[form](instance=o)
>   f.save(commit=False)
>
> o.site = Site.objects.get_current()
> o.save()
>
> Does this look right?   Thanks for everyone's help so far!!
>
> Keith
>
> On Aug 23, 3:45 am, coulix <[EMAIL PROTECTED]> wrote:
>
> > 1. yes by overlriding the init
>
> > class myForm(forms.ModelForm):
> > def __init__(self, *args, **kwargs):
> >     super(myForm, self).__init__(*args, **kwargs)
> >     self.fields.keyOrder = ['foo', 'bar',...]
>
> > 2. in the same way you could use
> >     self.fields['foo'].label = self.fields['foo'].help_text
>
> > On Aug 22, 10:40 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > So by using a combination of fields and exclude in the Meta class, I
> > > can choose what fields I want for that form.  Nice!   :)
>
> > > Two questions though:
>
> > > 1.  Will fields be presented in the order specified in the fields
> > > tuple?
> > > 2.  In my original model/form diagram, will there be a way for me to
> > > use the model's help_text as the field label?
>
> > > Keith
>
> > > On Aug 22, 4:24 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > Ah, so I guess ModelForm will work with the FormWizard?  I'll have to
> > > > look through that documentation.  Reading documentation is easier than
> > > > pulling my hair out!  =)
>
> > > > Thanks Rajesh.
>
> > > > On Aug 22, 4:14 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi Keith,
>
> > > > > > I'm using the form wizard for a project.  All the field names in
> > > > > > models.py coincide with the field names in forms.py.  There is ONE
> > > > > > field that is consistently, yet sporadically, causing problems and I
> > > > > > cannot see why.
>
> > > > > > # models.py
> > > > > > class PurchaseApplication(BasicApplication):
> > > > > >     down_payment_assets = models.IntegerField(help_text=u'Available
> > > > > > assets for down payment')
>
> > > > > > # forms.py
> > > > > > class PurchaseForm3_yes(forms.Form):
> > > > > >     down_payment_assets = forms.IntegerField(label=u'Available 
> > > > > > assets
> > > > > > for down payment ($)')
>
> > > > > > So, as I said, all the field names for the model and the form, so to
> > > > > > save I use:
>
> > > > > > class PurchaseWizard(FormWizard):
> > > > > >     def done(self, request, form_list):
> > > > > >         data = {}
> > > > > >         for f in form_list:
> > > > > >             data.update(f.cleaned_data)
>
> > > > > >         o = PurchaseApplication()
>
> > > > > >         for f in data:
> > > > > >             o.__setattr__(f, data[f])
> > > > > >         o.site = Site.objects.get_current()
> > > > > >         o.save()
>
> > > > > > So, its only the down_payment_assets field that is causing problems,
> > > > > > but only sporadically.  The error text looks like this:
>
> > > > > > Exception Type:         OperationalError
> > > > > > Exception Value:        (1048, "Column 'down_payment_assets' cannot 
> > > > > > be
> > > > > > null")
>
> > > > > > But the request.POST vars in actally show a value!!
>
> > > > > > Variable        Value
> > > > > > 1-credit_rating         u'1'
> > > > > > 2-purchase_home_type    u'1'
> > > > > > 2-down_payment_assets   u'3'
> > > > > > <-

Re: Template path for new admin doc broken in revision 8520?

2008-08-24 Thread Ulf Kronman

Thanks Karen and Shadow,

> > > urlpatterns = patterns('',
> > >    # Admin
> > >    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> > >    (r'^admin/(.*)', admin.site.root),
> > > )

> > You need that in urls.py,  plus you need  'django.contrib.admindocs' added
> > to your INSTALLED_APPS.  There's a ticket open 
> > (http://code.djangoproject.com/ticket/8496) for getting this last bit
> > mentioned somewhere in the docs, at the moment I don't believe it's
> > mentioned anywhere.

I had the urlpatterns mentioned by Shadow already installed, but I
missed the django.contrib.admindocs app that Karen mentioned.

I have installed the admindocs app now, and admin docs are working
fine for me again.

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



Making Custom Model Methods to Work

2008-08-24 Thread rmschne

I'm new to Django, and have played with Python for a few years on and
off (not a real programmer).  I'm keen to use Django to explore some
data because of its custom data models which I plan to rely on
extensively (putting the complex code there).

Try as I might, I can't see how to get them to work.  I can get the
fields from the database to display in the html created by the
render_to_response() function, but the custom fields do not compute
and display.  They come out empty. I'm also struggling how to get
access to the data inside of Python to enable data handling by other
Python code.  For example, when I issue a "print mvalues[0]" in the
example below, I get all the fields for the first record of the
database returned, but I don't the custome fields, which I expected.
My guess is I have to some other code format, but I don't see examples
for this in "The Definitive Guide to django" by Holovaty and Kaplan-
Moss.

Example: The data model-

class Tmeetings(models.Model):
Date = models.DateTimeField(null=True, blank=True)
Speaker = models.CharField(blank=True, max_length=150)
Venue = models.CharField(blank=True, max_length=150)
Cost = models.FloatField(null=True, blank=True)

def __str__(self):
return '%s, %s' % (self.Date, self.Speaker)

def test (self):
return self.Speaker+self.Venue

class Meta:
db_table = 'tmeetings'

class Admin: pass

Example: The test template file mtg_summary.html


{{ meeting_title }} 


template: mtg_summary.html
Talk_title: {{ Talk_Title }}
Speaker: {{ Speaker }}
Speaker_Title:{{ Speaker_title }}
test: {{ test }}



Example: The Problem (code snippet)

>>>from django.shortcuts import render_to_response
>>>from soc.models import Tmeeting
>>>m_values=Members.objects.values()
>>> print render_to_response('mtg_summary.html',mvalues[0])
Content-Type: text/html; charset=utf-8




 



template: mtg_summamry.html
Talk_title: None
Speaker: George Smith
Speaker_Title: Title of the test record
test: 


>>>

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



Re: unregister in old versions of django

2008-08-24 Thread aleray

Ok, I was affraid of this. Now, I think I will attach a little
javascript code to hide what I don't want to see in the admin
interface. That's my best option.
Thank you very much for helping.
Best

On Aug 24, 2:01 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Sun, Aug 24, 2008 at 6:40 AM, aleray <[EMAIL PROTECTED]> wrote:
> > Thanks for the tip, I often forgot the existence of python doc!
> > However the thing is in the version of django I'm using there is not
> > admin.site, so no API to unregister. Like I said, the models are
> > registered with the old fashioned class admin. Then I thought I could
> > override that class Admin to define it to None, or something like
> > that, in order to cancel its registration.
>
> In that case the only option you have is to edit the Satchmo code to
> remove the admin declarations. There's no way to programmatically
> remove models from the old version of the admin.
>
> --
> "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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



No "normalize" in locale(?)

2008-08-24 Thread Malcolm Tredinnick


On Sun, 2008-08-24 at 10:14 -0700, Prairie Dogg wrote:
> I ran into this problem as well when I upgraded to the most recent
> django trunk.  I found out about it because my tests failed the
> following error:
> 
> from locale import normalize
> ImportError: cannot import name normalize

So you've kind of hijacked the original thread here, since this is a
separate issue (I've changed the topic for that reason).

What version of Python are you using on which OS/platform? The
locale.normalize method is certainly in Python 2.3 by default (and later
versions). Are you running some kind of cut-down Python install?

Regards,
Malcolm



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



url problem

2008-08-24 Thread Handle Huang
Hi all:
  I have a strange problem, In my project urls.py I define as follow:

urlpatterns = patterns('',
# Example:
# (r'^urus/', include('urus.foo.urls')),

# Uncomment this for admin:
  (r'^admin/', include('django.contrib.admin.urls')),
  (r'^site_media/(?P.*)$',
'django.views.static.serve',{'document_root': settings.STATIC_PATH}),
  (r'^accounts/login/$', 'django.contrib.auth.views.login',
{'template_name': 'personal/login.html'}),
  (r'^urus/',include('urus.app.urls')),
  (r'^app/','urus.app.views.main'),

)

then the urus/app/urls.py
urlpatterns = patterns(
(r'^$', 'urus.app.views.main'),
)

when I type http://localhost:8000/urus/ in the bowser, an error occoured as
following:

Using the URLconf defined in urus.urls, Django tried these URL patterns, in
this order:

   1. ^admin/
   2. ^site_media/(?P.*)$
   3. ^accounts/login/$
   4. ^app/

The current URL, urus/, didn't match any of these.
But if I use http://localhost:8000/app/ it works well, What's the problem?

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

<>

Re: locale name conflict (deploy issue)

2008-08-24 Thread Prairie Dogg

I ran into this problem as well when I upgraded to the most recent
django trunk.  I found out about it because my tests failed the
following error:

from locale import normalize
ImportError: cannot import name normalize

Whoever is writing the patch for  ticket #5494 (http://
code.djangoproject.com/ticket/5494)
_may_ want to take this into consideration.

On Aug 16, 7:47 am, dcoy <[EMAIL PROTECTED]> wrote:
> I figured this problem should occur in my windows environment as well.
> So I did some tests but I never got that import problem.
> In sys.path on windows the current dir is first (same on linux) so
> python should start to look in the current dir for "locale". But
> somehow the problem only arises on linux (which is running python 2.4,
> windows is running 2.5, could that be it??)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: HTML in ValidationError?

2008-08-24 Thread coan



On Aug 24, 1:18 am, "Tim Kersten" <[EMAIL PROTECTED]> wrote:
> Seehttp://www.djangoproject.com/documentation/templates/#automatic-html-...
>
> Tim ^,^

It doesn't look as the form object is subject to this automatic html
escaping, because you can pass html into the form object like this:
forms.CharField( help_text=_(u'look! html :-)'),)
When I render the form as {{form}} the html in the help text is
displayed as is and not escaped, but the html in the
forms.ValidationError is escaped.
Is there any way to control this behavior, or do I have to build the
form by hand to do it?

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



Re: Template path for new admin doc broken in revision 8520?

2008-08-24 Thread Shadow

Are yes, that too ;)

On Aug 25, 1:36 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sun, Aug 24, 2008 at 10:27 AM, Shadow <[EMAIL PROTECTED]>wrote:
>
>
>
>
>
> > Hi, not an expert!
>
> > but I think I had this same problem. The admin docs were fairly
> > recently moved into a separate app. So you'll need to update your urls
> > to something like:
>
> > --
> > from django.conf.urls.defaults import *
> > from django.contrib import admin
>
> > admin.autodiscover()
>
> > urlpatterns = patterns('',
> >    # Admin
> >    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> >    (r'^admin/(.*)', admin.site.root),
> > )
>
> > --
>
> > I think that's right?
>
> You need that in urls.py,  plus you need  'django.contrib.admindocs' added
> to your INSTALLED_APPS.  There's a ticket open 
> (http://code.djangoproject.com/ticket/8496) for getting this last bit
> mentioned somewhere in the docs, at the moment I don't believe it's
> mentioned anywhere.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sum Values in DB

2008-08-24 Thread [EMAIL PROTECTED]

That depends, if this is going to be used for single instances I would
make it a method on the model, if this is going to be used for a model
as a whole(or over a queryset), I would make it a method on a custom
manager.

On Aug 23, 6:46 pm, [EMAIL PROTECTED] wrote:
> Thanks.
>
> So if I have this:
>
> def my_custom_sql(self):
>     from django.db import connection
>     cursor = connection.cursor()
>     cursor.execute("SELECT foo FROM bar WHERE baz = %s", [self.baz])
>     row = cursor.fetchone()
>     return row
>
> Where would I put that if I intend to use the data mainly as a
> templatetag to place in various pages?
>
> On Aug 23, 1:57 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > The django ORM does not currently have native support for aggregates.
> > However there is a super promising GSOC project that was just
> > completed, and will likely go in shortly after 1.0(since we are in
> > feature freeze for now), so your options are to: a) use the patch the
> > GSOC student has here:http://code.djangoproject.com/ticket/3566, b)
> > Write the manual SQL for now and switch to that onces it's committed
> > to django proper
>
> > On Aug 23, 1:44 pm, [EMAIL PROTECTED] wrote:
>
> > > I have entries from the different users, they're entering the total
> > > number of steps they walked during a particular period of time, that
> > > they set.
>
> > > So the model is setup like
>
> > > user (fk)
> > > start_date = DateField()
> > > end_date = DateField()
> > > steps = IntergerField()
>
> > > What I want to do is on the user's detail page to sum all the entries
> > > in the db for that model where user = page_user. I know with SQL you
> > > can do a query and just SUM(steps) as total_steps WHERE user =
> > > get_user. Is there a way, better/preferred, to do it with Django?
>
> > > Also, on the site's front page, I'd like to list the top 10 total as
> > > well.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin problems :(

2008-08-24 Thread Karen Tracey
On Sun, Aug 24, 2008 at 11:33 AM, Shadow <[EMAIL PROTECTED]>wrote:

>
> But I'm not sure why the "Change password" link still isn't working.
> I'm not sure it's associated with the models?
>
> http://dpaste.com/73515/
>

That's a bug in Django.  I've opened a ticket with a patch to get it fixed:

http://code.djangoproject.com/ticket/8520

Karen

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



Re: Showing staff users from another model

2008-08-24 Thread Mark

> > Are there better ways to do this?
> Yes.
> owned_by = models.ForeignKey(User, limit_choices_to={ 'is_staff': True
> })
> The model documentation covers the 'limit_choices_to' argument, as
> well as the proper syntax for setting up foreign keys.

I agree, there is plenty of documentation, I'll get into it better as I 
progress. Thanks for the help on this one 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin: Showing attributes in drop list

2008-08-24 Thread Gerard Petersen

Erik,

Marvelous! I saw this in the tutorial but I missed the part where admin uses it 
as well.

Thanx and greetz!

Gerard.

Erik Allik wrote:
> You could define the __unicode__ (or __str__) method for the Customer  
> class:
> 
> class Customer(models.Model):
>  
> 
>  def __unicode__(self):
>  return '%s %s' % (self.first_name, self.last_name)
> 
> 
> On 24.08.2008, at 15:22, Gerard Petersen wrote:
> 
>> Hi All,
>>
>> With some relational models in place I use droplists in the admin  
>> interface to fill my fields. There's a 1-to-n relation between  
>> customer and project that the admin module respects with a droplist.
>>
>> The problem is that the droplist shows "customer object" for all  
>> entries instead of a name (or field from the customer model)
>>
>> This clarifies: http://www.gp-net.nl/userdl/screens/screen1.png
>>
>> Is there a directive to specify this?
>>
>> Thanx a lot.
>>
>> Gerard.
>>
>> -- 
>> urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }
>>
>>
>>
> 
> 
> > 

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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



Re: url problem

2008-08-24 Thread Handle Huang
thanks for your replay.
but my problem is still here, the include function seems not work( I use the
last svn version of Django ). And you say why I having serveral different
URLS pointing to the same view is that the inculde function not work, I have
to point it directly (just to test if the view work well).

2008/8/24 timc3 <[EMAIL PROTECTED]>

>
> It looks like you are getting a little confused. For a start you don't
> match anything for just http://localhost:8000/
>
> (r'^$', 'urus.app.views.main')
>
> Don't know whether thats on purpose or not. anyway.
>
> > urlpatterns = patterns('',
> > # Example:
> > # (r'^urus/', include('urus.foo.urls')),
> >
> > # Uncomment this for admin:
> >   (r'^admin/', include('django.contrib.admin.urls')),
> >   (r'^site_media/(?P.*)$',
> > 'django.views.static.serve',{'document_root': settings.STATIC_PATH}),
> >   (r'^accounts/login/$', 'django.contrib.auth.views.login',
> > {'template_name': 'personal/login.html'}),
> >   (r'^urus/',include('urus.app.urls')),
> >   (r'^app/','urus.app.views.main'),
> >
> > )
> >
> > then the urus/app/urls.py
> > urlpatterns = patterns(
> > (r'^$', 'urus.app.views.main'),
> > )
>
> In your first urls.py you seem to be trying to include at urus/app/
> urls.py but I would use the following in there:
>
> urlpatterns = patterns('',
>url(r'^$', 'urus.app.views.main', name="main"),
> )
>
> Then you get named URLS which will be helpful when you go on
> developing.
>
> Try that and see if it works but I would also try and rethink why you
> are having several different URLS pointing to the same view.
> >
>

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



Re: Module not callable (Practical Django Projects)

2008-08-24 Thread Christian Joergensen

marsii wrote:
> I working whit the book Practical Django Project and have a problem
> with th weblog example.
> 
> (I have Django revision 8511.
> 
> I got the following error when I try to add an entry:
> ---
> TypeError at /admin/coltrane/entry/add/
> 
> 'module' object is not callable

> from markdown import markdown

[...]

> self.body_html = markdown(self.body) <-- LINE 76 ERROR

The imported name 'markdown' should be a function, yet python thinks 
it's a module. What is it?

Try importing markdown and running the above snippet outside of django 
in a python shell. Does that work?

Regards,
   Christian

-- 
Christian Joergensen
http://www.technobabble.dk

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



Re: Template path for new admin doc broken in revision 8520?

2008-08-24 Thread Karen Tracey
On Sun, Aug 24, 2008 at 10:27 AM, Shadow <[EMAIL PROTECTED]>wrote:

>
> Hi, not an expert!
>
> but I think I had this same problem. The admin docs were fairly
> recently moved into a separate app. So you'll need to update your urls
> to something like:
>
> --
> from django.conf.urls.defaults import *
> from django.contrib import admin
>
> admin.autodiscover()
>
> urlpatterns = patterns('',
># Admin
>(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>(r'^admin/(.*)', admin.site.root),
> )
>
> --
>
> I think that's right?
>

You need that in urls.py,  plus you need  'django.contrib.admindocs' added
to your INSTALLED_APPS.  There's a ticket open (
http://code.djangoproject.com/ticket/8496) for getting this last bit
mentioned somewhere in the docs, at the moment I don't believe it's
mentioned anywhere.

Karen

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



Re: Admin problems :(

2008-08-24 Thread Shadow

sorry,

that was a "ah... (dam, silly me)"
not a "ah... (Erik is strange :s)"
;)

So I've managed to get it to work now :D

But I'm not sure why the "Change password" link still isn't working.
I'm not sure it's associated with the models?

http://dpaste.com/73515/

Cheers

On Aug 25, 1:17 am, Steve  Potter <[EMAIL PROTECTED]> wrote:
> What Erik is saying is that in recent versions of Django you no longer
> use the same syntax to activate the admin.  This happened when the
> newforms-admin branch was merged.
>
> Steve
>
> On Aug 24, 10:13 am, Shadow <[EMAIL PROTECTED]> wrote:
>
> > ah... :P thanks
>
> > But what about the "Change password" link?
>
> > Not that it really matters... but wondering if its another thing I'm
> > doing wrong?
>
> > cheers
>
> > On Aug 25, 12:53 am, Erik Allik <[EMAIL PROTECTED]> wrote:
>
> > > You should consult the documentation (not djangobook.com) about how
> > > the admin site should be set up.
>
> > > Erik
>
> > > On 24.08.2008, at 17:20, Shadow wrote:
>
> > > > Hi, I'm having some issues with the admin app (using svn rev #8520).
>
> > > > 1) I can't get my apps models to show (logged in as superuser).
>
> > > > I've added:
> > > > "
> > > > class Admin:
> > > >    pass
> > > > "
> > > > to each one with no affect. But I can still see them in user
> > > > permissions?!
>
> > > > 2) The "Change password" link gives the following:
>
> > > >http://dpaste.com/73515/
>
> > > > Any help would be much appreciated,
>
> > > > 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin problems :(

2008-08-24 Thread Steve Potter

What Erik is saying is that in recent versions of Django you no longer
use the same syntax to activate the admin.  This happened when the
newforms-admin branch was merged.

Steve


On Aug 24, 10:13 am, Shadow <[EMAIL PROTECTED]> wrote:
> ah... :P thanks
>
> But what about the "Change password" link?
>
> Not that it really matters... but wondering if its another thing I'm
> doing wrong?
>
> cheers
>
> On Aug 25, 12:53 am, Erik Allik <[EMAIL PROTECTED]> wrote:
>
> > You should consult the documentation (not djangobook.com) about how
> > the admin site should be set up.
>
> > Erik
>
> > On 24.08.2008, at 17:20, Shadow wrote:
>
> > > Hi, I'm having some issues with the admin app (using svn rev #8520).
>
> > > 1) I can't get my apps models to show (logged in as superuser).
>
> > > I've added:
> > > "
> > > class Admin:
> > >pass
> > > "
> > > to each one with no affect. But I can still see them in user
> > > permissions?!
>
> > > 2) The "Change password" link gives the following:
>
> > >http://dpaste.com/73515/
>
> > > Any help would be much appreciated,
>
> > > 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Module not callable (Practical Django Projects)

2008-08-24 Thread Cubells



En/na marsii ha escrit:
> excerp_html = models.TextField(editable=False, blank=True)
>   
_
 ↓
excerpt_html = models.TextField(editable=False, blank=True)


You have only that mistake in the code you've attached...

Your models.py works on my system.

Cheers...

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



Re: Admin problems :(

2008-08-24 Thread Shadow

ah... :P thanks

But what about the "Change password" link?

Not that it really matters... but wondering if its another thing I'm
doing wrong?

cheers

On Aug 25, 12:53 am, Erik Allik <[EMAIL PROTECTED]> wrote:
> You should consult the documentation (not djangobook.com) about how  
> the admin site should be set up.
>
> Erik
>
> On 24.08.2008, at 17:20, Shadow wrote:
>
>
>
> > Hi, I'm having some issues with the admin app (using svn rev #8520).
>
> > 1) I can't get my apps models to show (logged in as superuser).
>
> > I've added:
> > "
> > class Admin:
> >    pass
> > "
> > to each one with no affect. But I can still see them in user
> > permissions?!
>
> > 2) The "Change password" link gives the following:
>
> >http://dpaste.com/73515/
>
> > Any help would be much appreciated,
>
> > 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ANN: django-morsels

2008-08-24 Thread Richard Ward

I too am unable to display the morsels.

I believe it is install correctly.

I can add morsels.
The morsel tag generates no error when the template is generated.

This is my context setting:
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.request",
)

I do not know how to debug the installation.


Thanks
Richard

On Sat, Aug 23, 2008 at 12:04 AM, Itai Tavor <[EMAIL PROTECTED]> wrote:
>
> Apologies to everyone who got bit by this. I updated the INSTALL
> instructions with the requirement of adding 'request' to the context.
>
> Itai
>
>
> On 23/08/2008, at 6:26 AM, lingrlongr wrote:
>
>>
>> Recommended fix @ http://code.google.com/p/django-morsels/issues/detail?id=1
>>
>> On Aug 22, 2:51 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>>> If I change my view to this, it works:
>>>
>>> # views.py
>>> def myview(request):
>>> return object_list(
>>> request,
>>> queryset=Stuff.objects.all(),
>>> extra_context = {
>>>   'request': request,
>>> }
>>> )
>>>
>>> Is this supposed to be the right way to use morsels?
>>>
>>> Keith
>>>
>>> On Aug 22, 12:50 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>>>
 I can't get this to work at all.  Seems to bomb here:
>>>
 class MorselManager(models.Manager):
 def get_for_current(self, context, name, inherit=False):
 if not context.has_key('request'):  <-- key never
 seems to exist
 return None
>>>
 I have a morsel defined with a URL of "/mypage/".
>>>
 # urls.py
 (r'^mypage/$', myview),
>>>
 # views.py
 def myview(request):
 return object_list(
 request,
 queryset=Stuff.objects.all(),
 )
>>>
 I have this in my template:
 {% load morsel_tags %}
 {% morsel %}
>>>
 Am I missing something?
>>>
 Keith
>>>
 On Aug 21, 5:19 am, Itai Tavor <[EMAIL PROTECTED]> wrote:
>>>
> At first glance (and, quite possibly, second and third) django-
> morsels
> might look like a clone of django-chunks 
> (http://code.google.com/p/django-chunks/
> ). Both apps attempt to solve the same problem, and in fact, I
> wrote
> this app after seeing and trying out django-chunks (so thanks,
> Clint
> Ecker!). But the feature set and functions differ enough to justify
> the existence of a second implementation.
>>>
> These apps provide a way to store partial page content in the
> database, and manage it in the admin app, when this content is
> integrated in pages that also contain dynamic features. I always
> dealt
> with this using FlatPages and templatetags (custom-written for each
> new project) that included them in templates. Looking at django-
> chunks, I realized a few things:
>>>
> 1) The templatetags I've already written worked better, for my own
> use, than the key-based approach of django-chunks.
> 2) Using a dedicated model for this type of content made a lot of
> sense.
> 3) Merging this model and all those custom templatetags I already
> had
> into a reusable app also made sense.
> 4) I needed a name that didn't have "chunks" in it.
>>>
> The main features of django-morselsare:
>>>
> * Each morsel can be tied to a site page by specifying the page's
> URL
> in the morsel.
>>>
> * Differentmorselscan be used in the same page by adding arbitrary
> names to the morsel's URL.
>>>
> *Morselscan be inherited from higher levels in the site's URL
> hierarchy. This allows the content of a single morsel to be
> displayed
> in a whole site section, while being overriden by othermorselsin
> specific pages within the section.
>>>
> *Morselscan include an optional title, which may be used to
> identify
> the morsel and may also be displayed in templates using the morsel.
>>>
> * Two custom templatetags - morsel and withmorsel - allowmorselsto
> be used in various, flexible ways.
>>>
> *Morselscan be locked, which prevents them from being deleted. This
> is intended to prevent accidental deletion of requiredmorsels, as
> having to explicitly unlock a morsel before deleting it should make
> the user think twice about it.
>>>
> * If the typogrify app (http://code.google.com/p/typogrify/) is
> installed, morsel content will be typogrified when rendered using
> the
> morsel templatetag.
>>>
> You can find django-morselsat  >.
>>>
> Itai
>> >
>>
>
>
> >
>

--~--~-~--~~~---~--~~
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, 

Re: Module not callable (Practical Django Projects)

2008-08-24 Thread Cubells



En/na marsii ha escrit:
> Hi!
> I working whit the book Practical Django Project and have a problem
> with th weblog example.
>
> (I have Django revision 8511.
>
> I got the following error when I try to add an entry:
> ---
> TypeError at /admin/coltrane/entry/add/
>
> 'module' object is not callable
>
> Request Method:   POST
> Request URL:  http://127.0.0.1:8000/admin/coltrane/entry/add/
> Exception Type:   TypeError
> Exception Value:
>
> 'module' object is not callable
>
> Exception Location:   /home/markku/django/practical_djproj/coltrane/
> models.py in save, line 76
> Python Executable:/usr/bin/python
> Python Version:   2.5.2
> ---
>
> copy of my models.py (error line 76 is marked):
>
> --
>   

I have the same code, I think..., and I doesn't get that error.

Try to put comments in the whole method save() or in the line 76 so that
we can see where is the problem...

Cheers...



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



Re: Admin problems :(

2008-08-24 Thread Erik Allik

You should consult the documentation (not djangobook.com) about how  
the admin site should be set up.

Erik

On 24.08.2008, at 17:20, Shadow wrote:

>
> Hi, I'm having some issues with the admin app (using svn rev #8520).
>
> 1) I can't get my apps models to show (logged in as superuser).
>
> I've added:
> "
> class Admin:
>pass
> "
> to each one with no affect. But I can still see them in user
> permissions?!
>
> 2) The "Change password" link gives the following:
>
> http://dpaste.com/73515/
>
>
> Any help would be much appreciated,
>
> 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin: Showing attributes in drop list

2008-08-24 Thread Erik Allik

You could define the __unicode__ (or __str__) method for the Customer  
class:

class Customer(models.Model):
 

 def __unicode__(self):
 return '%s %s' % (self.first_name, self.last_name)


On 24.08.2008, at 15:22, Gerard Petersen wrote:

>
> Hi All,
>
> With some relational models in place I use droplists in the admin  
> interface to fill my fields. There's a 1-to-n relation between  
> customer and project that the admin module respects with a droplist.
>
> The problem is that the droplist shows "customer object" for all  
> entries instead of a name (or field from the customer model)
>
> This clarifies: http://www.gp-net.nl/userdl/screens/screen1.png
>
> Is there a directive to specify this?
>
> Thanx a lot.
>
> Gerard.
>
> -- 
> urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }
>
>
>
> >


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



Re: Showing staff users from another model

2008-08-24 Thread James Bennett

On Sun, Aug 24, 2008 at 7:26 AM, Mark <[EMAIL PROTECTED]> wrote:
> Are there better ways to do this?

Yes.

from django.db import models
from django.contrib.auth.models import User

class Car(models.Model):
brand = models.CharField(max_length=20)
color = models.CharField(max_length=10)
owned_by = models.ForeignKey(User, limit_choices_to={ 'is_staff': True })

The model documentation covers the 'limit_choices_to' argument, as
well as the proper syntax for setting up foreign keys.


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



Re: Write Caching

2008-08-24 Thread Steve Potter

This is an interesting idea that I wouldn't have thought of.

However, I'm not sure that every select is equal to a display.  For
example if I load the objects via the admin.

Also, I am not sure as there would be a huge gain as the same number
or queries would still be executed, however in this case the database
is initiating some of them instead of Django.


Steve


On Aug 24, 5:59 am, TiNo <[EMAIL PROTECTED]> wrote:
> Maybe this could be a 
> solution:http://www.stardata.it/articoli_en/triggers_on_select_articoli_en.html
>
> No idea how much overhead that would create though.
>
> On Sun, Aug 24, 2008 at 5:43 AM, Steve Potter <[EMAIL PROTECTED]>wrote:
>
>
>
> > I am working on a project that involves logging every time an object
> > is displayed, and I can have anywhere from tens to hundreds of objects
> > displayed per page.
>
> > So needless to say I can quickly be generating very large numbers of
> > queries to the database to log all of these displays.
>
> > What I am looking for is some method of write caching these logs so I
> > only write to the database every 'n' times the object is displayed, or
> > when the cache gets too old.
>
> > Has anyone done anything like this?
>
> > Maybe someone just has a better suggestion for how to log this data
> > with less DB queries?
>
> > Thanks,
>
> > Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Admin problems :(

2008-08-24 Thread Shadow

Hi, I'm having some issues with the admin app (using svn rev #8520).

1) I can't get my apps models to show (logged in as superuser).

I've added:
"
class Admin:
pass
"
to each one with no affect. But I can still see them in user
permissions?!

2) The "Change password" link gives the following:

http://dpaste.com/73515/


Any help would be much appreciated,

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



Re: First App: devel server - can't establish a connection to 127.0.0.1

2008-08-24 Thread Robert Erbaron

> Each time what?  It's a development server, expected to be used as you
> develop your code.  It's pretty good but not perfect about re-loading itself

I typically do a long-term development session for a day or two...
then go off an do another project for a while (a couple days.) So I'd
shut everything down.

At this advanced age, I'll likely forget to start the dev server up
again when I begin another dev session, and then post a dozen messages
pretty much like the one that started this thread. :) I would guess
I'd get the hang of it by, oh, December.

It's also just 'icky' having a terminal window open, just hanging
here. 'spose I can just move it to another panel, huh?

Maybe when I finish the Dj book I'll be able to complete my
Apache/mod_python config. (I started it last night... bad idea,
configuring something new late Sat night.)

Thx all!

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



Showing staff users from another model

2008-08-24 Thread Mark

This class is only for the admin page. In the following model I'd like to make 
owned_by a dropdown box showing staff users.


from django.db import models
from django.contrib import admin
from django.contrib import auth

class Car(models.Model):
brand = models.CharField(max_length=20)
color = models.CharField(max_length=10)
owned_by = models.ForeignKey(something)

How can I achieve this?

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



Template path for new admin doc broken in revision 8520?

2008-08-24 Thread Ulf Kronman

Hi all,
some time ago, I noticed that I got an error when I clicked on the
link to Documentation in the Django admin.

I also saw that admin docs had been moved from
/django/contrib/admin/templates/admin_doc/
to
/django/contrib/admindocs/templates/admin_doc/
but some part of my Django installation was still trying to get a
template from /django/contrib/admin/templates/admin_doc/

Today, I installed revision 8520 and notice that the error is still
there. This is what I get when I click on the Documentation link in my
Django admin (in my case leading to http://localhost/vr/admin/doc/):


TemplateDoesNotExist at /vr/admin/doc/

admin_doc/index.html

Request Method: GET
Request URL:http://localhost/vr/admin/doc/
Exception Type: TemplateDoesNotExist
Exception Value:

admin_doc/index.html

Exception Location: /Library/Frameworks/Python.framework/Versions/2.5/
lib/python2.5/site-packages/django/template/loader.py in
find_template_source, line 73
-

And in the report for template searching I see the following:

Using loader
django.template.loaders.app_directories.load_template_source:

* /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/contrib/admin/templates/admin_doc/index.html
(File does not exist)


As you see some part of the code is looking for the admin index
template in:
/django/contrib/admin/templates/admin_doc/index.html
instead of:
/django/contrib/admindocs/templates/admin_doc/index.html

Am I alone with this problem?

Traceback listed below.

Regards
Ulf

---
Environment:

Request Method: GET
Request URL: http://localhost/vr/admin/doc/
Django Version: 1.0-beta_1-SVN-8520
Python Version: 2.5.1
Installed Applications:
['vr.isi',
 'vr.org',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')

Template Loader Error:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.load_template_source:
/var/local/web/vr/templates/admin_doc/index.html (File does not exist)
/Users/ulf/web/vr/templates/admin_doc/index.html (File does not exist)
Using loader
django.template.loaders.app_directories.load_template_source:
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
packages/django/contrib/admin/templates/admin_doc/index.html (File
does not exist)

Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/core/handlers/base.py" in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/contrib/admin/views/decorators.py" in _checklogin
  61. return view_func(request, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/contrib/admindocs/views.py" in doc_index
  29. }, context_instance=RequestContext(request))
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/shortcuts/__init__.py" in render_to_response
  18. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/template/loader.py" in render_to_string
  102. t = get_template(template_name)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/template/loader.py" in get_template
  80. source, origin = find_template_source(template_name)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/template/loader.py" in find_template_source
  73. raise TemplateDoesNotExist, name

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



Re: HTML in ValidationError?

2008-08-24 Thread coan



On Aug 24, 2:13 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Sun, Aug 24, 2008 at 7:07 AM, coan <[EMAIL PROTECTED]> wrote:
> > I wonder why custom error messages are considered more dangerous than
> > the help_text in the same form?
>
> Because people do things like this:

>             raise forms.ValidationError(u"Your submission -- %s -- was
> not valid" % self.cleaned_data["some_field"])

> Which, of course, is a gaping cross-site-scripting hole.
>

Ah - ok - that actually makes perfect sense :-)

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



Re: unregister in old versions of django

2008-08-24 Thread James Bennett

On Sun, Aug 24, 2008 at 6:23 AM, James Bennett <[EMAIL PROTECTED]> wrote:
> Which shows you full API documentation for the AdminSite class,
> listing all of its methods and what they do, including this one:

(and of course if you have DJANGO_SETTINGS_MODULE set properly,
there's also the command-line 'pydoc
django.contrib.admin.sites.AdminSite')


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



Techniques to store the confidential matters

2008-08-24 Thread deepa

Techniques to store the confidential matters

Workflow process rules
http://www.freewebs.com/businesprocs/

Database management
http://www.freewebs.com/businesprocs/

BPMN process modeler
http://www.freewebs.com/businesprocs/

Prozessautomatisierung
http://www.freewebs.com/businesprocs/

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



Re: Showing staff users from another model

2008-08-24 Thread Mark

I played for a while and this is my result:

StaffSeq = tuple((str(i),)*2 for i in \ 
auth.models.User.objects.filter(is_staff=True))

(..)
models.CharField(max_length=30,choices=StaffSeq)

Are there better ways to do this?

Mark

On Sunday 24 August 2008 13:18:42 Mark wrote:
> This class is only for the admin page. In the following model I'd like to
> make owned_by a dropdown box showing staff users.
>
>
> from django.db import models
> from django.contrib import admin
> from django.contrib import auth
>
> class Car(models.Model):
>   brand = models.CharField(max_length=20)
>   color = models.CharField(max_length=10)
>   owned_by = models.ForeignKey(something)
>
> How can I achieve this?
>
> 


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



Admin: Showing attributes in drop list

2008-08-24 Thread Gerard Petersen

Hi All,

With some relational models in place I use droplists in the admin interface to 
fill my fields. There's a 1-to-n relation between customer and project that the 
admin module respects with a droplist.

The problem is that the droplist shows "customer object" for all entries 
instead of a name (or field from the customer model)

This clarifies: http://www.gp-net.nl/userdl/screens/screen1.png

Is there a directive to specify this?

Thanx a lot.

Gerard.

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }



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



Re: Making Custom Model Methods to Work

2008-08-24 Thread rmschne

Daniel

You helped a lot.  You are right that my code wasn't clear.  I only
extracted snipets and forgot bits, e.g. talk _title and speaker_title
which are in the model but not in what I reported.  Frankly, all I'm
trying to do right now is experiment to learn how this works.
Eventually, I have a couple of projects in mind, the first being
something to generate HTML files for a web site based on content in a
database.

 You are right, the root cause is that I was not yet understanding how
to access the models and part of my learning is deaing with ojects in
Python.  With your key help, it now works and I see the light.

I learned:

1.  create the objects (one record from the database table) by
my_objectname=[Classname].objects.all()[N] where N is the record
number.
2.  when change the data model, I have to restart the python shell ...
on the to-do list is to learn how to redefine the data model.
3.  in the template, use the objectname in the double brackets, e.g.
{{ my_objectname.date }} and {{ my_objectname.test }}
4.  calling render_to_response is differnt than I thought!
print render_to_response('mtg_summary.html',{'my_meeting':my_meeting})

Question: in the context of this example, in
{'my_meeting':my_meeting}), what are these two things opposite of the
colon?

> It's not at all clear from the code what you're trying to do.
> talk_title and speaker_title aren't defined anywhere in the code
> you've given us, but I'm not even sure if those are the 'custom
> fields' you're referring to.
>
> What's more, the code you've given us would not be capable of
> producing the output you've shown, so this clearly isn't the actual
> code. We would need to see the actual view and template code - it's
> best if you paste it at dpaste.com and give us a link.
>
> If by 'custom fields' you mean methods on the model, like your test()
> example, you wouldn't expect the values() method to show them. It will
> only show the actual model fields.
>
> I think you're misunderstanding how to access models in your code and
> templates. values() isn't the normal way of doing it - really, you
> just want to be passing an instance of Tmeeting to your template and
> then using normal dot notation to access the values.
>
> For example:
>
> my_meeting = Tmeeting.objects.all()[0]
> print my_meeting.date
> print my_meeting.speaker
> print my_meeting.test()
> print render_to_response('mtg_summary.html',
> {'my_meeting':my_meeting})
>
> and in the template:
> Talk_title: {{ my_meeting.talk }}
> Speaker: {{ my_meeting.speaker }}
> Speaker_Title:{{ my_meeting.speaker_title }} {# where is this
> coming from? #}
> test: {{ my_meeting.test }}
>
> etc.
>
> (Note that the convention is to have lower case names for model fields
> and methods.)
>
> --
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: HTML in ValidationError?

2008-08-24 Thread James Bennett

On Sun, Aug 24, 2008 at 7:07 AM, coan <[EMAIL PROTECTED]> wrote:
> I wonder why custom error messages are considered more dangerous than
> the help_text in the same form?

Because people do things like this:

class HackMySiteForm(forms.Form):
some_text = forms.CharField(max_length=255)

def clean_some_text(self):
if not some_validation_check():
raise forms.ValidationError(u"Your submission -- %s -- was
not valid" % self.cleaned_data["some_field"])
return self.cleaned_data['some_field']

Which, of course, is a gaping cross-site-scripting hole.


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



Re: HTML in ValidationError?

2008-08-24 Thread coan

On Aug 24, 12:25 pm, "Tim Kersten" <[EMAIL PROTECTED]> wrote:
> Ah, I see what you mean. A quick glance 
> athttp://code.djangoproject.com/changeset/4544
> tell's me this is not possible to do so inside the error message, for
> good reasons. To style your message take a look at
>
> http://www.djangoproject.com/documentation/forms/#how-errors-are-disp...
> andhttp://www.djangoproject.com/documentation/forms/#customizing-the-err...
>
> Hope this helps,

Ok thanks! - this clears things up at least! :-)
I see a lot of good reasons for autoescaping all error messages, but
it should be possible to override.

I'd like to include a error message in my form with a link to a help
page.
I could make my own class for displaying errors, but the error
messages are already escaped when I get them. I would  have to
manually unescape the error message again, perhaps like this:

class HtmlErrorList(ErrorList):
def __unicode__(self):
return u'%s' % ''.join([u'%s' % unescape(e)
for e in self])

This however would cause all error messages in the form to be
unescaped, something I wouldn't want.

I wonder why custom error messages are considered more dangerous than
the help_text in the same form?

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



Re: unregister in old versions of django

2008-08-24 Thread James Bennett

On Sun, Aug 24, 2008 at 6:40 AM, aleray <[EMAIL PROTECTED]> wrote:
> Thanks for the tip, I often forgot the existence of python doc!
> However the thing is in the version of django I'm using there is not
> admin.site, so no API to unregister. Like I said, the models are
> registered with the old fashioned class admin. Then I thought I could
> override that class Admin to define it to None, or something like
> that, in order to cancel its registration.

In that case the only option you have is to edit the Satchmo code to
remove the admin declarations. There's no way to programmatically
remove models from the old version of the admin.


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



Module not callable (Practical Django Projects)

2008-08-24 Thread marsii

Hi!
I working whit the book Practical Django Project and have a problem
with th weblog example.

(I have Django revision 8511.

I got the following error when I try to add an entry:
---
TypeError at /admin/coltrane/entry/add/

'module' object is not callable

Request Method: POST
Request URL:http://127.0.0.1:8000/admin/coltrane/entry/add/
Exception Type: TypeError
Exception Value:

'module' object is not callable

Exception Location: /home/markku/django/practical_djproj/coltrane/
models.py in save, line 76
Python Executable:  /usr/bin/python
Python Version: 2.5.2
---

copy of my models.py (error line 76 is marked):

---
import datetime
from django.db import models
from django.contrib.auth.models import User
from django.contrib import admin
from markdown import markdown
from tagging.fields import TagField

class Category(models.Model):
description = models.TextField()
slug = models.SlugField(unique=True, help_text="Must be unique")

title = models.CharField(max_length=250, help_text='Max 250
chars')

class Meta:
ordering = ['title']
verbose_name_plural = "Categories"

def __unicode__(self):
return self.title

def get_absolute_url(self):
return "/categories/%s/" % self.slug

class CategoryAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}

admin.site.register(Category, CategoryAdmin)

class Entry(models.Model):

LIVE_STATUS = 1
DRAFT_STATUS = 2
HIDDEN_STATUS = 3
STATUS_CHOICES = (
(LIVE_STATUS, 'Live'),
(DRAFT_STATUS, 'Draft'),
(HIDDEN_STATUS, 'Hidden'),
)

# Core fields
title = models.CharField(max_length=250, help_text="Max 250
chars")
excerpt = models.TextField(blank=True, help_text="Short sum.
Optional")

body = models.TextField()
pub_date = models.DateTimeField(default=datetime.datetime.now)

# Fields to store genereted HTML
body_html = models.TextField(editable=False, blank=True)
excerp_html = models.TextField(editable=False, blank=True)

# Metadata
author = models.ForeignKey(User)
enable_comments = models.BooleanField(default=True)
featured = models.BooleanField(default=False)
slug = models.SlugField(unique_for_date='pub_date',
help_text="Auto")
status = models.IntegerField(choices=STATUS_CHOICES,
 default=LIVE_STATUS,
 help_text="Only LIVE will be
pub.displayed")

# Categorization
categories = models.ManyToManyField(Category)
tags = TagField(help_text="Separate tags with spaces")

class Meta:
ordering = ['-pub_date']
verbose_name_plural = "Entries"

def __unicode__(self):
return self.title

def save(self):
self.body_html = markdown(self.body) <-- LINE 76 ERROR
if self.excerpt:
self.excerpt_html = markdown(self.excerpt)
super(Entry, self).save()

def get_absolute_url(self):
return "/weblog/%s/%s/" % (self.pub_date.strftime("%Y/%b/
%d").lower(),
   self.slug)

class EntryAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}

admin.site.register(Entry, EntryAdmin)
-

Do anybody know what the problem is?


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



Re: unregister in old versions of django

2008-08-24 Thread aleray

Thanks for the tip, I often forgot the existence of python doc!
However the thing is in the version of django I'm using there is not
admin.site, so no API to unregister. Like I said, the models are
registered with the old fashioned class admin. Then I thought I could
override that class Admin to define it to None, or something like
that, in order to cancel its registration.
What do you think about ? If I can do like this, any snippet of python
would be useful! Otherwhise I'm open to every solution!
Best

On Aug 24, 1:25 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Sun, Aug 24, 2008 at 6:23 AM, James Bennett <[EMAIL PROTECTED]> wrote:
> > Which shows you full API documentation for the AdminSite class,
> > listing all of its methods and what they do, including this one:
>
> (and of course if you have DJANGO_SETTINGS_MODULE set properly,
> there's also the command-line 'pydoc
> django.contrib.admin.sites.AdminSite')
>
> --
> "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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



First App: devel server - can't establish a connection to 127.0.0.1

2008-08-24 Thread Rob

Running Fedora and Python 2.4. Working my way through the first
installation... I've successfully run "python manage.py runserver" and
gotten the expected

  Validating models...
  0 errors found
  Django version 1.0-beta_1-SVN-unknown, using settings 'dja.settings'
  Development server is running at http://127.0.0.1:8000/

response. Hoo-ray!

Next, in "Writing your first app..." it says, "Now that the server’s
running, visit http://127.0.0.1:8000/ with your Web browser. You’ll
see a “Welcome to Django” page, in pleasant, light-blue pastel. It
worked!"

Not for me! :( I get a "Unable able to connect. Firefox cannot
establish a connection to the server at 127.0.0.1:8000" message. I've
searched the group messages and there are only a handful of
(unrelated) messages about this.

I've checked my /etc/hosts to make sure that 127.0.0.1 is defined
(initially, it wasn't, only ::1.) I can navigate to http://127.0.0.1
and get a dummy index.html page I've set up. Since the manage.py
runserver command worked, it would seem that the development server is
running. But no joy in the browser.

If it's any help, I'd actually rather be running Apache +
mod_python... you know, make your development and production
environments as similar as possible...

Any ideas?

r.

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



Re: unregister in old versions of django

2008-08-24 Thread James Bennett

On Sun, Aug 24, 2008 at 5:04 AM, aleray <[EMAIL PROTECTED]> wrote:
> Really no idea ?

Well, you could always do the following:

>>> from django.contrib import admin
>>> help(admin.site)

Which shows you full API documentation for the AdminSite class,
listing all of its methods and what they do, including this one:

unregister(self, model_or_iterable)
 |  Unregisters the given model(s).
 |
 |  If a model isn't already registered, this will raise NotRegistered.


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



Re: unregister in old versions of django

2008-08-24 Thread aleray

Really no idea ?

On Aug 22, 11:01 pm, aleray <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm working with django revision 7513 and satchmo 0.7 because I heard
> they were doing nice job together. Howerver I would like to unregister
> some models in the admin interface, but I can't (and don't want to)
> touch to satchmo code. In satchmo 0.7.0, the models are registered
> with the admin class; is there a way to "unregister" them?
>
> Best
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Processing multiple forms in same page

2008-08-24 Thread Daniel Roseman

On Aug 24, 1:51 am, Rodolfo <[EMAIL PROTECTED]> wrote:
> Just for curiosity, why would one have two forms in a single page?
> I don't think it is possible to submit the two in a shot.
>
> Maybe only of them is intended to be filled per access?
>
> []s
>
> Rodolfo

You can't have two HTML forms per page, but you can have two *Django*
forms. You'd wrap them both in a single ... element, and
Django will sort out which fields belong where according to the
prefix. So yes, you can submit them both at the same time.
--
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: HTML in ValidationError?

2008-08-24 Thread Tim Kersten

Ah, I see what you mean. A quick glance at
http://code.djangoproject.com/changeset/4544
tell's me this is not possible to do so inside the error message, for
good reasons. To style your message take a look at

http://www.djangoproject.com/documentation/forms/#how-errors-are-displayed
and
http://www.djangoproject.com/documentation/forms/#customizing-the-error-list-format

Hope this helps,

Tim ^,^




On Sun, Aug 24, 2008 at 8:06 AM, coan <[EMAIL PROTECTED]> wrote:
>
>
>
> On Aug 24, 1:18 am, "Tim Kersten" <[EMAIL PROTECTED]> wrote:
>> Seehttp://www.djangoproject.com/documentation/templates/#automatic-html-...
>>
>> Tim ^,^
>
> It doesn't look as the form object is subject to this automatic html
> escaping, because you can pass html into the form object like this:
> forms.CharField( help_text=_(u'look! html :-)'),)
> When I render the form as {{form}} the html in the help text is
> displayed as is and not escaped, but the html in the
> forms.ValidationError is escaped.
> Is there any way to control this behavior, or do I have to build the
> form by hand to do it?
>
> >
>

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



Re: Making Custom Model Methods to Work

2008-08-24 Thread Daniel Roseman

On Aug 24, 7:38 am, rmschne <[EMAIL PROTECTED]> wrote:
> I'm new to Django, and have played with Python for a few years on and
> off (not a real programmer).  I'm keen to use Django to explore some
> data because of its custom data models which I plan to rely on
> extensively (putting the complex code there).
>
> Try as I might, I can't see how to get them to work.  I can get the
> fields from the database to display in the html created by the
> render_to_response() function, but the custom fields do not compute
> and display.  They come out empty. I'm also struggling how to get
> access to the data inside of Python to enable data handling by other
> Python code.  For example, when I issue a "print mvalues[0]" in the
> example below, I get all the fields for the first record of the
> database returned, but I don't the custome fields, which I expected.
> My guess is I have to some other code format, but I don't see examples
> for this in "The Definitive Guide to django" by Holovaty and Kaplan-
> Moss.
>
> Example: The data model-
>
> class Tmeetings(models.Model):
>         Date = models.DateTimeField(null=True, blank=True)
>         Speaker = models.CharField(blank=True, max_length=150)
>         Venue = models.CharField(blank=True, max_length=150)
>         Cost = models.FloatField(null=True, blank=True)
>
>         def __str__(self):
>                 return '%s, %s' % (self.Date, self.Speaker)
>
>         def test (self):
>                 return self.Speaker+self.Venue
>
>         class Meta:
>                 db_table = 'tmeetings'
>
>         class Admin: pass
>
> Example: The test template file mtg_summary.html
>
>  "http://www.w3.org/TR/html4/loose.dtd;>
> {{ meeting_title }}  equiv="Content-Type" content="text/html; charset=iso-8859-1" >
> 
>
> template: mtg_summary.html
> Talk_title: {{ Talk_Title }}
> Speaker: {{ Speaker }}
> Speaker_Title:{{ Speaker_title }}
> test: {{ test }}
>
> 
>
> Example: The Problem (code snippet)
>
> >>>from django.shortcuts import render_to_response
> >>>from soc.models import Tmeeting
> >>>m_values=Members.objects.values()
> >>> print render_to_response('mtg_summary.html',mvalues[0])
>
> Content-Type: text/html; charset=utf-8
>
>  "http://www.w3.org/TR/html4/loose.dtd;>
> 
> 
>  
> 
> 
> 
> template: mtg_summamry.html
> Talk_title: None
> Speaker: George Smith
> Speaker_Title: Title of the test record
> test: 
> 
> 
>
>


It's not at all clear from the code what you're trying to do.
talk_title and speaker_title aren't defined anywhere in the code
you've given us, but I'm not even sure if those are the 'custom
fields' you're referring to.

What's more, the code you've given us would not be capable of
producing the output you've shown, so this clearly isn't the actual
code. We would need to see the actual view and template code - it's
best if you paste it at dpaste.com and give us a link.

If by 'custom fields' you mean methods on the model, like your test()
example, you wouldn't expect the values() method to show them. It will
only show the actual model fields.

I think you're misunderstanding how to access models in your code and
templates. values() isn't the normal way of doing it - really, you
just want to be passing an instance of Tmeeting to your template and
then using normal dot notation to access the values.

For example:

my_meeting = Tmeeting.objects.all()[0]
print my_meeting.date
print my_meeting.speaker
print my_meeting.test()
print render_to_response('mtg_summary.html',
{'my_meeting':my_meeting})

and in the template:
Talk_title: {{ my_meeting.talk }}
Speaker: {{ my_meeting.speaker }}
Speaker_Title:{{ my_meeting.speaker_title }} {# where is this
coming from? #}
test: {{ my_meeting.test }}

etc.

(Note that the convention is to have lower case names for model fields
and methods.)

--
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: url problem

2008-08-24 Thread Handle Huang
urlpatterns = patterns('',
   url(r'^$', 'urus.app.views.main', name="main"),
)
And in the last version when I use this way to define the URL an invalid
syntax will popup.


2008/8/24 Handle Huang <[EMAIL PROTECTED]>

> thanks for your replay.
> but my problem is still here, the include function seems not work( I use
> the last svn version of Django ). And you say why I having serveral
> different URLS pointing to the same view is that the inculde function not
> work, I have to point it directly (just to test if the view work well).
>
> 2008/8/24 timc3 <[EMAIL PROTECTED]>
>
>
>> It looks like you are getting a little confused. For a start you don't
>> match anything for just http://localhost:8000/
>>
>> (r'^$', 'urus.app.views.main')
>>
>> Don't know whether thats on purpose or not. anyway.
>>
>> > urlpatterns = patterns('',
>> > # Example:
>> > # (r'^urus/', include('urus.foo.urls')),
>> >
>> > # Uncomment this for admin:
>> >   (r'^admin/', include('django.contrib.admin.urls')),
>> >   (r'^site_media/(?P.*)$',
>> > 'django.views.static.serve',{'document_root': settings.STATIC_PATH}),
>> >   (r'^accounts/login/$', 'django.contrib.auth.views.login',
>> > {'template_name': 'personal/login.html'}),
>> >   (r'^urus/',include('urus.app.urls')),
>> >   (r'^app/','urus.app.views.main'),
>> >
>> > )
>> >
>> > then the urus/app/urls.py
>> > urlpatterns = patterns(
>> > (r'^$', 'urus.app.views.main'),
>> > )
>>
>> In your first urls.py you seem to be trying to include at urus/app/
>> urls.py but I would use the following in there:
>>
>> urlpatterns = patterns('',
>>url(r'^$', 'urus.app.views.main', name="main"),
>> )
>>
>> Then you get named URLS which will be helpful when you go on
>> developing.
>>
>> Try that and see if it works but I would also try and rethink why you
>> are having several different URLS pointing to the same view.
>> >>
>>
>

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



Re: Composite Forms? Are widgets the right thing to use?

2008-08-24 Thread Jon Loyens

Thanks guys!  Using multiple forms + prefixes is exactly what I need!

Would be nice if there was some global wrapper though so you could do
validation amongst the forms but beggars can't be choosers.

On Aug 23, 2:28 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Aug 23, 2:33 am, Jeff Anderson <[EMAIL PROTECTED]> wrote:
>
> > There is no reason that you couldn't include multiple forms in an HTML
> > post operation. You just have to make sure that there won't end up being
> > duplicate fields across forms.
>
> In fact, there isn't even any reason to worry about that: just use a
> prefix when instantiating the 
> form.http://www.djangoproject.com/documentation/forms/#prefixes-for-forms
>
> --
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Modify data before save?

2008-08-24 Thread Paddy Joy

What is the best way to modify form data before it is saved to the
database?

I have tried the following but can't seem to get it to work, can
anyone help?

models.py
--

class MailBox(models.Model):

domain = models.ForeignKey(Domain, core=True)
address = models.CharField(max_length=500)
password = models.CharField(max_length=500)
maildir = models.CharField(max_length=500)

def __str__(self):
return self.address


forms.py
--

from django import forms
from django.forms import ModelForm, ModelChoiceField
from mysite.hosting.models import *
from django.forms.util import ValidationError
import crypt

class MailBoxForm(ModelForm):
class Meta:
model = MailBox

def clean_Password(self):

return crypt.crypt(self.data['Password'], '$1$salt')

views.py


@login_required
def test(request, domain_id):

if request.method == 'POST':
form = MailBoxForm(request.POST)

if form.is_valid():
new_form = form.save()
 
request.user.message_set.create(message="Mailbox created")

else:

form = MailBoxForm()

return render_to_response('test.html', {"form": form,  },
context_instance=RequestContext(request))


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



Re: Noob: form class location

2008-08-24 Thread Gerard Petersen

Julien,

It's working. It took some shuffling of import statements because I subclass 
ModelForm in there for use with form.as_table

Anyway, thanx again!

Regards,

Gerard.

Julien Phalip wrote:
> The import is likely to be in your view:
> 
> # views.py
> from forms import MyForm
> 
> myview(request):
> if request.method == 'POST':
> form = MyForm(request.POST)
> ...
> 
> That's assuming that views.py and forms.py are at the same level.
> 
> Cheers,
> 
> Julien
> 
> On Aug 23, 11:25 pm, Gerard Petersen <[EMAIL PROTECTED]> wrote:
>> Julien/Russell,
>>
>> Thanx for the info. Working around the name class would simply be resolved 
>> by a 'myforms.py' (or something). One thing is still missing in my brain 
>> though. If I put it in a myforms.py. How does Django (or my code if you 
>> will) knows where to find this class. There should be an import statement 
>> somewhere then, right?
>>
>> Forgive my Django noobness. And thanx a lot!!
>>
>> Regards,
>>
>> Gerard.
>>
>>
>>
>> Russell Keith-Magee wrote:
>>> On Sat, Aug 23, 2008 at 8:59 PM, Julien Phalip <[EMAIL PROTECTED]> wrote:
 Hi,
 In Django there are no 'standard' as such. You'd talk more about
 'conventions'.
 One common way is to put all your forms in forms.py. But that's just
 for cleanliness.
>>> While this is a common convention, I would point out that it is not
>>> without problems. If you have a local 'forms.py' module, you leave
>>> yourself open to name clashes if you use 'from django import forms' in
>>> your code.
>>> However, the rest of your advice is correct - there is not set rule,
>>> just conventions, and as long as Python can import it, the code will
>>> work the same regardless of the location.
>>> Yours,
>>> Russ Magee %-)
>> --
>> urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl'}
> > 

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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



Re: url problem

2008-08-24 Thread timc3

It looks like you are getting a little confused. For a start you don't
match anything for just http://localhost:8000/

(r'^$', 'urus.app.views.main')

Don't know whether thats on purpose or not. anyway.

> urlpatterns = patterns('',
>     # Example:
>     # (r'^urus/', include('urus.foo.urls')),
>
>     # Uncomment this for admin:
>       (r'^admin/', include('django.contrib.admin.urls')),
>       (r'^site_media/(?P.*)$',
> 'django.views.static.serve',{'document_root': settings.STATIC_PATH}),
>       (r'^accounts/login/$', 'django.contrib.auth.views.login',
> {'template_name': 'personal/login.html'}),
>       (r'^urus/',include('urus.app.urls')),
>       (r'^app/','urus.app.views.main'),
>
> )
>
> then the urus/app/urls.py
> urlpatterns = patterns(
>     (r'^$', 'urus.app.views.main'),
> )

In your first urls.py you seem to be trying to include at urus/app/
urls.py but I would use the following in there:

urlpatterns = patterns('',
url(r'^$', 'urus.app.views.main', name="main"),
)

Then you get named URLS which will be helpful when you go on
developing.

Try that and see if it works but I would also try and rethink why you
are having several different URLS pointing to the same view.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---