getting request.user into a ModelForm?

2008-11-06 Thread Rob Hudson

I have the following:

## MODELS

class Category(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=200)

class Link(models.Model):
user = models.ForeignKey(User)
category = models.ForeignKey(Category)
name = models.CharField(max_length=255)
url = models.URLField(max_length=255)

## FORMS

class CategoryField(forms.Field):
def clean(self, value):
if not value:
raise forms.ValidationError('This field is required.')
try:
category = Category.objects.get(user=???, name=value)
except Category.DoesNotExist:
category = Category(user=???, name=value)
category.save()
return category

class LinkForm(ModelForm):
category = CategoryField()
class Meta:
model = Link
exclude = ('user', 'url')

## VIEWS

def create(request):
if request.method == 'POST':
form = LinkForm(request.POST)
if form.is_valid():
link = form.save(commit=False)
link.user = request.user
link.save()
return HttpResponseRedirect(reverse('link_list'))
else:
form = LinkForm()

return render_to_response(
'links/link_form.html', {
'form': form,
},
context_instance=RequestContext(request)
)

What I don't see is a way to get the user up into my field the way I
have things set up.  I originally didn't have a user FK on the
Category model but decided I wanted it so that when adding new Links,
the Categories can be filtered by user so each user sees only their
categories.

I'm stuck here.  Any help is much appreciated.

Thanks,
Rob
--~--~-~--~~~---~--~~
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: App initialized twice? plus, debugging tips.

2008-11-06 Thread Thomas Guettler

project2501 schrieb:
> Hi,
>   I'm new to django and have a couple questions.
>
> I have a __init__.py in my app and try to declare a simple module wide
> variable. I noticed __init__.py is called twice when I run "python
> manage.py runserver". Is this normal?
>   
I remember, that I had a problem like this, too:
   http://www.mail-archive.com/django-users@googlegroups.com/msg39059.html

You can do this to debug it:

# file which gets imported twice
import logging
logging.error('import %s %s' % (__file__, __name__))

To investigate who called this peace of code you can use the traceback
module
and print the stacktrace.

Be sure that you access the module only in one way:
e.g. always "myapp.modules". Not sometimes "myproj.myapp.modules".

 HTH
  Thomas

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


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



defaultdict is not working on "for" template tag iteration.

2008-11-06 Thread Hyungyong Kim

Hi,

Since a few hours ago, I've suffered following problem.
I found this problem is due to collections.defaultdict.

Normal dictionary is working collectly, but defaultdict is not
working.

>>> from django.template import Template, Context
>>> t = Template("{% for k,v in data.items %}{{ k }}: {{ v }}{% endfor %}")
>>> normal_dict = {'a':1, 'b':2}
>>> t.render(Context({'data':normal_dict}))
u'a: 1b: 2'
>>>
>>> from collections import defaultdict
>>> default_dict = defaultdict(int)
>>> default_dict[1]+=1
>>> default_dict[2]+=1
>>> default_dict[1]+=1
>>> default_dict
defaultdict(, {1: 2, 2: 1})
>>> t.render(Context({'data':default_dict}))
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/django/template/__init__.py",
line 176, in render
return self.nodelist.render(context)
  File "/usr/lib/python2.5/site-packages/django/template/__init__.py",
line 768, in render
bits.append(self.render_node(node, context))
  File "/usr/lib/python2.5/site-packages/django/template/debug.py",
line 81, in render_node
raise wrapped
django.template.TemplateSyntaxError: Caught an exception while
rendering: 'int' object is not iterable

Original Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/django/template/debug.py",
line 71, in render_node
result = node.render(context)
  File "/usr/lib/python2.5/site-packages/django/template/
defaulttags.py", line 122, in render
values = list(values)
TypeError: 'int' object is not iterable

>>>

I think defaultdict have to work as normal dict.
--~--~-~--~~~---~--~~
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: Is it possible to output JSON like this?

2008-11-06 Thread Darthmahon

Hi guys, I'll give both a try tomorrow when I am near my dev box
again. Can't really do it in the template as I just want to dump out
JSON only, but I'll give them both a go :)

Cheers,
Chris

On Nov 6, 9:51 am, "Dj Gilcrease" <[EMAIL PROTECTED]> wrote:
> If you dont mind using the template system I think this should produce
> the results you are looking for
>
> [{% for event in events %}
>     {% ifchanged event.date %}{ 'date' : '{{ event.date }}',
> 'dayEvents' : [{% endif %}
>                { 'title' : '{{ event.title }}', 'location' : '{{
> event.location }}', 'id' : '{{ event.id }}' },
>     {% ifchanged event.date %}]},{% endif %}
> {% endfor %}]
>
> Dj Gilcrease
> OpenRPG Developer
> ~~http://www.openrpg.com
>
> On Thu, Nov 6, 2008 at 2:21 AM, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> > It's strange. I've just try this example and it is good:
>
> > In [1]: results = []
>
> > In [2]: results.append( { 'date' : '2008-11-04 00:00:00', 'dayEvents' :
> >    ...:     [ { 'title' : 'Event 1', 'location' : '1', 'id' : '1' }, {
> > 'title' :
> >    ...:         'Event 2', 'location' : '1', 'id' : '2' } ] } )
>
> > In [3]: from django.utils.simplejson import dumps
>
> > In [4]: dumps(results)
> > Out[4]: '[{"date": "2008-11-04 00:00:00", "dayEvents": [{"id": "1",
> > "location": "1", "title": "Event 1"}, {"id": "2", "location": "1", "title":
> > "Event 2"}]}]'
>
> > On Thu, Nov 6, 2008 at 12:13, Darthmahon <[EMAIL PROTECTED]> wrote:
>
> >> Hey Alex,
>
> >> I tried this hard codedJSONthe other day:
>
> >> results = []
> >> results.append( { 'date' : '2008-11-04 00:00:00', 'dayEvents' :
> >> [ { 'title' : 'Event 1', 'location' : '1', 'id' : '1' }, { 'title' :
> >> 'Event 2', 'location' : '1', 'id' : '2' } ] } )
>
> >> But I got an error when I did this (can't remember the error exactly).
>
> >> I can't see why it would fail.
>
> >> On Nov 5, 10:32 pm, "Alex Koshelev" <[EMAIL PROTECTED]> wrote:
> >> > With simplejson module (that is part of django distribution) you can
> >> > covert
> >> > toJSONany python objects. So create data structure you need and pass
> >> > it to
> >> > simplejson dump/dumps functions.
>
> >> > On Thu, Nov 6, 2008 at 01:17, Darthmahon <[EMAIL PROTECTED]> wrote:
>
> >> > > Hi,
>
> >> > > Ok I'm using the following code to turn my model intoJSON:
>
> >> > > from django.core import serializers
> >> > >json= serializers.serialize("json", Event.objects.all()[:5],
> >> > > fields=('title','date','location'))
>
> >> > > Now, this returnsJSONlikethis:
>
> >> > > [
> >> > >        { "pk": 1, "model": "events.event", "fields": {
> >> > >                "date": "2008-11-04 00:00:00", "location": 1, "title":
> >> > > "Event 1"}
> >> > >        },
> >> > >        { "pk": 2, "model": "events.event", "fields": {
> >> > >                "date": "2008-11-04 00:00:00", "location": 1, "title":
> >> > > "Event 2"}
> >> > >        },
> >> > >        { "pk": 3, "model": "events.event", "fields": {
> >> > >                "date": "2008-11-05 00:00:00", "location": 1, "title":
> >> > > "Event 3"}
> >> > >        },
> >> > >        { "pk": 4, "model": "events.event", "fields": {
> >> > >                "date": "2008-11-05 00:00:00", "location": 1, "title":
> >> > > "Event 4"}
> >> > >        },
> >> > > ]
>
> >> > > But I want it to outputlikethis:
>
> >> > > [
> >> > >        { 'date' : '2008-11-04 00:00:00', 'dayEvents' : [
> >> > >                { 'title' : 'Event 1', 'location' : '1', 'id' : '1' },
> >> > >                { 'title' : 'Event 2', 'location' : '1', 'id' : '2' }
> >> > >        ]},
> >> > >        { 'date' : '2008-11-05 00:00:00', 'dayEvents' : [
> >> > >                { 'title' : 'Event 3', 'location' : '1', 'id' : '3' },
> >> > >                { 'title' : 'Event 4', 'location' : '1', 'id' : '4' }
> >> > >        ]}
> >> > > ]
>
> >> > > The main difference is that the events are grouped by date, which
> >> > > makes it easier for me to loop through them the way I want to.
>
> >> > > Any ideas on how to achieve this, been looking in the documentation
> >> > > but nothing in there from what I can see :(
>
> >> > > The event model lookslikethis:
>
> >> > > title        = models.CharField(max_length=200)
> >> > > date       = models.DateTimeField()
> >> > > location  = models.IntegerField(choices=LOCATION_CHOICES, default=1)
>
> >> > > Cheers,
> >> > > Chris
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Submit button names are not showing up in request.POST

2008-11-06 Thread kesmit

I have a form where I need to know which submit button is being
pressed in order to process the form.  The inputs below are the submit
buttons that I have.




I've simplified the view down to the following just to see what's
going on:

@login_required
def home(self, request, mode='stats'):
print request.POST

I'm getting the other form values in request.POST (which include an
input of type="text" and a select), just nothing for the submit
buttons.  I know this used to work, unfortunately I don't know when it
stopped.  I am using Django 1.0.
--~--~-~--~~~---~--~~
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: One Question About Cache

2008-11-06 Thread DULMANDAKH Sukhbaatar

> I want to use per-view cache with memcached and low-level cache with
> filesystem caching.

what's the advantage of having both of them?


-- 
Regards
Dulmandakh

--~--~-~--~~~---~--~~
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: Can I use more than one database handle with Django?

2008-11-06 Thread John M

Do you want to use more than one Database?  Then NO, it's not
available directly right now, that's supposed to be an upcoming
feature.

J

On Nov 6, 4:28 pm, turbogears <[EMAIL PROTECTED]> wrote:
> Hi,
> Can I use more than one database handle with Django?
> and how can I do it?
> excuse my english!
> 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: Logout- Back Button

2008-11-06 Thread jai_python

But closing browser after logout in not a proper solution for this
issue right? just take gmail as example, after logout from gmail
accont and hit back button, it will prompt to login page, this is one
proper method for secure our data. Does django supports this
methodology ?
--~--~-~--~~~---~--~~
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: Django GridContainers at Media Temple

2008-11-06 Thread Kegan

Anyone?

On Oct 7, 5:04 pm, Kegan <[EMAIL PROTECTED]> wrote:
> Wonder if anyone have had experience with the new Media Template
> Django GridContainer?
>
> http://mediatemple.net/webhosting/gs/django.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
-~--~~~~--~~--~--~---



filtering in a template based on foreign key or query params

2008-11-06 Thread Milan Andric
Hello,

I have a view that displays hundreds of applications based on some filter
params.  But I want to render the actual template based on user (an fkey)
and list their applications as sub objects. but only the applications that
were filtered on. bleh.

So in the view I do something like:

# define queryset params from query string.
query_params = {
'status'   : request.GET.get('status', None),
'complete' : request.GET.get('complete', None),
'workshop__in' : request.GET.getlist('workshop__in'),
'user__is_active':True,
}
# form params need to be integers
query_params['workshop__in'] = [int(i) for i in
query_params['workshop__
in']]

# None or '' means don't filter on it.  Remove it so
# Foo.objects.filter() will give the correct results.
for key in query_params.keys():
if query_params[key] == None or query_params[key] == '':
del query_params[key]

# Pass query dict we just built as keyword args to filter().
queryset = Application.objects.filter(**query_params)

This gives me applications based on the query params that I iterate over in
my template.  The problem is I want to change the template now to display
based on the person/user foreign key and have the applications listed
underneath the person.  If I send a queryset of Users to the template then I
can get a list of users but I lose the applications filters.  Or is this a
good solution for some kind of querying filter/template tag?  If I send a
list of applications then  I can't list by user.

Any suggestions?

Thank you,

--
Milan

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



One Question About Cache

2008-11-06 Thread Rodrigo Lopes
Hi there,

I would like help with this problem. I'm studying some cache strategies for
my application, and I've got this doubt:

I would like to know if is possible to use *TWO caching systems together*:
memcached and filesystem caching

I want to use per-view cache with memcached and low-level cache with
filesystem caching.

How could I figure this out?

Regards

-- 
Rodrigo Lopes

--~--~-~--~~~---~--~~
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: Using FileField and existing files

2008-11-06 Thread Chris

This should reference
http://groups.google.com/group/django-users/browse_thread/thread/d7f97f909b2e5a5/6ef76fc78f820d09?lnk=gst&q=I+have+a+model+which+contains+a+FileField+newbie#6ef76fc78f820d09

but I can't seem to reply to the post, maybe too old (I did reply to
the author). This refers to setting FileField values programmatically
such as adding existing files to a database without going through a
web interface.

> I just wanted to add this to the archive for posterity, as I've lost a full 
> day sorting
> this out - supernewbie that I am):
> This is just 'setting' the field to the filename path you want.
>
> eg.
> class T(models.Model):
>file_object = models.FileField(upload_to='myuploads/', blank=True)
>
>
> on command line:
> t = T()
> t.file_object = "the_file.txt"
> t.save()
>
> The file_object now references the file at /myuploads/the_file.txt.
> You can read it etc.
>
> (I personally dislike assignment overloading - that should rightfully
> have reassigned my FileField object to a string, not made a hidden
> mystical call to file_object itself). (I'm going to collect my sour
> grapes and make some lovely wine some time.)
>
> -Chris

--~--~-~--~~~---~--~~
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: A question about models

2008-11-06 Thread Steve Holden

叮叮当当 wrote:
> I have a problem with model, describe as follow:
>
> suppose i have two models:
> class A:
>pass
> class B:
>pass
>
> for some reason, i must quote B in class A, and also, i must quote A
> in class B, how do i solve this question?
>
>   
Use the name of the class as a string.

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



Re: App initialized twice? plus, debugging tips.

2008-11-06 Thread Steve Holden

project2501 wrote:
> Hi,
>   I'm new to django and have a couple questions.
>
> I have a __init__.py in my app and try to declare a simple module wide
> variable. I noticed __init__.py is called twice when I run "python
> manage.py runserver". Is this normal?
>
>   
I believe it can happen, yes.
> Also, I tried to run "manage.py runserver" through my Wing IDE in
> debug mode, but it failed. Is there a convenient way to debug django
> apps?
>   
Did you follow the instructions in the Wing IDE documentation? You need
to use the --noreload option. It's very practical to debug Django under
Wing.

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



Re: how to get the id in an admin template

2008-11-06 Thread webcomm

ahh.  Thanks.



On Nov 6, 4:20 pm, "Alex Koshelev" <[EMAIL PROTECTED]> wrote:
> `example.com` is default Site added by the project setup into sites contrib
> application [1]
>
> [1]:http://docs.djangoproject.com/en/dev/ref/contrib/sites/#ref-contrib-s...
>
> On Fri, Nov 7, 2008 at 00:12, webcomm <[EMAIL PROTECTED]> wrote:
>
> > I don't understand the documentation.  I am able to get the "view on
> > site" link to show, but the URL is wrong.  The correct URL for the
> > instance is...
>
> >http://www.mysite.com/billing/321
>
> > ...so I tried this...
>
> >    def get_absolute_url(self):
> >        return "/billing/%i" % self.id
>
> > ...but when I click the resulting "view on site" link, I'm redirected
> > to...
>
> >http://example.com/billing/321/
>
> > I'm not sure where that "example.com" is coming from.  I went looking
> > for it in settings.py and urls.py and don't see it anywhere.
>
> > -Ryan
>
> > On Nov 4, 11:25 am, Adi Jörg Sieker <[EMAIL PROTECTED]> wrote:
> > > On 04.11.2008 17:19 Uhr,webcommwrote:> How do I get the instance id from
> > within an admin template?  I want to
> > > > add a link to view the instance, and I need the id to create that
> > > > link.  Like so...
>
> > > > View this item
>
> > > if your Model supplies a get_absolute_url method, then the Admin will
> > > automatically create a "view on site" link
> > > on the change detail page.
> > > See alsohttp://
> > docs.djangoproject.com/en/dev/ref/models/instances/#get-absolu...
>
> > > adi
>
> > > --
> > > Adi J. Sieker         mobile: +49 - 178 - 88 5 88 13
> > > Freelance developer   web:    http://www.sieker.info/profile
> > > SAP-Developer
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



A question about models

2008-11-06 Thread 叮叮当当

I have a problem with model, describe as follow:

suppose i have two models:
class A:
   pass
class B:
   pass

for some reason, i must quote B in class A, and also, i must quote A
in class B, how do i solve this question?

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



Select a list item by index

2008-11-06 Thread jago

I have a for loop over a list A.

inside the loop I want to print out the item of list B at the index
'forloop.counter0' of list A.

It is really strange. One can select randon items in a list, or the
first item in a list, but I did not find a way to select the list item
by index.

Am I missing something?

--~--~-~--~~~---~--~~
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: Forms Question

2008-11-06 Thread Robocop

Never mind, i finally realized what was so drastically different
between .96 forms and 1.0 forms.  Thanks for the help!

On Nov 6, 4:33 pm, Robocop <[EMAIL PROTECTED]> wrote:
> So i've just gotten back on this project, and it looks like i'm still
> doing something wrong with my forms code.
>
> What i have right now is:
> def timesheets_add(request):
>   if request.method == 'POST':
>     form = TimeSheetForm(request.POST)
>     if form.is_valid():
>       form.save()
>       return render_to_response("confirmation.html",locals())
>    else:
>       "some YOU FAILED" code
>   else:
>     form = TimeSheetForm()
>     return render_to_response("form_page.html", locals())
>
> The error i receive now is "TimeSheetForm has no attribute "save""
--~--~-~--~~~---~--~~
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: Forms Question

2008-11-06 Thread Robocop

So i've just gotten back on this project, and it looks like i'm still
doing something wrong with my forms code.

What i have right now is:
def timesheets_add(request):
  if request.method == 'POST':
form = TimeSheetForm(request.POST)
if form.is_valid():
  form.save()
  return render_to_response("confirmation.html",locals())
   else:
  "some YOU FAILED" code
  else:
form = TimeSheetForm()
return render_to_response("form_page.html", locals())


The error i receive now is "TimeSheetForm has no attribute "save""


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



Can I use more than one database handle with Django?

2008-11-06 Thread turbogears
Hi,
Can I use more than one database handle with Django?
and how can I do it?
excuse my english!
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
-~--~~~~--~~--~--~---



App initialized twice? plus, debugging tips.

2008-11-06 Thread project2501

Hi,
  I'm new to django and have a couple questions.

I have a __init__.py in my app and try to declare a simple module wide
variable. I noticed __init__.py is called twice when I run "python
manage.py runserver". Is this normal?

Also, I tried to run "manage.py runserver" through my Wing IDE in
debug mode, but it failed. Is there a convenient way to debug django
apps?

thank you!!

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



Re: Getting non-related records

2008-11-06 Thread John M

WOW, I knew it would be easy, but that is ridiculous.

Thanks Alex!

John

On Nov 6, 3:00 pm, "Alex Koshelev" <[EMAIL PROTECTED]> wrote:
> Hi, John
>
> Try this:
>
> Category.objects.exclude(bulletpoint__report=r)
>
> On Fri, Nov 7, 2008 at 01:54, John M <[EMAIL PROTECTED]> wrote:
>
> > i have a model athttp://dpaste.com/88760/
>
> > for a particular Report (r), I'd like to get all categories that
> > aren't in it's bulletpoints.
>
> > For example, If there are four categories: one, two, three, four.
> > there is a report with bullet points for one and two, how can I get a
> > list of three and four.
>
> > This allows me to offer a user to add bulletpoints in those
> > categories.
>
> > I hope this makes sense :P
>
> > John
--~--~-~--~~~---~--~~
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: Confused about unittests and fixtures

2008-11-06 Thread Russell Keith-Magee

On Fri, Nov 7, 2008 at 8:17 AM, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> GenericForeignKey and content type application itself look very doubtful for
> me. If you have a ForeignKey to the ContentType model then you depends on
> order with ContentType objects creates on syncdb. Because ContentType that
> references to some model can have different primary key any time you flush
> database.

"Doubtful" is a little harsh. Contenttypes and GenericForeignKeys both
work fine, and there are extensive unit tests to demonstrate this.
They also work fine in the presence of fixtures, given certain
preconditions.

You are correct in saying that fixtures with ContentTypes can have
problems - these are well understood, and I have plans to address the
problems as part of a fix for ticket #7052. However, as long as your
test data is self contained - i.e., you're not relying on the
implicitly created ContentTypes - you should be fine.

However, this point is worth clarifying for Andy's benefit. Andy: Does
your test fixture contain the content type definitions? Since
ContentType is a dependency of your Calendar app (by virtue of the
Generic Key), the content types will need to be in the fixture. Is
this the case with your project?

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: Confused about unittests and fixtures

2008-11-06 Thread Alex Koshelev
GenericForeignKey and content type application itself look very doubtful for
me. If you have a ForeignKey to the ContentType model then you depends on
order with ContentType objects creates on syncdb. Because ContentType that
references to some model can have different primary key any time you flush
database.

I've faced this issue than develop some application that has fixtures with
ContentType references. Reference brakes when needed ContentType object has
illegal primary key.


On Fri, Nov 7, 2008 at 02:06, Russell Keith-Magee <[EMAIL PROTECTED]>wrote:

>
> On Fri, Nov 7, 2008 at 1:00 AM, AndyH <[EMAIL PROTECTED]> wrote:
> >
> > Hello,
> >
> > I have the following simple test which demonstrates the confusing
> > behaviour I'm seeing:
> >
> > class AvailabilityTestCase(django.test.TestCase):
> >fixtures = FIXTURE_LIST
> >def setUp(self):
> >response = self.client.login(username='testuser',
> > password='password')
> >self.assertTrue(response)
> >
> >def test_page(self):
> >print Calendar.objects.all()
> >print Calendar.objects.all()
> >
> >def test_page_again(self):
> >print Calendar.objects.all()
> >print Calendar.objects.all()
> >
> > When I run this from "manage.py test", it prints out four lists of
> > Calendars as expected. However, the second two, are slightly different
> > to the first two. As far as I'm aware I'm not doing anything to the
> > all() method (or subscribing in to any triggers) that might cause
> > this. But even if I was, my understanding is that the fixtures are
> > refreshed for each test so they can run independently of each other.
> > In my case, which ever order I run these two tests the second set
> > always prints different results to the first.
>
> Assuming that FIXTURE_LIST is correctly defined and references well
> formed fixtures, I can't see anything obviously wrong with your
> example. You are correct in your understanding that a Django TestCase
> will flush the database at the start of each test, so both tests
> should have a clean database and be reporting the same results.
>
> The suggestion that the GenericForeignKey is the source of the problem
> is certainly plausible. I'm not aware of any problems serializing
> Generic FK's, but they are more complicated and less exercised than
> regular keys and fields, so it is certainly a reasonable place to
> start looking.
>
> If you could provide a minimal complete example of this behaviour and
> attach it to a new ticket, it would be most helpful.
>
> 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: Confused about unittests and fixtures

2008-11-06 Thread Russell Keith-Magee

On Fri, Nov 7, 2008 at 1:00 AM, AndyH <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I have the following simple test which demonstrates the confusing
> behaviour I'm seeing:
>
> class AvailabilityTestCase(django.test.TestCase):
>fixtures = FIXTURE_LIST
>def setUp(self):
>response = self.client.login(username='testuser',
> password='password')
>self.assertTrue(response)
>
>def test_page(self):
>print Calendar.objects.all()
>print Calendar.objects.all()
>
>def test_page_again(self):
>print Calendar.objects.all()
>print Calendar.objects.all()
>
> When I run this from "manage.py test", it prints out four lists of
> Calendars as expected. However, the second two, are slightly different
> to the first two. As far as I'm aware I'm not doing anything to the
> all() method (or subscribing in to any triggers) that might cause
> this. But even if I was, my understanding is that the fixtures are
> refreshed for each test so they can run independently of each other.
> In my case, which ever order I run these two tests the second set
> always prints different results to the first.

Assuming that FIXTURE_LIST is correctly defined and references well
formed fixtures, I can't see anything obviously wrong with your
example. You are correct in your understanding that a Django TestCase
will flush the database at the start of each test, so both tests
should have a clean database and be reporting the same results.

The suggestion that the GenericForeignKey is the source of the problem
is certainly plausible. I'm not aware of any problems serializing
Generic FK's, but they are more complicated and less exercised than
regular keys and fields, so it is certainly a reasonable place to
start looking.

If you could provide a minimal complete example of this behaviour and
attach it to a new ticket, it would be most helpful.

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: Getting non-related records

2008-11-06 Thread Alex Koshelev
Hi, John

Try this:

Category.objects.exclude(bulletpoint__report=r)


On Fri, Nov 7, 2008 at 01:54, John M <[EMAIL PROTECTED]> wrote:

>
> i have a model at http://dpaste.com/88760/
>
> for a particular Report (r), I'd like to get all categories that
> aren't in it's bulletpoints.
>
> For example, If there are four categories: one, two, three, four.
> there is a report with bullet points for one and two, how can I get a
> list of three and four.
>
> This allows me to offer a user to add bulletpoints in those
> categories.
>
> I hope this makes sense :P
>
> John
> >
>

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



Getting non-related records

2008-11-06 Thread John M

i have a model at http://dpaste.com/88760/

for a particular Report (r), I'd like to get all categories that
aren't in it's bulletpoints.

For example, If there are four categories: one, two, three, four.
there is a report with bullet points for one and two, how can I get a
list of three and four.

This allows me to offer a user to add bulletpoints in those
categories.

I hope this makes sense :P

John
--~--~-~--~~~---~--~~
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: Apache Segmentation Fault on succesful authentication

2008-11-06 Thread Graham Dumpleton



On Nov 7, 2:38 am, huw_at1 <[EMAIL PROTECTED]> wrote:
> Hi all. I am having some real problems with this. I have an LDAP
> authentication backend that I have hooked up to my app. Standalone it
> appears to run fine. However when running it through my apache server
> I am seeing alot of segmentation faults in my error log coupled with
> the redirection page not loading on succesful authentication.
>
> I have googled around a bit and seen a few other threads with LDAP
> authentication and apache segementation faults. However none of them
> seem to be quite the same issue that I am experiencing. The only thing
> I have managed to garner thus far is that there may be a version
> mismatch betweem the openldap libraries used to compile apache with
> and those used to compile the python-ldap module.
>
> If anyone has any ideas about this or, miraculously, has a solution I
> would be most grateful.

The version mismatch on shared library versions is indeed usually what
the problem is.

You need to run 'ldd' on all Apache modules, all PHP modules if using
PHP, and Python LDAP modules and work out which LDAP client libraries
they use.

Normally Apache mod_auth_ldap would use self contained LDAP client
implementation and so it shouldn't be an issue unless symbols not
being namespaced, but may be possible (not sure) to tell it to use
distinct LDAP client library as well.

See:

  
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#MySQL_Shared_Library_Conflicts

This is about MySQL, but same sort of issue. See how 'ldd' command is
used in that case to check library versions and do similar thing for
LDAP stuff.

Graham
--~--~-~--~~~---~--~~
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: Sort querysets by their data attribute values

2008-11-06 Thread John M

I had a similar need based on a calculated column, you'll have to turn
it into a list (i.e. mylist = list(queryset) ) and then sort from
there.  You can still pass the list to a template a loop through it
just like a regular queryset, since the objects in the list are just
python objects.

J

On Nov 6, 11:58 am, dexter <[EMAIL PROTECTED]> wrote:
> I have a queryset which I have looped thru and added a (temporary)
> data attribute to each instance. Now I would like to order the
> queryset by the value of the data attributes. If I do it like this:
>
> sorted(queryset, key=lambda x: x.data_attr)
>
> the queryset turns into a list and I can't use it like a queryset
> anymore = not good!
> How can i solve 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
-~--~~~~--~~--~--~---



Re: model inheritance - getting data from child objects

2008-11-06 Thread Pawel Pilitowski


On 07/11/2008, at 3:01 AM, Alistair Marshall wrote:


On Nov 6, 2:22 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> If all worker classes (cook, waiter, ...) are subclassed from Worker,
> something like this should work: Worker.objects.filter(workplace=...)
>

Unfortunately the function that each child will run is a bit more
complicated than just listing workers.
It involves output of different equations depending on the class.
Think of it like calculating rents for the different Places and the
rate of rent depends on both the size of the Place and the type of the
place (ie a charity shop might have a lower rate)

As I said, I have the function named the same in each child class but
I need to be able to access it from a list of all the Places.

My current thinking is just a long list of try, except: statements
attempting to call the subclass from the Place model but this feels
hacky and un-clean.

Alistair



Maybe something like this might work:

Store the content type of the child in the parent model.

class Place(models.Model):
 place_type = models.ForeignKey(ContentType)

 def get_workforce(self):
 child = self.place_type.model_class().objects.get 
(place_ptr=self.id)
 child.get_workforce()

Pawel.





--~--~-~--~~~---~--~~
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: how to get the id in an admin template

2008-11-06 Thread Alex Koshelev
`example.com` is default Site added by the project setup into sites contrib
application [1]

[1]:
http://docs.djangoproject.com/en/dev/ref/contrib/sites/#ref-contrib-sites


On Fri, Nov 7, 2008 at 00:12, webcomm <[EMAIL PROTECTED]> wrote:

>
> I don't understand the documentation.  I am able to get the "view on
> site" link to show, but the URL is wrong.  The correct URL for the
> instance is...
>
> http://www.mysite.com/billing/321
>
> ...so I tried this...
>
>def get_absolute_url(self):
>return "/billing/%i" % self.id
>
> ...but when I click the resulting "view on site" link, I'm redirected
> to...
>
> http://example.com/billing/321/
>
> I'm not sure where that "example.com" is coming from.  I went looking
> for it in settings.py and urls.py and don't see it anywhere.
>
> -Ryan
>
>
>
>
>
> On Nov 4, 11:25 am, Adi Jörg Sieker <[EMAIL PROTECTED]> wrote:
> > On 04.11.2008 17:19 Uhr,webcommwrote:> How do I get the instance id from
> within an admin template?  I want to
> > > add a link to view the instance, and I need the id to create that
> > > link.  Like so...
> >
> > > View this item
> >
> > if your Model supplies a get_absolute_url method, then the Admin will
> > automatically create a "view on site" link
> > on the change detail page.
> > See alsohttp://
> docs.djangoproject.com/en/dev/ref/models/instances/#get-absolu...
> >
> > adi
> >
> > --
> > Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
> > Freelance developer   web:http://www.sieker.info/profile
> > SAP-Developer
> >
>

--~--~-~--~~~---~--~~
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: how to get the id in an admin template

2008-11-06 Thread Steve Holden

It's in the only row in your sites table.

regards
 Steve

webcomm wrote:
> I don't understand the documentation.  I am able to get the "view on
> site" link to show, but the URL is wrong.  The correct URL for the
> instance is...
>
> http://www.mysite.com/billing/321
>
> ...so I tried this...
>
> def get_absolute_url(self):
> return "/billing/%i" % self.id
>
> ...but when I click the resulting "view on site" link, I'm redirected
> to...
>
> http://example.com/billing/321/
>
> I'm not sure where that "example.com" is coming from.  I went looking
> for it in settings.py and urls.py and don't see it anywhere.
>
> -Ryan
>
>
>
>
>
> On Nov 4, 11:25 am, Adi Jörg Sieker <[EMAIL PROTECTED]> wrote:
>   
>> On 04.11.2008 17:19 Uhr,webcommwrote:> How do I get the instance id from 
>> within an admin template?  I want to
>> 
>>> add a link to view the instance, and I need the id to create that
>>> link.  Like so...
>>>   
>>> View this item
>>>   
>> if your Model supplies a get_absolute_url method, then the Admin will
>> automatically create a "view on site" link
>> on the change detail page.
>> See 
>> alsohttp://docs.djangoproject.com/en/dev/ref/models/instances/#get-absolu...
>>
>> adi
>>
>> --
>> Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
>> Freelance developer   web:http://www.sieker.info/profile
>> SAP-Developer
>> 
> >
>
>   



--~--~-~--~~~---~--~~
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: how to get the id in an admin template

2008-11-06 Thread webcomm

I don't understand the documentation.  I am able to get the "view on
site" link to show, but the URL is wrong.  The correct URL for the
instance is...

http://www.mysite.com/billing/321

...so I tried this...

def get_absolute_url(self):
return "/billing/%i" % self.id

...but when I click the resulting "view on site" link, I'm redirected
to...

http://example.com/billing/321/

I'm not sure where that "example.com" is coming from.  I went looking
for it in settings.py and urls.py and don't see it anywhere.

-Ryan





On Nov 4, 11:25 am, Adi Jörg Sieker <[EMAIL PROTECTED]> wrote:
> On 04.11.2008 17:19 Uhr,webcommwrote:> How do I get the instance id from 
> within an admin template?  I want to
> > add a link to view the instance, and I need the id to create that
> > link.  Like so...
>
> > View this item
>
> if your Model supplies a get_absolute_url method, then the Admin will
> automatically create a "view on site" link
> on the change detail page.
> See 
> alsohttp://docs.djangoproject.com/en/dev/ref/models/instances/#get-absolu...
>
> adi
>
> --
> Adi J. Sieker         mobile: +49 - 178 - 88 5 88 13
> Freelance developer   web:    http://www.sieker.info/profile
> SAP-Developer
--~--~-~--~~~---~--~~
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: Best practice

2008-11-06 Thread Rajesh Dhawan

meppum wrote:
> I've run into a funny case and I'm not sure how to best deal with it.
> Basically, I have the following classes.
>
> class Profile(models.Model):
> name = models.CharField()
> foo = models.PositiveIntegerField(blank=True, default=0)
>
> class RegistrationForm(forms.Form):
> name = forms.CharField()
> foo = forms.IntegerField(min_value=0, max_value=55,
> required=False)
>
>def save(self):
>Profile.objects.create(name=name, foo=foo)

I think you want to change that to:

Profile.objects.create(name=self.cleaned_data['name'],
foo=self.cleaned_data.get('foo', 0))

-RD

--~--~-~--~~~---~--~~
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: Using Django

2008-11-06 Thread [EMAIL PROTECTED]

I think I had the .htaccess and dispatch.fcgi  files in the wrong
place. I had them in the django generated mysite directory rather the
than the domain, but now when I go to mysite.com I get the 500
internal server error. This happened when I tried the Jeff Croft
setup: http://jeffcroft.com/blog/2006/may/11/django-dreamhost/ which
is where I heard about the Gordon Tillman fix. Thanks for the help
thus far and any related to my new problem.

Jason

On Nov 6, 9:56 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I used the Gordon Tillman 
> setup:http://www.gordontillman.info/Development/DjangoDreamhost
> here are the dispatch.fcgi and .htaccess files:
>
> // dispatch.fcgi
>
> #!/usr/bin/env python2.4
> import sys, os
>
> # Add a custom Python path.
> sys.path.insert(0, "/home/USERNAME/projects/django/trunk")
> sys.path.insert(0, "/home/USERNAME/projects/flup/trunk")
> sys.path.insert(0, "/home/USERNAME/projects")
>
> //.htaccess
>
> # Set the DJANGO_SETTINGS_MODULE environment variable.
> os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"
>
> from django.core.servers.fastcgi import runfastcgi
> runfastcgi(method="threaded", daemonize="false")
>
> AddHandler fastcgi-script .fcgi
> RewriteEngine On
> RewriteBase /
> RewriteRule ^(media/.*)$ - [L]
> RewriteRule ^(admin_media/.*)$ - [L]
> RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
> RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
>
> Here is my directory structure:
>
> home/USERNAME/
>    www.mysite.com/
>    www.anothersite.com/
>    www.yetanothersite.com/
>    projects/
>       django/
>       flup/
>       django_templates/
>       media/
>       mysite/
>
> On Nov 5, 5:56 pm, AndyB <[EMAIL PROTECTED]> wrote:
>
> >http://wiki.dreamhost.com/index.php/Django
>
> > Have you got the .htaccess, dispatch.fcgi etc all set up?
--~--~-~--~~~---~--~~
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: Apache Segmentation Fault on succesful authentication

2008-11-06 Thread huw_at1

I tried running a strace on apache for this but I am still no wiser?
Anyone?

On Nov 6, 3:38 pm, huw_at1 <[EMAIL PROTECTED]> wrote:
> Hi all. I am having some real problems with this. I have an LDAP
> authentication backend that I have hooked up to my app. Standalone it
> appears to run fine. However when running it through my apache server
> I am seeing alot ofsegmentationfaults in my error log coupled with
> the redirection page not loading on succesful authentication.
>
> I have googled around a bit and seen a few other threads with LDAP
> authentication and apache segementation faults. However none of them
> seem to be quite the same issue that I am experiencing. The only thing
> I have managed to garner thus far is that there may be a version
> mismatch betweem the openldap libraries used to compile apache with
> and those used to compile the python-ldap module.
>
> If anyone has any ideas about this or, miraculously, has a solution I
> would be most grateful.
--~--~-~--~~~---~--~~
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: Filtering the modelform in Admin on request.user

2008-11-06 Thread Rajesh Dhawan

Hi,

> I have an Admin site which I want to filter based on request.user.
>
> My ModelAdmin class is something like this,
>
> class FilterOnUser(admin.ModelAdmin):
> def queryset(self, request):
> return self.model._default_manager.filter(user = request.user)
>
> def get_form(self, request, obj=None, **kwargs):
> form_class = super(FilterOnUser, self).get_form(self, request,
> **kwargs)
> class MyModelForm(form_class):
> def get_queryset(self):
> import pdb
> pdb.set_trace()
> return super(MyModelForm,
> self).get_queryset().filter(board = request.board)
>  return MyModelForm
>
> So when I navigate to the change view on my admin site the
> pdb.set_trace is not hit. What am I doing wrong?

I don't know what MyModelForm.get_queryset is intending to do here but
a ModelForm doesn't have such a method by default so you are not
really overriding anything in case that's what you are trying to do.
So "import pdb" is never getting executed by the Admin change list
because the Admin is not supposed to call get_queryset on the
ModelForm.

-RD
--~--~-~--~~~---~--~~
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: Sort querysets by their data attribute values

2008-11-06 Thread Alex Koshelev
There is no other way to do this in python/django layer. But you can try to
add your temp data in database layer and sort where.


On Thu, Nov 6, 2008 at 22:58, dexter <[EMAIL PROTECTED]> wrote:

>
> I have a queryset which I have looped thru and added a (temporary)
> data attribute to each instance. Now I would like to order the
> queryset by the value of the data attributes. If I do it like this:
>
> sorted(queryset, key=lambda x: x.data_attr)
>
> the queryset turns into a list and I can't use it like a queryset
> anymore = not good!
> How can i solve 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
-~--~~~~--~~--~--~---



Sort querysets by their data attribute values

2008-11-06 Thread dexter

I have a queryset which I have looped thru and added a (temporary)
data attribute to each instance. Now I would like to order the
queryset by the value of the data attributes. If I do it like this:

sorted(queryset, key=lambda x: x.data_attr)

the queryset turns into a list and I can't use it like a queryset
anymore = not good!
How can i solve 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
-~--~~~~--~~--~--~---



Re: Newb help request about fields and and subfields

2008-11-06 Thread mondonauta

thank you so much the code u linked me help me a lot...
i still used multivaluefield and multiwidget,
i overrided the render method as u suggested
an then i modified it copying a bit from the render method
i found in the code u linked me :-)
and well at list till i find any bug, it's working
thanks again for ur help

Valerio

On Nov 5, 4:37 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I see two solutions:
>  - be strict: Update the table to contain three columns.
>    day (0..6), start_hour and end_hour.
>     --> No need for MultiWidget
>  - don't be strict: Leave it as a charfield. I guess this field is
>   only read be humans. This gives you more possibilities:
>    Mon 15-17. Except in August 15-16.
>
> if you can convert all current charfields to three columns (strict
> solution),
> I would take the first solution. If you can't since there are already
> entries like the one above, choose the second.
>
> BTW, my TimeDeltaField contains a widget which renders as several
> input fields. Maybe it helps you:
>
> http://www.djangosnippets.org/snippets/1060/
>
>   Thomas
>
> mondonauta schrieb:
>
> > thanks for the answer... anyway, my problem is that i already
> > have a database so i don't really want to change it.
> > in this case in particular i have a table called 'teachings'
> > (that should be managed by the model i created)
> > where all the subjects taught by a professor r stored.
> > for each subject (in the teachings table) a single varchar field
> > is used to store both a day and a time range to indicate when
> > students can go to talk with the professor about that subject.
> > so, i think it would be more user friendly to have 3
> > choicefields: the first one for the day of the week,
> > the second one for the "from time" field and the last one
> > for the "to time" field.
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model ForeignKeys to other Models

2008-11-06 Thread joshuajenkins

That cleared it up, thanks! Great information which will definitely
help me in the future.

On Nov 6, 3:52 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Nov 6, 10:27 am, Håkan Waara <[EMAIL PROTECTED]> wrote:
>
> > 6 nov 2008 kl. 10.05 skrev Daniel Roseman:
>
> > > The problem is not with the imports (you were fine with the original
> > > method - in fact I'd recommend it, to avoid any future problems with
> > > circular imports), but with the __unicode__ methods. As the error
> > > states, you're referring to the related object's class, not the
> > > instance.
>
> > I've avoided using strings for referring to other models in my project  
> > because I prefer a explicity and a runtime error as soon as possible,  
> > if the model changes name etc. Will referring to other models using  
> > strings give the same sort of safety?
>
> > /Håkan
>
> Don't know, but consider this:
>
> app_a/models.py:
>
> from app_b import ModelB
> class ModelA(models.Model):
>     name = models.CharField(max_length=10)
>
> class ModelC(models.Model):
>     name = models.CharField(max_length=10)
>     model_b = models.ForeignKey(ModelB)
>
> app_b/models.py:
>
> from app_a import ModelA
> class ModelB(models.Model):
>     name = models.CharField(max_length=10)
>     model_a = models.ForeignKey(ModelA)
>
> Result: Cannot import ModelA.
> There are various ways round this, but the easiest is just to drop the
> imports and use the string format:
> models.ForeignKey('app_b.ModelB')
> --
> 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: Logout- Back Button

2008-11-06 Thread Scott Moonen
Hi,

This is why many secure web application (e.g., your bank or credit card
company) ask that you close your browser after you logout -- so that no one
else can get to any of your data that may be stored in the browser cache.

If your users are using your application from https:, then this is all you
have to worry about -- ask them to close their browser and the data will be
cleared (browsers should not persist https cached data after exit).  If your
users are using vanilla http, then you should ensure that your application
is sending the appropriate Cache-Control header to force the page not to be
cached.  In any case, you will still need to ask your users to close their
browser after logout.

  -- Scott

On Thu, Nov 6, 2008 at 11:26 AM, jai_python <[EMAIL PROTECTED]> wrote:

>
> Hi, i have created a project named as Asset and application named as
> Management. The problem i am facing is after  i logout form the
> project, if i hit the back button it fails to show the login window. I
> knew that some browsers don't actually hit the server on a "back". So
> can u tel me how to implement "redirect to login page, if i hit back
> button after logout." Its very urgent to implement in my project.
> would be thank full for replies :)
> >
>


-- 
http://scott.andstuff.org/  |  http://truthadorned.org/

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

2008-11-06 Thread Alex Koshelev

The is no way to do "redirect to login page, if i hit back button
after logout". But what is wrong that user can see non-actual old
data? I think it has no matter.

On Nov 6, 8:27 pm, jai_python <[EMAIL PROTECTED]> wrote:
> Please help me out
--~--~-~--~~~---~--~~
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: including javascript in templates

2008-11-06 Thread Steve Holden

You don't need to serve them from Apache for development - then it's OK
to use Django. It's only in production you want to use some other server
for media and static content.

I have this at the end of my settings.py just to keep my test sites
looking reasonable:

# Serve static content so test site looks reasonable
if settings.SERVE_STATIC:
urlpatterns += patterns('',
*tuple(
(r'^%s/(?P.*)$' % d, 'django.views.static.serve',
  {'document_root':
'/home/holdenwe/websites/test_holdenweb_com/static/%s' % d})
for d in settings.STATIC_DIRS ))

regards
 Steve

David Sáez wrote:
> Hi Håkan,
>
> yes, I missed the reading of that link. Now that I have set up
> correctly it works fine.
>
> But it has a BIG disclaimer, and the reccommendation is to let the
> webserver to serve these files (that is what I really want)
> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serving-media-files
>
> So, I should configure my own development Apache to serve them. (We
> will probably have only one webserver in the production environment,
> although separated webserver are recommended).
>
> Thanks a lot!
>
> On 6 nov, 17:53, Håkan Waara <[EMAIL PROTECTED]> wrote:
>   
>> 6 nov 2008 kl. 17.35 skrev David Sáez:
>>
>>
>>
>>
>>
>> 
>>> Hi, I'm a newbie to django and I'm dealing with some configuration
>>> stuff that is making me going crazy. My problem is very simple and I
>>> have a temporal solution, but I guess there might be a better way to
>>> do it. So... there goes the question...
>>>   
>>> ¿ How do I include javascript in a basic template ? I mean, imagine
>>> this template:
>>>   
>>> 
>>>
>>>

Re: Design question : best way to show 1 .. N different categoried items

2008-11-06 Thread John M

Bruno,

Thanks for pointing me in the right direction, the only thing I needed
to as was an order_by("category") to make sure all the bullet points
were grouped by category.

Again, thank you so much for getting me past this.

John

On Nov 5, 1:02 am, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 4 nov, 23:54, John M <[EMAIL PROTECTED]> wrote:
>
> > i have a model for status reports:http://dpaste.com/88760/
>
> > The report has 1-N bullet Points, each bullet Point has a category.
>
> > What I want to figure out, whats my best way to display this in a
> > template, given that the category list is flexible.  I mean, a report
> > might have 1 or more categories.
>
> > I'd like to then group the bullet points for each category on the
> > site.
>
> Not tested, but this should work AFAICT:
>
> # myview.py
> def myview(resquest, report_id):
>    report = get_object_or_404(Report, pk=report_id)
>    context = dict(
>       report = report,
>       bullets =
> report.bulletpoint_set.all().select_related('category')
>    }
>    return render_to_response('mytemplate.html', context)
>
> # mytemplate.html
> {% regroup bullets by category as grouped_bullets %}
> 
>   {% for group in grouped_bullets %}
>   
>     {{ group.grouper }}
>     
>     {% for bullet in group.list %}
>       {{ bullet }}
>     {% endfor %}
>   
>   {% endfor %}
> 
>
> cfhttp://docs.djangoproject.com/en/dev/ref/templates/builtins/#regroup
>
> HTH
--~--~-~--~~~---~--~~
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: Newbie question: HTML formatting not applied to pages

2008-11-06 Thread Peter Rowell

You're being tripped up by auto-escaping of variable contents. This is
a security feature that was first introduced in November of last year.
(http://code.djangoproject.com/changeset/6671)

See http://docs.djangoproject.com/en/dev/ref/templates/builtins/#autoescape
--~--~-~--~~~---~--~~
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: date formats in settings.py

2008-11-06 Thread Benedict Verheyen

Karen Tracey wrote:
> On Thu, Nov 6, 2008 at 11:30 AM, Benedict Verheyen
> <[EMAIL PROTECTED] > wrote:
> 
> 
> Hi,
> 
> i have a question on the different date/time settings one can specify in
>  the settings.py.
> I currently have these:
> TIME_ZONE = 'Europe/Brussels'
> DATE_FORMAT = 'd/m/Y'
> DATETIME_FORMAT = 'd/m/Y H:i'
> TIME_FORMAT = 'H:i'
> YEAR_MONTH_FORMAT = 'm Y'
> MONTH_DAY_FORMAT = 'd m'
> 
> However, any date i enter in the admin section is displayed as Y-m-d.
> I thought these settings would adjust the way dates are displayed but it
> doesn't seem so.
> What is the purpose of these settings?
> 
> Possibly they are being over-ridden by the translation you are using -- see:
> 
> http://code.djangoproject.com/ticket/2203
> 
> Karen

Karen,

thanks for the info. However, i don't use any translations.
I do have USE_I18N = True but changing it to False doesn't change a
thing so the issue remains.

The bug report you mentioned is already 2 years old and it's isn't clear
if this is a bug or not although it does seem like a bug to me and quite
an annoying one if you're using another date format.

I can manage by using the date tag in templates and always converting
the dates in my views but one would think the settings would be there to
handle this kind of things.

Is there a way to define the date format globally or convert it
globally? That would also help.

Regards,
Benedict


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

2008-11-06 Thread [EMAIL PROTECTED]

I used the Gordon Tillman setup: 
http://www.gordontillman.info/Development/DjangoDreamhost
here are the dispatch.fcgi and .htaccess files:

// dispatch.fcgi

#!/usr/bin/env python2.4
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/home/USERNAME/projects/django/trunk")
sys.path.insert(0, "/home/USERNAME/projects/flup/trunk")
sys.path.insert(0, "/home/USERNAME/projects")

//.htaccess

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")


AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin_media/.*)$ - [L]
RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

Here is my directory structure:

home/USERNAME/
   www.mysite.com/
   www.anothersite.com/
   www.yetanothersite.com/
   projects/
  django/
  flup/
  django_templates/
  media/
  mysite/

On Nov 5, 5:56 pm, AndyB <[EMAIL PROTECTED]> wrote:
> http://wiki.dreamhost.com/index.php/Django
>
> Have you got the .htaccess, dispatch.fcgi etc all set up?
--~--~-~--~~~---~--~~
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: Logout- Back Button

2008-11-06 Thread jai_python

Please help me out
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Filtering the modelform in Admin on request.user

2008-11-06 Thread shabda

I have an Admin site which I want to filter based on request.user.

My ModelAdmin class is something like this,

class FilterOnUser(admin.ModelAdmin):
def queryset(self, request):
return self.model._default_manager.filter(user = request.user)

def get_form(self, request, obj=None, **kwargs):
form_class = super(FilterOnUser, self).get_form(self, request,
**kwargs)
class MyModelForm(form_class):
def get_queryset(self):
import pdb
pdb.set_trace()
return super(MyModelForm,
self).get_queryset().filter(board = request.board)
 return MyModelForm

So when I navigate to the change view on my admin site the
pdb.set_trace is not hit. What am I doing wrong?



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



date formats in settings.py

2008-11-06 Thread Benedict Verheyen

Hi,

i have a question on the different date/time settings one can specify in
 the settings.py.
I currently have these:
TIME_ZONE = 'Europe/Brussels'
DATE_FORMAT = 'd/m/Y'
DATETIME_FORMAT = 'd/m/Y H:i'
TIME_FORMAT = 'H:i'
YEAR_MONTH_FORMAT = 'm Y'
MONTH_DAY_FORMAT = 'd m'

However, any date i enter in the admin section is displayed as Y-m-d.
I thought these settings would adjust the way dates are displayed but it
doesn't seem so.
What is the purpose of these settings?

Regards,
Benedict


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

2008-11-06 Thread David Sáez

Hi Håkan,

yes, I missed the reading of that link. Now that I have set up
correctly it works fine.

But it has a BIG disclaimer, and the reccommendation is to let the
webserver to serve these files (that is what I really want)
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serving-media-files

So, I should configure my own development Apache to serve them. (We
will probably have only one webserver in the production environment,
although separated webserver are recommended).

Thanks a lot!

On 6 nov, 17:53, Håkan Waara <[EMAIL PROTECTED]> wrote:
> 6 nov 2008 kl. 17.35 skrev David Sáez:
>
>
>
>
>
> > Hi, I'm a newbie to django and I'm dealing with some configuration
> > stuff that is making me going crazy. My problem is very simple and I
> > have a temporal solution, but I guess there might be a better way to
> > do it. So... there goes the question...
>
> > ¿ How do I include javascript in a basic template ? I mean, imagine
> > this template:
>
> > 
> >    
> >            

Re: don't escape html tags

2008-11-06 Thread gontran

Sorry but I was working with an old documentation!
I fixed it with th e filter 'safe'

thank you for the quick answer

On 6 nov, 17:48, "Ramiro Morales" <[EMAIL PROTECTED]> wrote:
> On Thu, Nov 6, 2008 at 2:16 PM, gontran <[EMAIL PROTECTED]> wrote:
>
> > hello,
>
> > I just started to learn django, so my question may be stupid:
>
> > In my template, I would like to display a html string (stored in my
> > database). My problem is that it displays the string but it
> > automatically escapes the html tags.
>
> > for example, if my string is: my text
> >  instade of showing: my text
> >  it shows: my text
>
> > any idea to fix that?
>
> Searching over the documentation with terms like "automatically
> escaping" or "autoescaping"
> gives this
>
> http://docs.djangoproject.com/en/dev/topics/templates/
>
> as the first hit. Unsurprisingly, one of the sections in that document
> is "Automatic HTML escaping"
>
> Try reading it to know how you can control the feature.
>
> Regards,
>
> --
>  Ramiro Morales
--~--~-~--~~~---~--~~
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: date formats in settings.py

2008-11-06 Thread Karen Tracey
On Thu, Nov 6, 2008 at 11:30 AM, Benedict Verheyen <
[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> i have a question on the different date/time settings one can specify in
>  the settings.py.
> I currently have these:
> TIME_ZONE = 'Europe/Brussels'
> DATE_FORMAT = 'd/m/Y'
> DATETIME_FORMAT = 'd/m/Y H:i'
> TIME_FORMAT = 'H:i'
> YEAR_MONTH_FORMAT = 'm Y'
> MONTH_DAY_FORMAT = 'd m'
>
> However, any date i enter in the admin section is displayed as Y-m-d.
> I thought these settings would adjust the way dates are displayed but it
> doesn't seem so.
> What is the purpose of these settings?
>
> Possibly they are being over-ridden by the translation you are using --
see:

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

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: including javascript in templates

2008-11-06 Thread Håkan Waara

6 nov 2008 kl. 17.35 skrev David Sáez:

>
> Hi, I'm a newbie to django and I'm dealing with some configuration
> stuff that is making me going crazy. My problem is very simple and I
> have a temporal solution, but I guess there might be a better way to
> do it. So... there goes the question...
>
> ¿ How do I include javascript in a basic template ? I mean, imagine
> this template:
>
> 
>   
>   

Re: Template inheritance

2008-11-06 Thread Alaric Haag

Belated thanks for that; the "specialization" tip helps. It feels a 
little like I haven't flopped over to the correct way of thinking about 
it.

Custom tags and inclusion tags are helping me sort it out a bit though.


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



including javascript in templates

2008-11-06 Thread David Sáez

Hi, I'm a newbie to django and I'm dealing with some configuration
stuff that is making me going crazy. My problem is very simple and I
have a temporal solution, but I guess there might be a better way to
do it. So... there goes the question...

¿ How do I include javascript in a basic template ? I mean, imagine
this template:






Hello {{ user_name }}



The javscript inclusion does not work, altough I have configured these
settings:

MEDIA_ROOT = /an/absolute/file/system/path/'
MEDIA_URL = '/m/'

It is not defined in urls.py, and I suppose that I will have this
problem when including CSS and some other media, such as images, flex,
etc...

Does anybody know the right solution?

Thanks in advance :)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: don't escape html tags

2008-11-06 Thread Ramiro Morales

On Thu, Nov 6, 2008 at 2:16 PM, gontran <[EMAIL PROTECTED]> wrote:
>
> hello,
>
> I just started to learn django, so my question may be stupid:
>
> In my template, I would like to display a html string (stored in my
> database). My problem is that it displays the string but it
> automatically escapes the html tags.
>
> for example, if my string is: my text
>  instade of showing: my text
>  it shows: my text
>
> any idea to fix that?
>

Searching over the documentation with terms like "automatically
escaping" or "autoescaping"
gives this

http://docs.djangoproject.com/en/dev/topics/templates/

as the first hit. Unsurprisingly, one of the sections in that document
is "Automatic HTML escaping"

Try reading it to know how you can control the feature.

Regards,

-- 
 Ramiro Morales

--~--~-~--~~~---~--~~
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: don't escape html tags

2008-11-06 Thread Håkan Waara

The documentation for the template system will give you the answer:

http://docs.djangoproject.com/en/dev/topics/templates/

/Håkan

6 nov 2008 kl. 17.16 skrev gontran:

>
> hello,
>
> I just started to learn django, so my question may be stupid:
>
> In my template, I would like to display a html string (stored in my
> database). My problem is that it displays the string but it
> automatically escapes the html tags.
>
> for example, if my string is: my text
> instade of showing: my text
> it shows: my text
>
> any idea to fix that?
>
> thanks for your help
>
> >


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



Re: Newbie question: HTML formatting not applied to pages

2008-11-06 Thread Jeff Beckham

Sure.

Here's /blog/models.py
http://dpaste.com/89108/

/blog/urls.py
http://dpaste.com/89109/

I've got nothing in /blog/views.py right now.

As far as templates, this is /templates/base.html (it's got the
autoescape tags included)
http://dpaste.com/89112/

/templates/blog/list.html has only one line:
{% extends 'base.html' %}

and nothing at all in /templates/blog/detail.html

Thanks!

Jeff



On Nov 5, 3:52 pm, Daniel Hepper <[EMAIL PROTECTED]> wrote:
> > I feel like I'm missing something simple. I read up on the autoescape
> > tags, but I'm not sure that's the solution. Any ideas?
>
> Can you paste your code to dpaste.com and post the link? Any ideas would
> be a guess without some further information.
>
> Regards,
> Daniel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



Logout- Back Button

2008-11-06 Thread jai_python

Hi, i have created a project named as Asset and application named as
Management. The problem i am facing is after  i logout form the
project, if i hit the back button it fails to show the login window. I
knew that some browsers don't actually hit the server on a "back". So
can u tel me how to implement "redirect to login page, if i hit back
button after logout." Its very urgent to implement in my project.
would be thank full for replies :)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



don't escape html tags

2008-11-06 Thread gontran

hello,

I just started to learn django, so my question may be stupid:

In my template, I would like to display a html string (stored in my
database). My problem is that it displays the string but it
automatically escapes the html tags.

for example, if my string is: my text
 instade of showing: my text
 it shows: my text

any idea to fix that?

thanks for your help

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



Re: Oracle Clob Field type

2008-11-06 Thread Ian

On Nov 5, 3:54 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Noob here...
>
> I have an existing table with two Clob fields.  While defining the
> model I use TextField as the filed type.
>
> running  gives me back the error:
>
> cx_Oracle.DatabaseError: ORA-01754: a table may contain only one
> column of type LONG
>
> Well, what I really want are clobs to begin with.  It sounds like what
> I really want to do is subclass Field, but this is starting to turn in
> to more trouble than it's worth...
>
> This has to be something somebody's come across before.

Django doesn't use LONG columns.  Please make sure that you're using
Django 1.0+ and *not* a 0.96 release.  The oracle backend included in
0.96 was incomplete and should not be used.

Hope that helps,
Ian
--~--~-~--~~~---~--~~
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: sql error (1054, "Unknown column 'scripts_script.id' in 'on clause'")

2008-11-06 Thread sergo

I've tried to JOIN instead of ", " in sql query and it works but only
in sql frontend. I don't know where to fix this statement in Django.


On Nov 6, 5:52 pm, sergo <[EMAIL PROTECTED]> wrote:
> I'm using django-tagging and django-multilingual applications in my
> project. I don't know if the problem is in these packages or it is
> more general. Google gives thishttp://bugs.mysql.com/bug.php?id=16190
> , so I thought it is more general problem.
>
> Error page says:
>
> Environment:
>
> Request Method: GET
> Request URL:http://127.0.0.1:8000/scripts/tag/material/
> Django Version: 1.1 pre-alpha SVN-9285
> Python Version: 2.5.2
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.admin',
>  'django.contrib.markup',
>  'sergepogosyan.mytags',
>  'sergepogosyan.articles',
>  'sergepogosyan.scripts',
>  'sergepogosyan.about',
>  'sergepogosyan.gallery',
>  'django.contrib.comments',
>  'tagging',
>  'multilingual',
>  'multilingual.flatpages',
>  'localeurl']
> Installed Middleware:
> ('django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.locale.LocaleMiddleware',
>  'localeurl.middleware.LocaleURLMiddleware',
>  'multilingual.middleware.DefaultLanguageMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.middleware.doc.XViewMiddleware',
>  'multilingual.flatpages.middleware.FlatpageFallbackMiddleware')
>
> Traceback:
> File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
> get_response
>   86.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "C:\Python25\lib\site-packages\tagging\views.py" in
> tagged_object_list
>   52.     return object_list(request, queryset, **kwargs)
> File "C:\Python25\lib\site-packages\django\views\generic
> \list_detail.py" in object_list
>   60.             page_obj = paginator.page(page_number)
> File "C:\Python25\lib\site-packages\django\core\paginator.py" in page
>   37.         number = self.validate_number(number)
> File "C:\Python25\lib\site-packages\django\core\paginator.py" in
> validate_number
>   28.         if number > self.num_pages:
> File "C:\Python25\lib\site-packages\django\core\paginator.py" in
> _get_num_pages
>   60.             if self.count == 0 and not
> self.allow_empty_first_page:
> File "C:\Python25\lib\site-packages\django\core\paginator.py" in
> _get_count
>   48.                 self._count = self.object_list.count()
> File "C:\Python25\lib\site-packages\django\db\models\query.py" in
> count
>   296.         return self.query.get_count()
> File "C:\Python25\lib\site-packages\django\db\models\sql\query.py" in
> get_count
>   237.         data = obj.execute_sql(SINGLE)
> File "C:\Python25\lib\site-packages\django\db\models\sql\query.py" in
> execute_sql
>   1734.         cursor.execute(sql, params)
> File "C:\Python25\lib\site-packages\django\db\backends\util.py" in
> execute
>   19.             return self.cursor.execute(sql, params)
> File "C:\Python25\lib\site-packages\django\db\backends\mysql\base.py"
> in execute
>   83.             return self.cursor.execute(query, args)
> File "C:\Python25\lib\site-packages\MySQLdb\cursors.py" in execute
>   166.             self.errorhandler(self, exc, value)
> File "C:\Python25\lib\site-packages\MySQLdb\connections.py" in
> defaulterrorhandler
>   35.     raise errorclass, errorvalue
>
> Exception Type: OperationalError at /scripts/tag/material/
> Exception Value: (1054, "Unknown column 'scripts_script.id' in 'on
> clause'")
>
> and here's sql query in error page:
>
> SELECT COUNT(*) FROM `scripts_script` , `tagging_taggeditem` LEFT JOIN
> `scripts_script_translation` AS `scripts_script_translation_en` ON
> ((`scripts_script_translation_en`.master_id = `scripts_script`.`id`)
> AND (`scripts_script_translation_en`.language_id = 2)) LEFT JOIN
> `scripts_script_translation` AS `scripts_script_translation_ru` ON
> ((`scripts_script_translation_ru`.master_id = `scripts_script`.`id`)
> AND (`scripts_script_translation_ru`.language_id = 1)) WHERE
> `tagging_taggeditem`.content_type_id = %s AND
> `tagging_taggeditem`.tag_id = %s AND `scripts_script`.`id` =
> `tagging_taggeditem`.object_id
>
> Thank you!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Having trouble with django-multilingual

2008-11-06 Thread Alex Koshelev
Django-multilingual has its own discussion group:
http://groups.google.com/group/django-multilingual.

Try to ask there.


On Thu, Nov 6, 2008 at 18:44, Brandon Taylor <[EMAIL PROTECTED]>wrote:

>
> Hi Everyone,
>
> I'm having a hard time getting django-multilingual to work the way I
> expect.
>
> #settings.py
>
> LANGUAGES = (
>('en', 'English'),
>('es', 'Spanish'),
> )
>
> TEMPLATE_CONTEXT_PROCESSORS = (
>...
>'multilingual.context_processors.multilingual',
> )
>
> MIDDLEWARE_CLASSES = (
>..
>'multilingual.middleware.DefaultLanguageMiddleware',
> )
>
> #models.py
>
> from django.db import models
> from django.contrib import admin
> import multilingual
>
>
> class Widget(models.Model):
>name = models.CharField(max_length=50)
>
>class Translation(multilingual.Translation):
>name = models.CharField(max_length=50)
>
>class Meta:
>verbose_name = _('Widget')
>verbose_name_plural = _('Widgets')
>
>def __unicode__(self):
>return self.name
>
> #index.html
>
> {% for widget in widgets %}
> 
>{{ widget.name }}
> 
> {% endfor %}
>
>
> When I switch my locale in FireFox, widget.name is always English.
> What am I doing wrong? I'm trying to follow the documentation as
> closely as possible, but obviously I'm missing something.
>
> Advice appreciated,
> Brandon
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: model inheritance - getting data from child objects

2008-11-06 Thread Alistair Marshall

On Nov 6, 2:22 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> If all worker classes (cook, waiter, ...) are subclassed from Worker,
> something like this should work: Worker.objects.filter(workplace=...)
>

Unfortunately the function that each child will run is a bit more
complicated than just listing workers.
It involves output of different equations depending on the class.
Think of it like calculating rents for the different Places and the
rate of rent depends on both the size of the Place and the type of the
place (ie a charity shop might have a lower rate)

As I said, I have the function named the same in each child class but
I need to be able to access it from a list of all the Places.

My current thinking is just a long list of try, except: statements
attempting to call the subclass from the Place model but this feels
hacky and un-clean.

Alistair

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



Confused about unittests and fixtures

2008-11-06 Thread AndyH

Hello,

I have the following simple test which demonstrates the confusing
behaviour I'm seeing:

class AvailabilityTestCase(django.test.TestCase):
fixtures = FIXTURE_LIST
def setUp(self):
response = self.client.login(username='testuser',
password='password')
self.assertTrue(response)

def test_page(self):
print Calendar.objects.all()
print Calendar.objects.all()

def test_page_again(self):
print Calendar.objects.all()
print Calendar.objects.all()

When I run this from "manage.py test", it prints out four lists of
Calendars as expected. However, the second two, are slightly different
to the first two. As far as I'm aware I'm not doing anything to the
all() method (or subscribing in to any triggers) that might cause
this. But even if I was, my understanding is that the fixtures are
refreshed for each test so they can run independently of each other.
In my case, which ever order I run these two tests the second set
always prints different results to the first.

The only clue I have to go on (as this doesn't happen with the Auth or
Group models) is that the Calendar model has a GenericForeignKey
field, and it is this field which seems to be different in the second
two Calendar lists (even though the content_type, and object_id are
correct).

Incidentally, if I add a third and fourth test, they also show the
incorrect list. And obviously, the behaviour isn't seen if I refresh a
list of Calendar objects in the admin, or run the code in the
interactive shell.

Any thoughts on what I'm missing.
Thanks for taking the time.

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



Apache Segmentation Fault on succesful authentication

2008-11-06 Thread huw_at1

Hi all. I am having some real problems with this. I have an LDAP
authentication backend that I have hooked up to my app. Standalone it
appears to run fine. However when running it through my apache server
I am seeing alot of segmentation faults in my error log coupled with
the redirection page not loading on succesful authentication.

I have googled around a bit and seen a few other threads with LDAP
authentication and apache segementation faults. However none of them
seem to be quite the same issue that I am experiencing. The only thing
I have managed to garner thus far is that there may be a version
mismatch betweem the openldap libraries used to compile apache with
and those used to compile the python-ldap module.

If anyone has any ideas about this or, miraculously, has a solution I
would be most grateful.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Having trouble with django-multilingual

2008-11-06 Thread Brandon Taylor

Hi Everyone,

I'm having a hard time getting django-multilingual to work the way I
expect.

#settings.py

LANGUAGES = (
('en', 'English'),
('es', 'Spanish'),
)

TEMPLATE_CONTEXT_PROCESSORS = (
...
'multilingual.context_processors.multilingual',
)

MIDDLEWARE_CLASSES = (
..
'multilingual.middleware.DefaultLanguageMiddleware',
)

#models.py

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


class Widget(models.Model):
name = models.CharField(max_length=50)

class Translation(multilingual.Translation):
name = models.CharField(max_length=50)

class Meta:
verbose_name = _('Widget')
verbose_name_plural = _('Widgets')

def __unicode__(self):
return self.name

#index.html

{% for widget in widgets %}

{{ widget.name }}

{% endfor %}


When I switch my locale in FireFox, widget.name is always English.
What am I doing wrong? I'm trying to follow the documentation as
closely as possible, but obviously I'm missing something.

Advice appreciated,
Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Installation of django in user account

2008-11-06 Thread Daniel Hepper

> On Wed, Nov 5, 2008 at 12:18 PM, Tim O'Toole <[EMAIL PROTECTED]> wrote:
> > But I obviously cant  do the following without root access
> >
> > ln -s `pwd`/django-trunk/django SITE-PACKAGES-DIR/django
> >
> > Whilst I can set the PYTHONPATH, I can't then write to PythonPath in
> > the Apache configuration file.
> 
> You may want to try out a deployment option other than
> Apache/mod_python, then, but I'm honestly a bit curious how you're
> planning to use mod_python at all if you don't have access to the
> Apache configuration file.

Wouldn't it be possible to put the configuration in a .htaccess file,
given that AllowOverride is set?

If I put the settings that would normally go into a location directive
directly into .htaccess, everythings seems to work just fine. 

This might be slower, is there anything else to be said against this
solution?


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



sql error (1054, "Unknown column 'scripts_script.id' in 'on clause'")

2008-11-06 Thread sergo

I'm using django-tagging and django-multilingual applications in my
project. I don't know if the problem is in these packages or it is
more general. Google gives this http://bugs.mysql.com/bug.php?id=16190
, so I thought it is more general problem.

Error page says:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/scripts/tag/material/
Django Version: 1.1 pre-alpha SVN-9285
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.markup',
 'sergepogosyan.mytags',
 'sergepogosyan.articles',
 'sergepogosyan.scripts',
 'sergepogosyan.about',
 'sergepogosyan.gallery',
 'django.contrib.comments',
 'tagging',
 'multilingual',
 'multilingual.flatpages',
 'localeurl']
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'localeurl.middleware.LocaleURLMiddleware',
 'multilingual.middleware.DefaultLanguageMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'multilingual.flatpages.middleware.FlatpageFallbackMiddleware')


Traceback:
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python25\lib\site-packages\tagging\views.py" in
tagged_object_list
  52. return object_list(request, queryset, **kwargs)
File "C:\Python25\lib\site-packages\django\views\generic
\list_detail.py" in object_list
  60. page_obj = paginator.page(page_number)
File "C:\Python25\lib\site-packages\django\core\paginator.py" in page
  37. number = self.validate_number(number)
File "C:\Python25\lib\site-packages\django\core\paginator.py" in
validate_number
  28. if number > self.num_pages:
File "C:\Python25\lib\site-packages\django\core\paginator.py" in
_get_num_pages
  60. if self.count == 0 and not
self.allow_empty_first_page:
File "C:\Python25\lib\site-packages\django\core\paginator.py" in
_get_count
  48. self._count = self.object_list.count()
File "C:\Python25\lib\site-packages\django\db\models\query.py" in
count
  296. return self.query.get_count()
File "C:\Python25\lib\site-packages\django\db\models\sql\query.py" in
get_count
  237. data = obj.execute_sql(SINGLE)
File "C:\Python25\lib\site-packages\django\db\models\sql\query.py" in
execute_sql
  1734. cursor.execute(sql, params)
File "C:\Python25\lib\site-packages\django\db\backends\util.py" in
execute
  19. return self.cursor.execute(sql, params)
File "C:\Python25\lib\site-packages\django\db\backends\mysql\base.py"
in execute
  83. return self.cursor.execute(query, args)
File "C:\Python25\lib\site-packages\MySQLdb\cursors.py" in execute
  166. self.errorhandler(self, exc, value)
File "C:\Python25\lib\site-packages\MySQLdb\connections.py" in
defaulterrorhandler
  35. raise errorclass, errorvalue

Exception Type: OperationalError at /scripts/tag/material/
Exception Value: (1054, "Unknown column 'scripts_script.id' in 'on
clause'")


and here's sql query in error page:

SELECT COUNT(*) FROM `scripts_script` , `tagging_taggeditem` LEFT JOIN
`scripts_script_translation` AS `scripts_script_translation_en` ON
((`scripts_script_translation_en`.master_id = `scripts_script`.`id`)
AND (`scripts_script_translation_en`.language_id = 2)) LEFT JOIN
`scripts_script_translation` AS `scripts_script_translation_ru` ON
((`scripts_script_translation_ru`.master_id = `scripts_script`.`id`)
AND (`scripts_script_translation_ru`.language_id = 1)) WHERE
`tagging_taggeditem`.content_type_id = %s AND
`tagging_taggeditem`.tag_id = %s AND `scripts_script`.`id` =
`tagging_taggeditem`.object_id

Thank you!

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



Re: Using Django

2008-11-06 Thread Blu3ness

Hey there,

I am running Django testing server on Dreamhost as well, and I can
tell you it works fine. So I am sure you are probably just
misconfiguring something.

Like AndyB said, .htaccess needs to pass the URL to your dispatch.fcgi
on the dreamhost server, all of your django projects and folders needs
to be in the PYTHON path, not actually under the public viewable
domain directory. Take my directory structure for example.

/home/USER/
  -  local/lib/django   - django main project files
  -  django_projects  - my application code
  -  django_templates - my django templates
  -  beta.mysite.com  - actual public viewable area serving static
files

Hope that helps.

Good luck,
Blu3ness
On Nov 5, 6:56 pm, AndyB <[EMAIL PROTECTED]> wrote:
> http://wiki.dreamhost.com/index.php/Django
>
> Have you got the .htaccess, dispatch.fcgi etc all set up?

--~--~-~--~~~---~--~~
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: Installation of django in user account

2008-11-06 Thread James Bennett

On Wed, Nov 5, 2008 at 12:18 PM, Tim O'Toole <[EMAIL PROTECTED]> wrote:
> But I obviously cant  do the following without root access
>
> ln -s `pwd`/django-trunk/django SITE-PACKAGES-DIR/django
>
> Whilst I can set the PYTHONPATH, I can't then write to PythonPath in
> the Apache configuration file.

You may want to try out a deployment option other than
Apache/mod_python, then, but I'm honestly a bit curious how you're
planning to use mod_python at all if you don't have access to the
Apache configuration file.


-- 
"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: Mysqldb adapter

2008-11-06 Thread achab61

Thanks, it works now! I found out the installation location of MySQLdb
was wrong (my mistake...)
On Nov 6, 1:55 pm, gv <[EMAIL PROTECTED]> wrote:
> On 6 Nov, 12:30, achab61 <[EMAIL PROTECTED]> wrote:
>
> > I've got the same package but I'm getting the same error.
> > Is there anything do once you run the exe ? Did you make any special
> > configuration in your Windows (I'm on XP SP2) i.e. PATH etc...
>
> I cannot remember doing anything extra.  My understanding is that
> Python can find any module in the site-packages directory, so if you
> have:
>
> C:\Python25\Lib\site-packages\MySQLdb
>  it should work
>
> When you run the installer, it finds your Python version in the
> registry, and installsMySQLdbinto that.  So one possibility is that
> maybe you have 2 Python versions, and installedMySQLdbinto the other
> version (which you are not using for django).
> I also have C:\Python25 in my system path - that is anyway useful to
> have.
--~--~-~--~~~---~--~~
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: model inheritance - getting data from child objects

2008-11-06 Thread Thomas Guettler

I have never used model inheritance, but I read the documentation

If all worker classes (cook, waiter, ...) are subclassed from Worker,
something like this should work: Worker.objects.filter(workplace=...)

(Given that workers only work for one workplace)

HTH,
  Thomas

Alistair Marshall schrieb:
> Using the example in the django writing models documentation [1] I
> wish to get a list of all the places, then calculate a value that
> depends on what the type of place it is.
>
> Say in my restraunt I have a function get_workforce() which returns a
> list of all the people that work in the restaraunt. This collects all
> the waiters, cooks and managers that are associated with the
> restraunt.
> Then I have another type of place, a shop which also has a function
> get_workforce() which returns a list of people that work in the shop.
> This collects all the shop_assistants and managers associated with the
> shop.
>
> The function is different depending on the type of subclass but I need
> to be able to get access to it from a list of all the places.
>
> Has anyone come across this before and come up with a solution.
>
> Thanks
> Alistair
>
> [1] http://docs.djangoproject.com/en/dev/topics/db/models/#id6
> >
>   


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


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



Re: Installation of django in user account

2008-11-06 Thread [EMAIL PROTECTED]

No one?

On Nov 5, 6:18 pm, "Tim O'Toole" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I was wondering how feasile it is it to install Django in a user
> account without root access. I followed the instruction at:
>
> http://docs.djangoproject.com/en/dev/topics/install/#installing-devel...
>
> But I obviously cant  do the following without root access
>
> ln -s `pwd`/django-trunk/django SITE-PACKAGES-DIR/django
>
> Whilst I can set the PYTHONPATH, I can't then write to PythonPath in
> the Apache configuration file.
>
> I generally place my html/php files in a public_html directory in my
> local account, but I see that mod_python 3.1 is installed, However I
> fear the network is locked down too tightly for me to experiment with
> Django - anyone care to comment on that?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: multi foreign keys and ordering in admin

2008-11-06 Thread MikeKJ

Rephrased a little

On Nov 6, 11:51 am, MikeKJ <[EMAIL PROTECTED]> wrote:
> Got something like this
>
> class A(models.Model):
>     x
>     class Admin:
>         x
>
> class B(models.Model):
>     a =models.ForeignKey(A, edit_inline=models.TABULAR)
>     xxx
>
> class C(models.Model):
>     a = models.ForeignKey(A,edit_inline=models.TABULAR)
>     x
>
> classD(models.Model):
>     a=models.ForeignKey(A,edit_inline=models.TABULAR)
>     xx
>
> how do I control the ordering of B,C and D classes in the admin template? At 
> the moment it
> appears to be random neither in alpha or in order of the classes.
--~--~-~--~~~---~--~~
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: Help regarding Sqlite3

2008-11-06 Thread sergioh

Also you can use the python shell, you can import your models and
create objects, the you can save them and also make queries to your
model.

is simple as:

# manage.py shell
>>> from django.contrib.auth.models import User
>>>User.objects.all()
..

Also the structure of the tables created you can obtain with the
following command:

manage.py sql [model]

this command will show you the sql used to create your tables.

On Nov 5, 6:46 am, Mattias Jämting <[EMAIL PROTECTED]> wrote:
> I use the sqlite manager extension for firefox. Very good.
>
> http://code.google.com/p/sqlite-manager/
>
> /Mattias
>
> From: django-users@googlegroups.com [mailto:[EMAIL PROTECTED]
> On Behalf Of sadeesh Arumugam
> Sent: den 5 november 2008 11:07
> To: django-users@googlegroups.com
> Subject: Help regarding Sqlite3
>
> Hi Friends,
>   I'm a newbie to Django, in my application i'm uisng Sqlite3 as my
> Database. I've created the models as per my requirement. The database is
> succesfully synchronized. After this how can i view the tables (like select
> statement in Postgres) to check whether my data is successfully inserted
> into the tables.
>
> Any help will be highly Appreciated...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: setting value of a ModelForm field through Javascript

2008-11-06 Thread Donn

On Thursday, 06 November 2008 14:38:41 limas wrote:
> can i set the value of a ModelForm field ,ie a text box, using
> javascript.
Try JQuery. If your input box has an id "blah" then:
$('#blah').val("some new value") 
would set it for you.

jQuery is very cool for this kind of thing.

hth,
\d

--~--~-~--~~~---~--~~
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: syncdb problem with standalone applications

2008-11-06 Thread Ramiro Morales

On Thu, Nov 6, 2008 at 10:26 AM, cnole <[EMAIL PROTECTED]> wrote:
>
> Hi everybody,
>
> i'm new to django framework and i found a problem during learning
> django. I wrote a standalone application for my project and registered
> it as installed applications in the project settings. But everytime i
> made a change to models of the standalone application and run the
> syncdb command to the project, all the standalone application related
> database schema won't be updated. I must remove the whole .db file and
> create it with command sqlall again, than i get the reflection of the
> changed i've made.
>
> Is this a feature or a bug?

It's a functionality that isn't currently included in Django. See:

http://docs.djangoproject.com/en/dev/faq/models/#if-i-make-changes-to-a-model-how-do-i-update-the-database

> Or is there another tricky ways to get the
> syncdb command to work? Please help me, i can't remove and then create
> the whole database schema everytime i make a change to models. Any
> suggestions would be appreciated.

There are some external projects that offer provide schema evoluton
functionality:

south, dmigrations, django-evolution, dbmigrations, deseb,
django-schemaevolution

Google for them.

Regards,

-- 
 Ramiro Morales

--~--~-~--~~~---~--~~
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: Getting a relationship using double underscores

2008-11-06 Thread Daniel Roseman

On Nov 6, 12:10 pm, gv <[EMAIL PROTECTED]> wrote:
> On 6 Nov, 11:56, Daniel Roseman <[EMAIL PROTECTED]> wrote:
>
> > On Nov 6, 10:25 am, gv <[EMAIL PROTECTED]> wrote:
>
> > Well, you don't appear to have any foreign keys linking Backup and
> > Server. You'd need something like this in your Backup declaration:
>
> >     server = models.ForeignKey('Server')
>
> Thanks - should have added that I have already tried that, but if I do
> I get:
> OperationalError: (1054, "Unknown column 'backup.server_id' in 'field
> list'")
> I get this not only in my view, but also in the 'Backup' part of the
> Admin.  I guess I should stick with the ForeignKey, and try to solve
> the Unknown column - problem.

Since you've already created the tables, you'll need to modify them
manually in the database to add the server_id column - or just drop
the tables and re-run 'manage.py syncdb'.
--
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: setting value of a ModelForm field through Javascript

2008-11-06 Thread bruno desthuilliers


On 6 nov, 13:38, limas <[EMAIL PROTECTED]> wrote:
> hello
>
> please help me...
> can i set the value of a ModelForm field ,ie a text box, using
> javascript.

This is totally unrelated to Django and ModelForms. javascript runs on
the browser, *after* the whole page containing the form has been sent
by the server. IOW, at this stage, all you have is a plain old HTML
form. For questions related to client-side HTML form (or whatever)
scripting, please post on comp.lang.javascript (and possibly, learns a
bit of javascript before...).

HTH
--~--~-~--~~~---~--~~
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: Help regarding renaming the uploaded file name in Django.

2008-11-06 Thread Alex Koshelev
Django uploading mechanism allow you to add date-bases values to path. See
`upload_to` section in [1]

[1]: http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield


On Thu, Nov 6, 2008 at 15:45, sadeesh Arumugam
<[EMAIL PROTECTED]>wrote:

> Hi Friends,
>
> I need a help from you. How to rename the uploaded file name in django.
> Example if we upload  a file named "a.jpg" at first time, and at next upload
> it is uploaded as "a_.jpg", and at the third time "a__.jpg", likewise the
> Underscore after the filename is increasing one time for each upload of the
> same image. For this i want to make the filename as -mm-dd-h-m-s
> (Current timetamp of the system), so that for each upload we will get a
> different filename of same image.
>
> How to rename the uploaded filename in django...
>
> >
>

--~--~-~--~~~---~--~~
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: multi foreign keys and ordering in admin

2008-11-06 Thread Alex Koshelev
Try to set meta [1] `ordering` setting

[1]: http://docs.djangoproject.com/en/dev/ref/models/options/

On Thu, Nov 6, 2008 at 14:51, MikeKJ <[EMAIL PROTECTED]> wrote:

>
> Got something like this
>
> class A(models.Model):
>x
>class Admin:
>x
>
> class B(models.Model):
>a =models.ForeignKey(A)
>xxx
>
> class C(models.Model):
>a = models.ForeignKey(A)
>x
>
> classD(models.Model):
>a=models.ForeignKey(A)
>xx
>
>
> how do I control the ordering of B,C and D please. At the moment it
> appears to be random neither in alpha or in order of the classes.
>
> >
>

--~--~-~--~~~---~--~~
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: Mysqldb adapter

2008-11-06 Thread gv

On 6 Nov, 12:30, achab61 <[EMAIL PROTECTED]> wrote:
> I've got the same package but I'm getting the same error.
> Is there anything do once you run the exe ? Did you make any special
> configuration in your Windows (I'm on XP SP2) i.e. PATH etc...

I cannot remember doing anything extra.  My understanding is that
Python can find any module in the site-packages directory, so if you
have:

C:\Python25\Lib\site-packages\MySQLdb
 it should work

When you run the installer, it finds your Python version in the
registry, and installs MySQLdb into that.  So one possibility is that
maybe you have 2 Python versions, and installed MySQLdb into the other
version (which you are not using for django).
I also have C:\Python25 in my system path - that is anyway useful to
have.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Help regarding renaming the uploaded file name in Django.

2008-11-06 Thread sadeesh Arumugam
Hi Friends,

I need a help from you. How to rename the uploaded file name in django.
Example if we upload  a file named "a.jpg" at first time, and at next upload
it is uploaded as "a_.jpg", and at the third time "a__.jpg", likewise the
Underscore after the filename is increasing one time for each upload of the
same image. For this i want to make the filename as -mm-dd-h-m-s
(Current timetamp of the system), so that for each upload we will get a
different filename of same image.

How to rename the uploaded filename in django...

--~--~-~--~~~---~--~~
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: Getting a relationship using double underscores

2008-11-06 Thread gv

On 6 Nov, 12:33, "Alex Koshelev" <[EMAIL PROTECTED]> wrote:
> If you have `serverid` field in database so you can add reference with
> custom column name [1]. For example:
>
> server = models.ForeignKey(Server, db-column="serverid")
>
> [1]:http://docs.djangoproject.com/en/dev/ref/models/fields/#db-column
>

Thank you - that solved it!  (using db_column)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



syncdb problem with standalone applications

2008-11-06 Thread cnole

Hi everybody,

i'm new to django framework and i found a problem during learning
django. I wrote a standalone application for my project and registered
it as installed applications in the project settings. But everytime i
made a change to models of the standalone application and run the
syncdb command to the project, all the standalone application related
database schema won't be updated. I must remove the whole .db file and
create it with command sqlall again, than i get the reflection of the
changed i've made.

Is this a feature or a bug? Or is there another tricky ways to get the
syncdb command to work? Please help me, i can't remove and then create
the whole database schema everytime i make a change to models. Any
suggestions would be appreciated.

Best regards, Zheng

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



syncdb problem with standalone applications

2008-11-06 Thread cnole

Hi everybody,

i'm new to django framework and i found a problem during learning
django. I wrote a standalone application for my project and registered
it as installed applications in the project settings. But everytime i
made a change to models of the standalone application and run the
syncdb command to the project, all the standalone application related
database schema won't be updated. I must remove the whole .db file and
create it with command sqlall again, than i get the reflection of the
changed i've made.

Is this a feature or a bug? Or is there another tricky ways to get the
syncdb command to work? Please help me, i can't remove and then create
the whole database schema everytime i make a change to models. Any
suggestions would be appreciated.

Best regards, Zheng

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



setting value of a ModelForm field through Javascript

2008-11-06 Thread limas

hello

please help me...
can i set the value of a ModelForm field ,ie a text box, using
javascript.

--~--~-~--~~~---~--~~
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: Getting a relationship using double underscores

2008-11-06 Thread Alex Koshelev
If you have `serverid` field in database so you can add reference with
custom column name [1]. For example:

server = models.ForeignKey(Server, db-column="serverid")

[1]: http://docs.djangoproject.com/en/dev/ref/models/fields/#db-column


On Thu, Nov 6, 2008 at 15:10, gv <[EMAIL PROTECTED]> wrote:

>
> On 6 Nov, 11:56, Daniel Roseman <[EMAIL PROTECTED]> wrote:
> > On Nov 6, 10:25 am, gv <[EMAIL PROTECTED]> wrote:
>
> >
> > Well, you don't appear to have any foreign keys linking Backup and
> > Server. You'd need something like this in your Backup declaration:
> >
> > server = models.ForeignKey('Server')
>
> Thanks - should have added that I have already tried that, but if I do
> I get:
> OperationalError: (1054, "Unknown column 'backup.server_id' in 'field
> list'")
> I get this not only in my view, but also in the 'Backup' part of the
> Admin.  I guess I should stick with the ForeignKey, and try to solve
> the Unknown column - 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: Mysqldb adapter

2008-11-06 Thread achab61

I've got the same package but I'm getting the same error.
Is there anything do once you run the exe ? Did you make any special
configuration in your Windows (I'm on XP SP2) i.e. PATH etc...
Thanks

On 6 Nov, 12:15, gv <[EMAIL PROTECTED]> wrote:
> On 6 Nov, 10:39, achab61 <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > I'm in trouble trying to get running theMysqldbadapteron Windows.
>
> > My configuration is MySQL vers. 5.0.67, PythonWin vers. 2.5.2
>
> I use much the same as you, but got mysql-python from Sourceforge - no
> problems:http://sourceforge.net/project/showfiles.php?group_id=22307
--~--~-~--~~~---~--~~
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: Getting a relationship using double underscores

2008-11-06 Thread gv

On 6 Nov, 11:56, Daniel Roseman <[EMAIL PROTECTED]> wrote:
> On Nov 6, 10:25 am, gv <[EMAIL PROTECTED]> wrote:

>
> Well, you don't appear to have any foreign keys linking Backup and
> Server. You'd need something like this in your Backup declaration:
>
>     server = models.ForeignKey('Server')

Thanks - should have added that I have already tried that, but if I do
I get:
OperationalError: (1054, "Unknown column 'backup.server_id' in 'field
list'")
I get this not only in my view, but also in the 'Backup' part of the
Admin.  I guess I should stick with the ForeignKey, and try to solve
the Unknown column - 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: Help regarding Decimal Field in models.py in Django

2008-11-06 Thread Daniel Roseman

On Nov 6, 10:32 am, "sadeesh Arumugam" <[EMAIL PROTECTED]>
wrote:
> Hi Friends,
>     I'm a newbie to Django, i'm doing a registration form to be displayed in
> Admin section. In my form i'm giving two fields namely latitude and
> longitude and setting them as a DecimalField. My question how to set the
> Decimal field into an Optional field (its not a Mandatory field) like
> blank=True.
>
> My code is as follows:
>
> latitude = models.DecimalField(max_digits=11, decimal_places=6, null=True)
> longitude = models.DecimalField(max_digits=11, decimal_places=6, null=True)
>
>                       or
>
> latitude = models.DecimalField(max_digits=11, decimal_places=6, blank=True)
> longitude = models.DecimalField(max_digits=11, decimal_places=6, blank=True)
>
> But its returning the following error:
>
> IntegrityError at /admin/businesstypes/business/add/
>
> businesstypes_business.latitude may not be NULL
>
> Any help is highly Appreciated

Did you originally have it working without either blank or null? Don't
forget that Django won't change any existing database tables. You'll
need to drop the tables and re-run syncdb if you make changes to the
model.
--
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: Getting a relationship using double underscores

2008-11-06 Thread Daniel Roseman

On Nov 6, 10:25 am, gv <[EMAIL PROTECTED]> wrote:
> Hello
>
> What I want to achieve is the equivalent of this:
> select * from server, backup where backup.serverid=server.id and
> servername={backupserver}
>
> To do that the django way is proving challenging, maybe because the
> database was an existing one (not created the django way), or maybe
> because I'm misunderstanding something.
>
> My view:
>
> def detail(request, backupserver):
>     output =
> Backup.objects.filter(server__servername__exact=backupserver)
>     return HttpResponse(output)
>
> If I pass the backupserver in the URL, it returns:
>
> FieldError: Cannot resolve keyword 'server' into field. Choices are:
> backupdate, backupresult, bytecount, checkuser, id, jobname,
> logfilename, verdict
>
> My models.py:
>
> class Server(models.Model):
>     def __unicode__(self):
>         return self.servername
>     servername = models.CharField(max_length=192)
>     ip = models.CharField(max_length=48)
>     domainname = models.CharField(max_length=96, blank=True)
>     os = models.CharField(max_length=96, blank=True)
>     av_file = models.CharField(max_length=768, blank=True)
>     backedupto = models.CharField(max_length=192, blank=True)
>     purpose = models.CharField(max_length=384, blank=True)
>     comment = models.CharField(max_length=768, blank=True)
>     siteid = models.IntegerField(null=True, blank=True)
>     authid = models.IntegerField(null=True, blank=True)
>     exchange = models.CharField(max_length=3, blank=True)
>     status = models.CharField(max_length=3, blank=True)
>     backupserver = models.CharField(max_length=12, blank=True)
>     backuppath = models.CharField(max_length=384, blank=True)
>     backupowners = models.CharField(max_length=254, default='no-one')
>     class Meta:
>         db_table = u'server'
>
> class Backup(models.Model):
>     def __unicode__(self):
>         return self.jobname
>     jobname = models.CharField(max_length=64)
>     logfilename = models.CharField(max_length=64, blank=True)
>     backupresult = models.CharField(max_length=255, blank=True)
>     checkuser = models.CharField(max_length=64, blank=True)
>     backupdate = models.DateTimeField()
>     verdict = models.CharField(max_length=255, blank=True)
>     bytecount = models.IntegerField()
>     class Meta:
>         db_table = u'backup'
>
> Any help would be appreciated.

Well, you don't appear to have any foreign keys linking Backup and
Server. You'd need something like this in your Backup declaration:

server = models.ForeignKey('Server')

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



multi foreign keys and ordering in admin

2008-11-06 Thread MikeKJ

Got something like this

class A(models.Model):
x
class Admin:
x

class B(models.Model):
a =models.ForeignKey(A)
xxx

class C(models.Model):
a = models.ForeignKey(A)
x

classD(models.Model):
a=models.ForeignKey(A)
xx


how do I control the ordering of B,C and D please. At the moment it
appears to be random neither in alpha or in order of the classes.

--~--~-~--~~~---~--~~
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: Model ForeignKeys to other Models

2008-11-06 Thread Daniel Roseman

On Nov 6, 10:27 am, Håkan Waara <[EMAIL PROTECTED]> wrote:
> 6 nov 2008 kl. 10.05 skrev Daniel Roseman:
>
> > The problem is not with the imports (you were fine with the original
> > method - in fact I'd recommend it, to avoid any future problems with
> > circular imports), but with the __unicode__ methods. As the error
> > states, you're referring to the related object's class, not the
> > instance.
>
> I've avoided using strings for referring to other models in my project  
> because I prefer a explicity and a runtime error as soon as possible,  
> if the model changes name etc. Will referring to other models using  
> strings give the same sort of safety?
>
> /Håkan

Don't know, but consider this:

app_a/models.py:

from app_b import ModelB
class ModelA(models.Model):
name = models.CharField(max_length=10)

class ModelC(models.Model):
name = models.CharField(max_length=10)
model_b = models.ForeignKey(ModelB)

app_b/models.py:

from app_a import ModelA
class ModelB(models.Model):
name = models.CharField(max_length=10)
model_a = models.ForeignKey(ModelA)


Result: Cannot import ModelA.
There are various ways round this, but the easiest is just to drop the
imports and use the string format:
models.ForeignKey('app_b.ModelB')
--
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: Best practice

2008-11-06 Thread TiNo
>
> class Profile(models.Model):
>name = models.CharField()
>foo = models.PositiveIntegerField(blank=True, default=0)
>
> class RegistrationForm(forms.Form):
>name = forms.CharField()
>foo = forms.IntegerField(min_value=0, max_value=55,
> required=False)
>
>


a) If your form is the same as your Model, why not use a model form? [1]

b) if you want to allow foo to be null, add 'null=True' to the foo field in
the model [2]

[1] http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
[2] http://docs.djangoproject.com/en/dev/topics/db/models/#field-options

--~--~-~--~~~---~--~~
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: post data and @login_required

2008-11-06 Thread James Bennett

On Thu, Nov 6, 2008 at 5:12 AM, coan <[EMAIL PROTECTED]> wrote:
> Why isn't there an option to have the request object passed to the
> login form?

The login view in the Django admin actually used to do this; see our
most recent security-oriented release for the reasons why it doesn't
do that anymore...


-- 
"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: Mysqldb adapter

2008-11-06 Thread gv

On 6 Nov, 10:39, achab61 <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm in trouble trying to get running the Mysqldb adapter on Windows.
>
> My configuration is MySQL vers. 5.0.67, PythonWin vers. 2.5.2

I use much the same as you, but got mysql-python from Sourceforge - no
problems:
http://sourceforge.net/project/showfiles.php?group_id=22307
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



  1   2   >