Re: Noobie question about getting form data to save to the database

2009-06-05 Thread Andy Dietler

When I add that line I get the following error:

'AddShow' object has no attribute 'save'

On Jun 4, 7:47 pm, Streamweaver  wrote:
> You need to call form.save() after you validate the form.
>
> As below:
>
> def add(request):
>     if request.method == 'POST':
>         form = AddShow(request.POST)
>         if form.is_valid():
>             form.save()
>             return HttpResponseRedirect('/shows/#success')
>     return HttpResponseRedirect('/shows/#error')
>
> On Jun 4, 7:39 pm, Andy  Dietler  wrote:
>
>
>
> > I'm pretty new to Django and Python and I've had some success from
> > reading some books and guides playing around so far but I'm having
> > trouble figuring out how to get data I submit from a form to save into
> > the database. I've simplified down my code to just the basics and I
> > can get the form to submit fine and get passed the "if form.isvalid()"
> > step, but I'm lost from there. I've looked at a ton of code samples,
> > but most are way too complex and I can't figure out the basics of
> > this. All I want to do is save the title field as a new database entry
> > in the shows_show table. Anybody out there willing to take a look at
> > this incredibly simple code and give me a pointer or two about what is
> > wrong, what I need to add to get that working.
>
> > Thanks a ton. - Andy
>
> > 3 pertinent files:
>
> > models.py
> > -
> > from django.db import models
> > from django import forms
>
> > class Show(models.Model):
> >     title = models.CharField(max_length=100)
>
> > class AddShow(forms.Form):
> >     title = forms.CharField(max_length=100)
>
> > views.py
> > 
> > from django.http import HttpResponseRedirect
> > from tvolt.shows.models import Show, AddShow
>
> > def add(request):
> >     if request.method == 'POST':
> >         form = AddShow(request.POST)
> >         if form.is_valid():
> >             return HttpResponseRedirect('/shows/#success')
> >     return HttpResponseRedirect('/shows/#error')
>
> > index.html
> > --
> > 
> >         
> >                 Add a show
> >                 
> >                         Title
> >                         
> >                                  > name="title"
> > maxlength="100" />
> >                         
> >                         
> >                                 Add a show
> >                         
> >                 
> >         
> > 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



syncdb no such table: auth_group

2009-06-05 Thread Wim Feijen

Hello,

python manage.py syncdb failed for me, saying: there is no such table
auth_group. On closer examination, the error stack mentioned one of my
models: timewriting.

After commenting 5 lines of code: tada... syncdb worked!

However, I do not understand, and I am interested in: why ?

Wim

-
My code (problematic lines are commented):

from datetime import datetime, date

from django.db import models
from django.db.models import Q
from django.contrib.auth.models import User, Group
from django.conf import settings

if hasattr(settings, 'TIMEWRITING_MINUTES_LIST'):
MINUTES_LIST = settings.TIMEWRITING_MINUTES_LIST
else:
MINUTES_LIST = (
(0, '0'),
(15, '15'),
(30, '30'),
(45, '45'),
)

HOURS_LIST = [(item, unicode(item)) for item in xrange(0, 24)]

PROJECT_TYPE_LIST = (
('project', 'Project'),
('leave', 'Verlof'),
('illness', 'Ziekte'),
)

# TIMEWRITING_GROUP_ID = 5
# TIMEWRITING_GROUP = Group.objects.get(id=TIMEWRITING_GROUP_ID)

def format_hours(hours, minutes):
return '%d:%02d' % (hours, minutes)

def format_minutes(minutes):
hours = minutes // 60
minutes = minutes % 60
return format_hours(hours, minutes)

# def get_timewriting_users():
#return User.objects.filter(is_active=True,
groups__id=TIMEWRITING_GROUP_ID).exclude(username='estrate')

class ProjectManager(models.Manager):
def visible(self):
return self.filter((Q(finished_at__isnull=True)|Q
(finished_at__gte=date.today())), is_active=True,
started_at__lte=date.today())

def for_user(self, user):
return self.visible().filter((Q(allow_all_users=True)|Q
(allowed_users=user)))

class Project(models.Model):
name = models.CharField('naam', max_length=200)
short_name = models.CharField('korte naam', max_length=25,
unique=True, help_text='Korte, unieke naam om te gebruiken in
overzichten.')
description = models.TextField('omschrijving', blank=True,
help_text='Optioneel')
confirm_term = models.PositiveIntegerField('bevestigingstermijn',
default=30, help_text='Aantal dagen waarna gebruikers een herinnering
krijgen om geschreven uren te bevestigen (0=nooit).')
type = models.CharField('type', max_length=25, default='project',
choices=PROJECT_TYPE_LIST, help_text='Verlof en ziekte kunnen ook als
"projecten" worden ingevoerd zodat de gebruiker hier uren op kan
schrijven.')
started_at = models.DateField('gestart op', default=date.today,
db_index=True, help_text='Vanaf deze dag kan men urenschrijven op dit
project. Als de startdatum later wordt verlegd zullen reeds geschreven
uren NIET worden gewist.')
finished_at = models.DateField(u'be\xebindigd op', null=True,
blank=True, db_index=True, help_text='Tot en met deze dag kan men
urenschrijven op dit project. Als de begindatum later wordt verlegd
zullen reeds geschreven uren NIET worden gewist. Laat dit veld leeg
als er geen einddatum bekend is of indien niet van toepassing.')
is_active = models.BooleanField('is geactiveerd', default=True,
db_index=True, help_text='Met dit veld kan een project (tijdelijk)
worden afgesloten voor het schrijven van nieuwe uren, ongeacht de
start- en einddatum.')
allow_all_users = models.BooleanField('open voor alle gebruikers',
default=True, db_index=True, help_text='Vink dit aan indien alle
gebruikers die uren mogen schrijven, op dit project uren kunnen
schrijven. Indien dit is uitgevinkt dan kunnen alleen de gebruikers
urenschrijven die zijn geselecteerd bij "toegestane gebruikers".')
allowed_users = models.ManyToManyField(User,
verbose_name='toegestane gebruikers', db_index=True, blank=True)

objects = ProjectManager()

class Meta:
verbose_name = 'project'
verbose_name_plural = 'projecten'
ordering = ('short_name',)

def __unicode__(self):
return self.short_name

class WorkDayManager(models.Manager):
def unconfirmed(self):
return self.filter(is_confirmed=False)

def confirmed(self):
return self.filter(is_confirmed=True)


class WorkDay(models.Model):
date = models.DateField('datum', default=date.today, help_text='De
datum van deze werkdag voor de aangegeven gebruiker.', db_index=True)
user = models.ForeignKey(User, verbose_name='gebruiker',
db_index=True)
is_confirmed = models.BooleanField('is bevestigd', default=False,
db_index=True)
confirmed_at = models.DateTimeField('bevestigd op', null=True,
blank=True, editable=False)

objects = WorkDayManager()

class Meta:
verbose_name = 'werkdag'
verbose_name_plural = 'werkdagen'
ordering = ('-date',)
unique_together = (('date', 'user'),)

def __unicode__(self):
return u'%s %s' % (self.date, self.user)

def save(self, *args, **kwargs):
if self.is_confirmed and not self.confirmed_at:
 self.confirmed_at = datetime.now()
else:
self.confirmed_at = None
super(WorkDay, self).save(*args, **kwargs)

def total_minutes(s

Re: Noobie question about getting form data to save to the database

2009-06-05 Thread Daniel Roseman

> On Jun 4, 7:47 pm, Streamweaver  wrote:
>
> > You need to call form.save() after you validate the form.
>
On Jun 5, 8:08 am, Andy  Dietler  wrote:
> When I add that line I get the following error:
>
> 'AddShow' object has no attribute 'save'


Because you've used a plain Form, not a ModelForm. If you've got a
form that represents a model, you should use a modelform.

class AddShow(forms.ModelForm):
class Meta:
model = Show

Now your form has a save method. See here:
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie - record parent ID in child data entered by ModelForm

2009-06-05 Thread Daniel Roseman

On Jun 5, 5:33 am, adelaide_mike  wrote:
> Another "in principle" question.  My Street model is the parent of my
> Property model, many to one via foreign key.
>
> User selects the street and I store it in request.session. User then
> gets to enter the property details in this form:
>
> class PropertyForm(ModelForm):
>         class Meta:
>                 model = Property
>                 exclude = ('street', 'price1', 'price2',)
>
> and when the Add is clicked we do:
>
> def property_data(request, property_id='0'):
>         st = request.session['street_id']
>         print "At start of property_data, st=", st           # debug, so I
> know it has the correct value
>         if request.method == "POST":
>                 if property_id > '0':
>                         #do something
>                 else:
>                         form = PropertyForm(request.POST)
>                         form['street']=request.session['street_id']
>                         if form.is_valid():
>                                 try:
>                                         form.save()
>                                         return 
> HttpResponseRedirect('somewhere')
>                                 except:
>                                         message='database error in ADD'       
>    #debug, this is returned
> to the page
> Because all fields in property (except the foreign key street) either
> have data or are blank=True, the problem must? be the lack of the
> foreign key. (In admin I can add propertys).  How do I get it into the
> data to be saved?
>
> Mike

Don't guess. Look at what the traceback actually says. Especially,
don't use a raw 'except', as that will swallow all types of errors.
Leave out the try/except for now, and let Django print the traceback
page, then show us what it says.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: multiple modelforms for model

2009-06-05 Thread Daniel Roseman

On Jun 5, 12:08 am, adrian  wrote:
> I need to show Telephone and Address modelforms in the middle of
> another big form,
> so I decided to organize the big form into smaller modelforms and
> display each in a separate fieldset.
>
> This works well until the next time I clear the DB and run syncdb.
> At that point,
> syncdb completely ignores the app containing these modelforms.   It
> does not create tables for them or load initial data.   If I run
> manage.py reset venue then it does create the tables.
>
> Here are the forms.  If I remove these from models.py, then syncdb
> creates all the tables in this file.   If I put them back in, it
> doesn't.   Am I doing something wrong here or have I just hit some
> sort of
> limit?
>
> Thanks
>
> class VenueNamesForm(ModelForm):
>     class Meta:
>         model = Venue
>
>         fields = ['name', 'room_name', 'multi_room']
>
> class AreaForm(ModelForm):
>     class Meta:
>         model = Venue
>
>         fields = ['area']
>
> class EmailWebForm(ModelForm):
>     class Meta:
>         model = Venue
>
>         fields = ['email_address', 'website_url']
>
> class ContactsForm(ModelForm):
>     contact = forms.ModelMultipleChoiceField(required=False, queryset
> = Entity.objects.filter(role__exact="CON"))
>     class Meta:
>         model = Venue
>
>         fields = ['contact']
>
> class CapacityForm(ModelForm):
>     class Meta:
>         model = Venue
>
>         fields = ['wheelchair_accessible', 'wheelchair_capacity',
> 'seating_capacity']
>
> class StatusForm(ModelForm):
>     class Meta:
>         model = Venue
>
>         fields = ['active', 'comments']

There's probably a syntax error somewhere in your models.py. I can't
see it above, but it might be unobvious, or it might be elsewhere in
the file.
Try importing the models module in your Python shell (do something
like 'from myapp import models') and see if the traceback shows you
anything useful.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: select size box error

2009-06-05 Thread Daniel Roseman

On May 30, 3:40 pm, Jesse  wrote:
> I have three drop down select boxes, which I have to expand for web
> visibility reasons with the size='' option.  If I select one from each
> box I receive no errors, but if I leave one or more boxes without a
> selection I receive an error.
>
>  
>     {% for pathology in pathology_list %}
>     {{ pathology.pathology }} option>
>     {% endfor %}
>     
>
>  
>     {% for commodity in commodity_list %}
>     {{ commodity.commodity }} option>
>     {% endfor %}
>     
>
> 
>     {% for technology in technology_list %}
>     {{ technology.technology }} option>
>     {% endfor %}
>     
>
> ERROR:
> MultiValueDictKeyError
> Exception Value:
>
> "Key 'pathology_id' not found in http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: syncdb no such table: auth_group

2009-06-05 Thread Daniel Roseman

On Jun 5, 8:42 am, Wim Feijen  wrote:
> Hello,
>
> python manage.py syncdb failed for me, saying: there is no such table
> auth_group. On closer examination, the error stack mentioned one of my
> models: timewriting.
>
> After commenting 5 lines of code: tada... syncdb worked!
>
> However, I do not understand, and I am interested in: why ?
>
> Wim
>
> -
> My code (problematic lines are commented):
>
> from datetime import datetime, date
>
> from django.db import models
> from django.db.models import Q
> from django.contrib.auth.models import User, Group
> from django.conf import settings
>
> if hasattr(settings, 'TIMEWRITING_MINUTES_LIST'):
>     MINUTES_LIST = settings.TIMEWRITING_MINUTES_LIST
> else:
>     MINUTES_LIST = (
>         (0, '0'),
>         (15, '15'),
>         (30, '30'),
>         (45, '45'),
>     )
>
> HOURS_LIST = [(item, unicode(item)) for item in xrange(0, 24)]
>
> PROJECT_TYPE_LIST = (
>     ('project', 'Project'),
>     ('leave', 'Verlof'),
>     ('illness', 'Ziekte'),
> )
>
> # TIMEWRITING_GROUP_ID = 5
> # TIMEWRITING_GROUP = Group.objects.get(id=TIMEWRITING_GROUP_ID)
>
> def format_hours(hours, minutes):
>     return '%d:%02d' % (hours, minutes)
>
> def format_minutes(minutes):
>     hours = minutes // 60
>     minutes = minutes % 60
>     return format_hours(hours, minutes)
>
> # def get_timewriting_users():
> #    return User.objects.filter(is_active=True,
> groups__id=TIMEWRITING_GROUP_ID).exclude(username='estrate')

This looks like a circular dependency error. The call to
Group.objects.get is at module level, so it is executed when the
module is first imported. Since you haven't run syncdb successfully
yet, at the point when that line is executed, the group table doesn't
exist.

I would suggest moving that call into a function, but it looks like
you're not using it at all, so I would leave it out.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie - record parent ID in child data entered by ModelForm

2009-06-05 Thread adelaide_mike

Thanks for the offer.  I have altered the function as suggested:

def property_data(request, property_id='0'):
message = ''
st = request.session['street_id']
print "At start of property_data, request.method=", request.method
print "At start of property_data, st=", st
if request.method == "POST":
form = PropertyForm(request.POST)
form['street']=request.session['street_id']
print "form=", form
if form.is_valid():
form.save()
message='we are added'
return HttpResponseRedirect('somewhere')

And here is the traceback:
Environment:
Request Method: POST
Request URL: http://localhost:8000/wha/address/1/add_property/
Django Version: 1.0.2 final
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.auth',
 'whasite.wha']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/core/handlers/base.py" in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/Users/michael/Documents/Django Projects/whasite/../whasite/wha/
data.py" in property_data
  35.   form['street']=request.session['street_id']

Exception Type: TypeError at /wha/address/1/add_property/
Exception Value: 'PropertyForm' object does not support item
assignment

On Jun 5, 5:15 pm, Daniel Roseman 
wrote:
> On Jun 5, 5:33 am, adelaide_mike  wrote:
>
>
>
> > Another "in principle" question.  My Street model is the parent of my
> > Property model, many to one via foreign key.
>
> > User selects the street and I store it in request.session. User then
> > gets to enter the property details in this form:
>
> > class PropertyForm(ModelForm):
> >         class Meta:
> >                 model = Property
> >                 exclude = ('street', 'price1', 'price2',)
>
> > and when the Add is clicked we do:
>
> > def property_data(request, property_id='0'):
> >         st = request.session['street_id']
> >         print "At start of property_data, st=", st           # debug, so I
> > know it has the correct value
> >         if request.method == "POST":
> >                 if property_id > '0':
> >                         #do something
> >                 else:
> >                         form = PropertyForm(request.POST)
> >                         form['street']=request.session['street_id']
> >                         if form.is_valid():
> >                                 try:
> >                                         form.save()
> >                                         return 
> > HttpResponseRedirect('somewhere')
> >                                 except:
> >                                         message='database error in ADD'     
> >      #debug, this is returned
> > to the page
> > Because all fields in property (except the foreign key street) either
> > have data or are blank=True, the problem must? be the lack of the
> > foreign key. (In admin I can add propertys).  How do I get it into the
> > data to be saved?
>
> > Mike
>
> Don't guess. Look at what the traceback actually says. Especially,
> don't use a raw 'except', as that will swallow all types of errors.
> Leave out the try/except for now, and let Django print the traceback
> page, then show us what it says.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie - record parent ID in child data entered by ModelForm

2009-06-05 Thread TiNo
On Fri, Jun 5, 2009 at 11:04, adelaide_mike wrote:

>  Exception Value: 'PropertyForm' object does not support item
> assignment
>

There you go. You can't do:


> form['street']=request.session['street_id']


You can save the form instance first, without commiting, then set the street
the instance:

 if form.is_valid():
 instance = form.save(commit=False)
 instance.street = request.session['street_id']
 instance.save()
 form.save_m2m()

see:
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method

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



Creating a temporary model in tests

2009-06-05 Thread foxbunny

Hi,

I'm trying to figure out how to create tests for my PermaLib app. It
uses ContentTypes to store permalinks for any model in a Django
project. Since the app itself has only one model, and it has no
get_absolute_url() (obviously, because it is not needed), I was trying
to find a way to define a model within the `tests.py`, to test storage
of premalinks, etc.

Is that possible, and how is it done? If it's not possible, how do I
test this?

The app itself is here:

http://github.com/foxbunny/django-permalib/tree/master


Best regards,


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



Re: Newbie - record parent ID in child data entered by ModelForm

2009-06-05 Thread adelaide_mike

Thank you TiNo  that works if altered slightly like so:
 if form.is_valid():
  instance = form.save(commit=False)
  instance.street_id= request.session['street_id']
  instance.save()
I have been using Django for about ten days, and it requires very
different thinking c/w "normal" desktop apps.  Still heaps to learn.
Thanks again.
Mike
On Jun 5, 6:15 pm, TiNo  wrote:
> On Fri, Jun 5, 2009 at 11:04, adelaide_mike 
> wrote:
>
> >  Exception Value: 'PropertyForm' object does not support item
> > assignment
>
> There you go. You can't do:
>
> > form['street']=request.session['street_id']
>
> You can save the form instance first, without commiting, then set the street
> the instance:
>
>  if form.is_valid():
>                  instance = form.save(commit=False)
>                  instance.street = request.session['street_id']
>                  instance.save()
>                  form.save_m2m()
>
> see:http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-sav...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Creating a temporary model in tests

2009-06-05 Thread Russell Keith-Magee

On Fri, Jun 5, 2009 at 5:28 PM, foxbunny wrote:
>
> Hi,
>
> I'm trying to figure out how to create tests for my PermaLib app. It
> uses ContentTypes to store permalinks for any model in a Django
> project. Since the app itself has only one model, and it has no
> get_absolute_url() (obviously, because it is not needed), I was trying
> to find a way to define a model within the `tests.py`, to test storage
> of premalinks, etc.
>
> Is that possible, and how is it done? If it's not possible, how do I
> test this?

There isn't anything built into Django to do this at the present, but
it can be done.

This very topic is the subject of ticket #7835. This ticket aims to
allow you to define models for testing purposes. The ticket has a
patch which is fairly good, and is probably pretty close to a strategy
that will eventually find its way into trunk. The ticket also has some
useful tips in the comments, which indicates how you can mock up
analogous behaviour without requiring modifications to Django itself.

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



Modifying deserialized Model instances before saving, good idea or bad?

2009-06-05 Thread Jarek Zgoda

I need to copy some data between disconnected instances of an  
application. My first thought was to use serialization and  
deserialization, but I'm hitting one obstacle after another.

Now I am stuck at importing deserialized data with foreign keys  
(available in the same "dump"). I try to import objects in "right  
order" (first import referred, then referring), but objects "saved"  
earlier (referred) cann't be found when importing referring objects.  
The flow is like (obj is Django's DeserializedObject):

try:
   instance = Model.objects.get(uniq_property=obj.object.uniq_property)
   # we have one already, no import necessary
except Model.DoesNotExist:
   referred = OtherModel.objects.get(prop=obj.object.fk.prop)
   instance.fk = referred
   instance.pk = None
   obj.save()

I'm getting OtherModel.DoesNotExist exception, even when the referred  
OtherModel instance has been succesfully imported and exists in  
database at the time of importing Model instance.

Am I abusing Django serialization?

-- 
Artificial intelligence stands no chance against natural stupidity

Jarek Zgoda, R&D, Redefine
jarek.zg...@redefine.pl


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



Strange: named URL only works in root urlconf..

2009-06-05 Thread gnijholt

I've used named URLs for some time now, never had any trouble with
them.
But now I have added an app 'website' to a new Django project.
(version 1.1 beta 1 SVN-10924)

My root urlconf (as defined in settings.py) contains an include to
website.urls:
---
urlpatterns = patterns('',
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls)),
(r'^$', include('website.urls')),
)
---


The included urlconf website.urls looks like this:
---
from django.conf.urls.defaults import *
from django.contrib.auth.decorators import login_required
from django.views.generic.simple import direct_to_template

urlpatterns = patterns('',
url(r'search/', 'website.views.search', name='website-search'),
url(r'^$', 'website.views.index', name='website-index'),
)
---


And both view functions exist ofcourse:
---
from django.conf import settings
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404

def index(request):
"""
docstring for index
"""
return render_to_response("website/index.html", locals(),
context_instance=RequestContext(request))

def search(request):
"""
docstring for search
"""
return render_to_response("website/search.html", locals(),
context_instance=RequestContext(request))
---


The problem is that the {% url website-search %} tags don't work. They
give this error:
---
TemplateSyntaxError at /
Caught an exception while rendering: Reverse for 'website-search' with
arguments '()' and keyword arguments '{}' not found.
---

But if I move the 'search' entry to the root urlconf, it works..
---
urlpatterns = patterns('',
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls)),
url(r'search/', 'website.views.search', name='website-search'),
(r'^$', include('website.urls')),
)
---
I'd rather have this entry in the included urlconf. This worked in the
past..
I don't understand why this won't work. What am I not seeing? Thanks
for any help!

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



Feedbacks and recommendations about test coverage tools

2009-06-05 Thread Michelschr

Hello everyone,

What are the current trends about the best test coverage tools to use
with Django?
Do you have feedback or recommendations for me?

Up to now, I founded this links:

http://opensource.55minutes.com/trac/browser/python/trunk/django/apps...
http://pypi.python.org/pypi/django-test-coverage/

and I would be happy if I can receive some light from the community
before digging further.

Thanks in advance,

Michel

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



Re: Creating a temporary model in tests

2009-06-05 Thread Branko Vukelic



On Jun 5, 1:02 pm, Russell Keith-Magee  wrote:
> On Fri, Jun 5, 2009 at 5:28 PM, foxbunny wrote:
>
> > Hi,
>
> > I'm trying to figure out how to create tests for my PermaLib app. It
> > uses ContentTypes to store permalinks for any model in a Django
> > project. Since the app itself has only one model, and it has no
> > get_absolute_url() (obviously, because it is not needed), I was trying
> > to find a way to define a model within the `tests.py`, to test storage
> > of premalinks, etc.
>
> > Is that possible, and how is it done? If it's not possible, how do I
> > test this?
>
> There isn't anything built into Django to do this at the present, but
> it can be done.
>
> This very topic is the subject of ticket #7835. This ticket aims to
> allow you to define models for testing purposes. The ticket has a
> patch which is fairly good, and is probably pretty close to a strategy
> that will eventually find its way into trunk. The ticket also has some
> useful tips in the comments, which indicates how you can mock up
> analogous behaviour without requiring modifications to Django itself.
>
> Yours,
> Russ Magee %-)


Thanks, Russ. I'll take a look at it.

Best regards,

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



Re: Modifying deserialized Model instances before saving, good idea or bad?

2009-06-05 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-06-05, o godz. 14:06, przez Jarek Zgoda:

> try:
>   instance = Model.objects.get(uniq_property=obj.object.uniq_property)
>   # we have one already, no import necessary
> except Model.DoesNotExist:
>   referred = OtherModel.objects.get(prop=obj.object.fk.prop)
>   instance.fk = referred
>   instance.pk = None
>   obj.save()
>
> I'm getting OtherModel.DoesNotExist exception, even when the referred
> OtherModel instance has been succesfully imported and exists in
> database at the time of importing Model instance.


Deep debug revealed that obj.object.fk is empty (so no chance to get  
obj.object.fk.prop), only obj.object.fk_id is set. Any idea how to get  
related object data from serialized dump?

-- 
Artificial intelligence stands no chance against natural stupidity

Jarek Zgoda, R&D, Redefine
jarek.zg...@redefine.pl


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



issue when creating new project on windows

2009-06-05 Thread grimmus

Hi,

I am trying to run the following in dos

django-admin.py startproject mysite

When it press enter, the django-admin.py file opens in notepad and the
script isnt executed ??

Any ideas why this is happening ?

I have the following in my path setting:

C:\Python26;C:\Python26\Scripts;

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



repost of possible bug

2009-06-05 Thread crypto

Why is Django unquoting the path_info in WSGIRequestHandler?

http://example.com/http%3A%2F%2Ftest.org%2Fvocab%23FOAF/

becomes:

http://example.com/http://test.org/vocab#FOAF/

which is an invalid url.

Is this an oversight or is there something in the HTTP spec that says
otherwise?

file: django/core/servers/basehttp.py
class: WSGIRequestHandler
method: get_environ(self)
line: env['PATH_INFO'] = urllib.unquote(path)

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



Re: Historical Records (as introduced in the Pro Django book)

2009-06-05 Thread Phil Mocek

On Thu, Jun 04, 2009 at 05:46:20PM -0700, chris wrote:
> is anybody else using [the Historical Records model, which is
> introduced in Apress' Pro Django book by Marty Alchin]?

Very likely so.  I haven't, but I'm very interested in the
discussion of such, as it seems that this would be very useful.

> Have you successfully dealt with [the problems of using this
> model with self-referential models and the inability to get an
> overview of what has changed via retrieval of instances with the
> most recent changes]?

I haven't.  Hopefully someone else can answer.

It looks like the Audit Trail page on the Django wiki [1]
describes something similar to what you're doing.  It references a
previous discussion [2] on this list that might be of interest.

If you find solutions to your problems, it be helpful to others if
you followed up here.  Thanks in advance for doing so.


References:

[1]: 
[2]: 


-- 
Phil Mocek

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



How to import this module

2009-06-05 Thread David

Hello,

In my project "mysite" directory I have "middleware.py". This
"middleware.py" has only one class "SiteLogin" and this class has only
one method "process_request".

Now I need to import this "process_request" into "urls.py" in the
"mysite" directory. Can anybody give me a clue how to do this?

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



Place two or more inputs per line in django admin.

2009-06-05 Thread Denis Cheremisov

I saw the method using fieldsets, by grouping several fields in a
tuple. But this method didn't suit my needs, because I use slightly
modified add_view,change_view,get_form, etc, where the base model/form
can be substituted by it's derivative. So, I don't know what fields to
show exactly, but know which fields I want to show in one line.
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to group_by..

2009-06-05 Thread Darren

Hey,

Would anyone be able to to help me convert this SQL to Django code?

SELECT A.a, COUNT(B.b)
FROM A, B
WHERE A.id = B.a_id
GROUP BY A.id
ORDER BY A.id;

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



Re: issue when creating new project on windows

2009-06-05 Thread Ned Batchelder

To run Python scripts directly, you need to make sure your PATHEXT 
environment variable has .py in it.  Mine is:

C:\> set PATHEXT
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.py;.pyw;.pyc;.pyo

Or, you can use python explicitly:

C:\> python django-admin.py startproject mysite

--Ned.
http://nedbatchelder.com

grimmus wrote:
> Hi,
>
> I am trying to run the following in dos
>
> django-admin.py startproject mysite
>
> When it press enter, the django-admin.py file opens in notepad and the
> script isnt executed ??
>
> Any ideas why this is happening ?
>
> I have the following in my path setting:
>
> C:\Python26;C:\Python26\Scripts;
>
> Thanks in advance
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.com


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



Re: How to import this module

2009-06-05 Thread Daniel Roseman

On Jun 5, 3:51 pm, David  wrote:
> Hello,
>
> In my project "mysite" directory I have "middleware.py". This
> "middleware.py" has only one class "SiteLogin" and this class has only
> one method "process_request".
>
> Now I need to import this "process_request" into "urls.py" in the
> "mysite" directory. Can anybody give me a clue how to do this?
>
> Thanks so much.

Er, what? If it's a middleware, it needs to go in the
MIDDLEWARE_CLASSES tuple in settings.py.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to import this module

2009-06-05 Thread Alex Gaynor
On Fri, Jun 5, 2009 at 10:35 AM, Daniel Roseman <
roseman.dan...@googlemail.com> wrote:

>
> On Jun 5, 3:51 pm, David  wrote:
> > Hello,
> >
> > In my project "mysite" directory I have "middleware.py". This
> > "middleware.py" has only one class "SiteLogin" and this class has only
> > one method "process_request".
> >
> > Now I need to import this "process_request" into "urls.py" in the
> > "mysite" directory. Can anybody give me a clue how to do this?
> >
> > Thanks so much.
>
> Er, what? If it's a middleware, it needs to go in the
> MIDDLEWARE_CLASSES tuple in settings.py.
> --
> DR.
> >
>
And regardless you can't import a method from a class, you'd need to import
the class and reference the method as class.method.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: How to group_by..

2009-06-05 Thread Russell Keith-Magee

On Fri, Jun 5, 2009 at 11:24 PM, Darren wrote:
>
> Hey,
>
> Would anyone be able to to help me convert this SQL to Django code?
>
> SELECT A.a, COUNT(B.b)
> FROM A, B
> WHERE A.id = B.a_id
> GROUP BY A.id
> ORDER BY A.id;

It's impossible to give you a canonical answer without a complete
Django model, but the query you have written would be rendered using
something like:
A.objects.values('a').annotate(Count(b__b)).order_by('id')

As a point of clarification - if you actually only want a count of B
objects, not a count of unique values of B.b, then you could use:

A.objects.values('a').annotate(Count(b)).order_by('id')

The values() clause is also potentially optional. The purpose of that
clause is to reduce the output set so that it contains only the field
'a' and the count. If you are happy with returning full A instances,
annotated with the count, you would use:

A.objects.annotate(Count(b)).order_by('id')

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



Re: How to import this module

2009-06-05 Thread David

Thanks DR. I did put  'mysite.middleware.SiteLogin' into
MIDDLEWARE_CLASSES  in settings.py already, however I still get

Exception Value: name 'process_request' is not defined





On Jun 5, 8:35 am, Daniel Roseman 
wrote:
> On Jun 5, 3:51 pm, David  wrote:
>
> > Hello,
>
> > In my project "mysite" directory I have "middleware.py". This
> > "middleware.py" has only one class "SiteLogin" and this class has only
> > one method "process_request".
>
> > Now I need to import this "process_request" into "urls.py" in the
> > "mysite" directory. Can anybody give me a clue how to do this?
>
> > Thanks so much.
>
> Er, what? If it's a middleware, it needs to go in the
> MIDDLEWARE_CLASSES tuple in settings.py.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



LDAP support in Django?

2009-06-05 Thread Mike Driscoll

Hi,

Can someone tell me if Django has LDAP support builtin or as a plugin
of some sort? Or do I need to write all that myself? I saw references
to LDAP in the svn docs and I've found some snippets of code with the
ldap module and Django 0.96 as well as a blog post or two on rolling
your own LDAP integration.

Anyway, your advice would be welcome. I'm getting rather fed up with a
certain other Python web framework's poor documentation and unhelpful
community.

Thanks,

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



Re: How to import this module

2009-06-05 Thread David

Middleware class:

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

===
urls.py:

from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()


urlpatterns = patterns('',

(r'^admin/(.*)', admin.site.root),
(r'^accounts/login/', process_request),
(r'^polls/', include('mysite.polls.urls')),
)


=

url: http://ip_address/accounts/login/

I got:

NameError at /accounts/login/
name 'process_request' is not definedRequest Method: GET
Request URL: http://10.0.1.244:8000/accounts/login/
Exception Type: NameError
Exception Value: name 'process_request' is not defined
Exception Location: /home/dwang/mysite/../mysite/urls.py in ,
line 26
Python Executable: /usr/bin/python
Python Version: 2.5.2
Python Path: ['/home/dwang/mysite', '/usr/lib/python2.5', '/usr/lib/
python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/
python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/
usr/lib/python2.5/site-packages', '/var/lib/python-support/
python2.5']
Server time: Fri, 5 Jun 2009 10:55:40 -0500


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



Re: How to import this module

2009-06-05 Thread Daniel Roseman

On Jun 5, 4:47 pm, David  wrote:
> Thanks DR. I did put  'mysite.middleware.SiteLogin' into
> MIDDLEWARE_CLASSES  in settings.py already, however I still get
>
> Exception Value: name 'process_request' is not defined

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



Re: How to import this module

2009-06-05 Thread Daniel Roseman

On Jun 5, 4:58 pm, David  wrote:
> Middleware class:
>
> MIDDLEWARE_CLASSES = (
>     'django.middleware.common.CommonMiddleware',
>     'django.contrib.sessions.middleware.SessionMiddleware',
>     'django.contrib.auth.middleware.AuthenticationMiddleware',
>     'mysite.middleware.SiteLogin',
> )
>
> ===
> urls.py:
>
> from django.conf.urls.defaults import *
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>
>     (r'^admin/(.*)', admin.site.root),
>     (r'^accounts/login/', process_request),
>     (r'^polls/', include('mysite.polls.urls')),
> )

Why are you doing this? You can't map middleware to a URL, it makes
absolutely no sense. What are you trying to do?
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to import this module

2009-06-05 Thread David

I am trying to set up a user login page. A user needs to login first
before he/she can do anything.

I refered: "http://superjared.com/entry/requiring-login-entire-django-
powered-site/"

"Then put myproject.middleware.SiteLogin in your MIDDLEWARE_CLASSES in
settings.py (replace myproject with your project name) and you’re
done"


I must have did something wrong. Then how to enable a user login?






On Jun 5, 9:07 am, Daniel Roseman 
wrote:
> On Jun 5, 4:58 pm, David  wrote:
>
>
>
>
>
> > Middleware class:
>
> > MIDDLEWARE_CLASSES = (
> >     'django.middleware.common.CommonMiddleware',
> >     'django.contrib.sessions.middleware.SessionMiddleware',
> >     'django.contrib.auth.middleware.AuthenticationMiddleware',
> >     'mysite.middleware.SiteLogin',
> > )
>
> > ===
> > urls.py:
>
> > from django.conf.urls.defaults import *
> > from django.contrib import admin
> > admin.autodiscover()
>
> > urlpatterns = patterns('',
>
> >     (r'^admin/(.*)', admin.site.root),
> >     (r'^accounts/login/', process_request),
> >     (r'^polls/', include('mysite.polls.urls')),
> > )
>
> Why are you doing this? You can't map middleware to a URL, it makes
> absolutely no sense. What are you trying to do?
> --
> DR.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to group_by..

2009-06-05 Thread Darren

Fantastic, thanks!

This is 1.1 only though correct?

Cheers :)
Darren


On Jun 5, 11:39 am, Russell Keith-Magee 
wrote:
> On Fri, Jun 5, 2009 at 11:24 PM, Darren wrote:
>
> > Hey,
>
> > Would anyone be able to to help me convert this SQL to Django code?
>
> > SELECT A.a, COUNT(B.b)
> > FROM A, B
> > WHERE A.id = B.a_id
> > GROUP BY A.id
> > ORDER BY A.id;
>
> It's impossible to give you a canonical answer without a complete
> Django model, but the query you have written would be rendered using
> something like:
> A.objects.values('a').annotate(Count(b__b)).order_by('id')
>
> As a point of clarification - if you actually only want a count of B
> objects, not a count of unique values of B.b, then you could use:
>
> A.objects.values('a').annotate(Count(b)).order_by('id')
>
> The values() clause is also potentially optional. The purpose of that
> clause is to reduce the output set so that it contains only the field
> 'a' and the count. If you are happy with returning full A instances,
> annotated with the count, you would use:
>
> A.objects.annotate(Count(b)).order_by('id')
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to import this module

2009-06-05 Thread David

I am new in this Django field so please do not get surprised when you
see my stupid errors.

any more suggestions on how to set up a user login page?

Thanks.



On Jun 5, 9:17 am, David  wrote:
> I am trying to set up a user login page. A user needs to login first
> before he/she can do anything.
>
> I refered: "http://superjared.com/entry/requiring-login-entire-django-
> powered-site/"
>
> "Then put myproject.middleware.SiteLogin in your MIDDLEWARE_CLASSES in
> settings.py (replace myproject with your project name) and you’re
> done"
>
> I must have did something wrong. Then how to enable a user login?
>
> On Jun 5, 9:07 am, Daniel Roseman 
> wrote:
>
>
>
> > On Jun 5, 4:58 pm, David  wrote:
>
> > > Middleware class:
>
> > > MIDDLEWARE_CLASSES = (
> > >     'django.middleware.common.CommonMiddleware',
> > >     'django.contrib.sessions.middleware.SessionMiddleware',
> > >     'django.contrib.auth.middleware.AuthenticationMiddleware',
> > >     'mysite.middleware.SiteLogin',
> > > )
>
> > > ===
> > > urls.py:
>
> > > from django.conf.urls.defaults import *
> > > from django.contrib import admin
> > > admin.autodiscover()
>
> > > urlpatterns = patterns('',
>
> > >     (r'^admin/(.*)', admin.site.root),
> > >     (r'^accounts/login/', process_request),
> > >     (r'^polls/', include('mysite.polls.urls')),
> > > )
>
> > Why are you doing this? You can't map middleware to a URL, it makes
> > absolutely no sense. What are you trying to do?
> > --
> > DR.- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to import this module

2009-06-05 Thread Daniel Roseman

On Jun 5, 5:17 pm, David  wrote:
> I am trying to set up a user login page. A user needs to login first
> before he/she can do anything.
>
> I refered: "http://superjared.com/entry/requiring-login-entire-django-
> powered-site/"
>
> "Then put myproject.middleware.SiteLogin in your MIDDLEWARE_CLASSES in
> settings.py (replace myproject with your project name) and you’re
> done"
>
> I must have did something wrong. Then how to enable a user login?

That quote - and indeed the whole page - says nothing at all about
putting a reference to the middleware in your urls.py.

Grabbing random bits of code off the Internet is not going to help you
to create your site if you don't actually know what you're doing. This
code does something very specific, which is to redirect an
unauthorised user requesting any page to the login pages. It doesn't
actually create the login pages for you. To learn how to do that,
you're going to have to read the documentation.

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



Customizing extends template tag for mobile version of site

2009-06-05 Thread Andrew Fong

I was hoping someone could explain to me what the exact behavior would
be if the Extends Node in the template was not first.

Here's my use-case scenario: I need to maintain separate mobile and
desktop templates for my site. I'm finding out that 90% of my
templates would be identical -- the only difference would be which
templates they extended from -- e.g. {% extends 'base.html' %} vs. {%
extends 'm_base.html' %}.

My views insert a mobile variable into the context if they think the
user-agent is a mobile device. So I want behavior like this:

{% if mobile_var %}
  {% extends 'm_base.html' %}
{% else %}
  {% extends 'base.html' %}
{% endif %}

This won't work because the the extends tag doesn't really understand
the {% if %} tag above it and just throws up when it comes to the {%
else %} tag. So as an alternative, I plan to encapsulate that logic in
a custom extends tag -- e.g. {% mextends mobile_var 'm_base.html'
'base.html' %} that wraps the existing do_extends function.

When going over the ExtendNode source code however, I noticed it has
to be first. However, in order to use my custom tag, I need to call {%
load %}, and that call means any ExtendNode created after that can't
be first. I'm tempted to simply disable that, but I'm not really sure
what will happen if I do. Are there any problems with calling a load
tag before an extends?

Thanks!

-- Andrew


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



Re: How to group_by..

2009-06-05 Thread Russell Keith-Magee

On Sat, Jun 6, 2009 at 12:20 AM, Darren wrote:
>
> Fantastic, thanks!
>
> This is 1.1 only though correct?

Apologies, I should have mentioned this. Yes, the syntax I gave will
only work with Django trunk (soon to be v1.1)

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



Re: How to import this module

2009-06-05 Thread David

thanks for your information. it is quite helpful.

thanks again.

On Jun 5, 9:27 am, Daniel Roseman 
wrote:
> On Jun 5, 5:17 pm, David  wrote:
>
> > I am trying to set up a user login page. A user needs to login first
> > before he/she can do anything.
>
> > I refered: "http://superjared.com/entry/requiring-login-entire-django-
> > powered-site/"
>
> > "Then put myproject.middleware.SiteLogin in your MIDDLEWARE_CLASSES in
> > settings.py (replace myproject with your project name) and you’re
> > done"
>
> > I must have did something wrong. Then how to enable a user login?
>
> That quote - and indeed the whole page - says nothing at all about
> putting a reference to the middleware in your urls.py.
>
> Grabbing random bits of code off the Internet is not going to help you
> to create your site if you don't actually know what you're doing. This
> code does something very specific, which is to redirect an
> unauthorised user requesting any page to the login pages. It doesn't
> actually create the login pages for you. To learn how to do that,
> you're going to have to read the documentation.
>
> Start here:http://docs.djangoproject.com/en/dev/topics/auth/
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Troubles using Django custom feed generation

2009-06-05 Thread towel

Hello,

I'm trying to generate a custom feed since I need both the summary and
content elements in a certain Atom Feed. I have therefore created a
feeds.py where I import all the needed stuff (omitted) and then I
create a CustomFeed class like this:

class CustomFeed(Atom1Feed):
 def add_item_elements(self, handler, item):
  super(CustomFeed, self).add_item_elements(handler, item)
  handler.addQuickElement(u'content', u'bar', {u'type': u'html'})

Then I use this CustomFeed in my LatestArticlesFeed class (feed_type =
CustomFeed).

So far so good, this works just fine and adds bar
to every item element in my Atom Feed. However I obviously need
content to be set based on item.content -- how do I do so? I can't
use

  handler.addQuickElement(u'content', item['content'], {u'type':
u'html'})

since content is not defined in django.utils.feedgenerator.

Unfortunatly the custom feed generation doesn't seem to be a very
discussed subject, I tried looking on the list and on the web but I
haven't be able to find any real word example. Any help (or link)
would be very appreciated.

Thank,

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



Re: How to group_by..

2009-06-05 Thread Darren

That's cool. You don't happen to have an updated estimate of the 1.1
release date by any chance?

Thanks,
Darren

On Jun 5, 12:35 pm, Russell Keith-Magee 
wrote:
> On Sat, Jun 6, 2009 at 12:20 AM, Darren wrote:
>
> > Fantastic, thanks!
>
> > This is 1.1 only though correct?
>
> Apologies, I should have mentioned this. Yes, the syntax I gave will
> only work with Django trunk (soon to be v1.1)
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: LDAP support in Django?

2009-06-05 Thread Adam Stein

Just google django and ldap.  That's how I found how to set up Django
authentication to use an LDAP server (works great).

On Fri, 2009-06-05 at 08:52 -0700, Mike Driscoll wrote:
> Hi,
> 
> Can someone tell me if Django has LDAP support builtin or as a plugin
> of some sort? Or do I need to write all that myself? I saw references
> to LDAP in the svn docs and I've found some snippets of code with the
> ldap module and Django 0.96 as well as a blog post or two on rolling
> your own LDAP integration.
> 
> Anyway, your advice would be welcome. I'm getting rather fed up with a
> certain other Python web framework's poor documentation and unhelpful
> community.
> 
> Thanks,
> 
> Mike
> -- 
Adam Stein @ Xerox Corporation   Email: a...@eng.mc.xerox.com

Disclaimer: Any/All views expressed
here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]


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



Django application support in GlassFish v3 Preview

2009-06-05 Thread vivek

In the recent preview release of GlassFish v3 application server, we
have made it Python and WSGI aware (thru Jython) and so you can run
Django applications on it.

Read here for details: 
http://weblogs.java.net/blog/vivekp/archive/2009/06/run_django_appl_1.html

-vivek.

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



query help (distinct)

2009-06-05 Thread eric.frederich

How can I get distinct content_types from a model like this?...

In sqlite I did the following and it worked...
sqlite> select distinct content_type_id from booking_managedasset;

class ManagedAsset(models.Model):
content_type   = models.ForeignKey(ContentType)
object_id  = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type',
'object_id')
name   = models.CharField(max_length=100, unique=True,
 help_text='Asset Name')
slug   = models.SlugField(max_length=100, unique=True,
 help_text='Slug')


This works in Django but it is getting all objects from the database
and then using Python to make them distinct.
set([ma.content_type for ma in ManagedAsset.objects.all()])

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



Re: LDAP support in Django?

2009-06-05 Thread Kip Parker

There's a lot of useful stuff on djangosnippets for LDAP and Active
Directory too:

http://www.google.co.uk/search?q=+LDAP+site%3Ahttp%3A%2F%2Fwww.djangosnippets.org

On Jun 5, 6:17 pm, Adam Stein  wrote:
> Just google django and ldap.  That's how I found how to set up Django
> authentication to use an LDAP server (works great).
>
>
>
> On Fri, 2009-06-05 at 08:52 -0700, Mike Driscoll wrote:
> > Hi,
>
> > Can someone tell me if Django has LDAP support builtin or as a plugin
> > of some sort? Or do I need to write all that myself? I saw references
> > to LDAP in the svn docs and I've found some snippets of code with the
> > ldap module and Django 0.96 as well as a blog post or two on rolling
> > your own LDAP integration.
>
> > Anyway, your advice would be welcome. I'm getting rather fed up with a
> > certain other Python web framework's poor documentation and unhelpful
> > community.
>
> > Thanks,
>
> > Mike
> > --
>
> Adam Stein @ Xerox Corporation       Email: a...@eng.mc.xerox.com
>
> Disclaimer: Any/All views expressed
> here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: query help (distinct)

2009-06-05 Thread Daniel Roseman

On Jun 5, 6:56 pm, "eric.frederich"  wrote:
> How can I get distinct content_types from a model like this?...
>
> In sqlite I did the following and it worked...
> sqlite> select distinct content_type_id from booking_managedasset;
>
> class ManagedAsset(models.Model):
>     content_type   = models.ForeignKey(ContentType)
>     object_id      = models.PositiveIntegerField()
>     content_object = generic.GenericForeignKey('content_type',
> 'object_id')
>     name   = models.CharField(max_length=100, unique=True,
>              help_text='Asset Name')
>     slug   = models.SlugField(max_length=100, unique=True,
>              help_text='Slug')
>
> This works in Django but it is getting all objects from the database
> and then using Python to make them distinct.
> set([ma.content_type for ma in ManagedAsset.objects.all()])
>
> Is there a way to accomplish this using Django queries?

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



Re: query help (distinct)

2009-06-05 Thread eric.frederich

Thats good, but now I need to turn those id's back into content types.

>From there I need to get the model's verbose plural name also.
The idea is a view where the types of assets are listed, Rooms,
Projectors, etc.

BTW, if you couldn't tell from the sql statement before, this is a
booking application.

On Jun 5, 2:19 pm, Daniel Roseman 
wrote:
> On Jun 5, 6:56 pm, "eric.frederich"  wrote:
>
>
>
> > How can I get distinct content_types from a model like this?...
>
> > In sqlite I did the following and it worked...
> > sqlite> select distinct content_type_id from booking_managedasset;
>
> > class ManagedAsset(models.Model):
> >     content_type   = models.ForeignKey(ContentType)
> >     object_id      = models.PositiveIntegerField()
> >     content_object = generic.GenericForeignKey('content_type',
> > 'object_id')
> >     name   = models.CharField(max_length=100, unique=True,
> >              help_text='Asset Name')
> >     slug   = models.SlugField(max_length=100, unique=True,
> >              help_text='Slug')
>
> > This works in Django but it is getting all objects from the database
> > and then using Python to make them distinct.
> > set([ma.content_type for ma in ManagedAsset.objects.all()])
>
> > Is there a way to accomplish this using Django queries?
>
> ManagedAsset.objects.values_list('content_type', flat=True).distinct()
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: add parameter to url

2009-06-05 Thread Michael

I don't know if it's the right solution but I made a custom filter.

import urllib

@register.filter
def custom_urlencode(url):
return urllib.urlencode({'category': url})

Seems to work just fine. Spaces are now replaced by a '+'.


On May 29, 10:08 pm, Michael  wrote:
> Hi and thanks for your reply. The problem is that I will autoload
> excel files into the database without a slug field. So I guess I need
> to filter the categories by the exact same name and that's why I
> started with the parameters.
>
> On 29 mei, 18:19, "scot.hac...@gmail.com" 
> wrote:
>
> > On May 28, 1:04 pm, Michael  wrote:
>
> > > If I look to the admin is see that for example spaces are replaced by
> > > a '+' sign and & is replaced by '%26'. I have just white spaces and
> > > the & sign in my parameters. To avoid this I have put the urlencode
> > > filter in my template.
>
> > > Example:
>
> > > {% for category in category_list %}
> > > {{ category.name }} > > a>
> > > {% endfor %}
>
> > Maybe not the answer you're looking for, but seems like a better job
> > for category.slug, so you don't have to worry about parsing for
> > whitespace, etc. That's what slugs are for!
>
> > ./s
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



accounts/profile question

2009-06-05 Thread David

Hello,

I have set up a user login page and it works. However I do not know
how to redirect this user to his/her account. I have

(r'^accounts/login/$', 'django.contrib.auth.views.login'),

in my urls.py. When a user types his/her username/password correctly,
the url transfers to

http://ip_address/accounts/profile/

Is there a homepage for users by default? Of course this user can only
see/update his/her account information there or do something that he/
she is authorized to do.

Anybody likes to give me a clue?

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



Re: accounts/profile question

2009-06-05 Thread Phil Mocek

On Fri, Jun 05, 2009 at 01:21:50PM -0700, David wrote:
> Is there a homepage for users by default?

That is a question about your application, not about the Django
framework.

-- 
Phil Mocek

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



Using Django authentication for web pages outside Django?

2009-06-05 Thread Adam Stein

I'm trying to figure out a way to use Django authentication to control
access to web pages (on the same web server) that are NOT under Django.

I have found some information regarding setting up Apache for basic
authentication using mod_wsgi, but in this case Apache puts up it's own
login window.

I'm looking for a solution using Django and/or Apache directives that
would put up Django's login page.  It should look exactly the same as if
the URL were under Django control.

Has anyone done anything like this?  I'm currently using Django v1.0.2
and Apache v2.2 but can upgrade either if necessary.
-- 
Adam Stein @ Xerox Corporation   Email: a...@eng.mc.xerox.com

Disclaimer: Any/All views expressed
here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]


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



Re: accounts/profile question

2009-06-05 Thread Gabriel .

On Fri, Jun 5, 2009 at 5:21 PM, David wrote:
>
> Hello,
>
> I have set up a user login page and it works. However I do not know
> how to redirect this user to his/her account. I have
>
> (r'^accounts/login/$', 'django.contrib.auth.views.login'),
>
> in my urls.py. When a user types his/her username/password correctly,
> the url transfers to
>
> http://ip_address/accounts/profile/
>
> Is there a homepage for users by default? Of course this user can only
> see/update his/her account information there or do something that he/
> she is authorized to do.
>
> Anybody likes to give me a clue?
>

accounts/profile is the default redirect url, but you need to create
the corresponding url conf and view :)

Or you can modify the behavior with the LOGIN_REDIRECT_URL setting.

-- 
Kind Regards

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



Re: accounts/profile question

2009-06-05 Thread David


ok. then is there a default userpage template that I can use?
thanks.


On Jun 5, 1:23 pm, Phil Mocek 
wrote:
> On Fri, Jun 05, 2009 at 01:21:50PM -0700, David wrote:
> > Is there a homepage for users by default?
>
> That is a question about your application, not about the Django
> framework.
>
> --
> Phil Mocek
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: accounts/profile question

2009-06-05 Thread David

I see. thanks.

On Jun 5, 1:30 pm, "Gabriel ."  wrote:
> On Fri, Jun 5, 2009 at 5:21 PM, David wrote:
>
> > Hello,
>
> > I have set up a user login page and it works. However I do not know
> > how to redirect this user to his/her account. I have
>
> > (r'^accounts/login/$', 'django.contrib.auth.views.login'),
>
> > in my urls.py. When a user types his/her username/password correctly,
> > the url transfers to
>
> >http://ip_address/accounts/profile/
>
> > Is there a homepage for users by default? Of course this user can only
> > see/update his/her account information there or do something that he/
> > she is authorized to do.
>
> > Anybody likes to give me a clue?
>
> accounts/profile is the default redirect url, but you need to create
> the corresponding url conf and view :)
>
> Or you can modify the behavior with the LOGIN_REDIRECT_URL setting.
>
> --
> Kind Regards- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



image upload

2009-06-05 Thread Dhruv Adhia

I am new to django and was searching for thorough tutorial for image
upload.

What I want to do is add image upload field in backend and after
uploading image from admin section it shows in frontend

Thank you,
Dhruv Adhia



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



django.contrib.admin.util.quote does not handle spaces (%20 -> _20)

2009-06-05 Thread Matt S.

I have a primary key that allows spaces, e.g., "foo bar", which comes
up in the admin list page properly, but the
URL becomes "http://example.com/admin/myapp/mymodel/foo%20bar/"; when I
expect it to become "http://example.com/admin/myapp/mymodel/
foo_20bar/".  If you follow the link you'll get a debug page with:

"""
Page not found (404)
Request Method: GET
Request URL:http://example.com/admin/myapp/mymodel/foo%20bar/

mymodel object with primary key u'foo%20bar' does not exist.
"""

It seems that django.contrib.admin.util.quote should convert spaces
along with the other characters it already does.

I can submit a patch, but is there anyone else that's had this problem
or any concerns about backwards compatibility?  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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: image upload

2009-06-05 Thread Antoni Aloy

2009/6/5 Dhruv Adhia :
>
> I am new to django and was searching for thorough tutorial for image
> upload.
>
> What I want to do is add image upload field in backend and after
> uploading image from admin section it shows in frontend
>
like this 
http://code.google.com/p/appfusedjango/source/browse/#svn/trunk/thumbs_prj?


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: image upload

2009-06-05 Thread Dhruv Adhia
Yep Ill try and see if it works.

Thank you!

On Fri, Jun 5, 2009 at 3:32 PM, Antoni Aloy  wrote:

>
> 2009/6/5 Dhruv Adhia :
> >
> > I am new to django and was searching for thorough tutorial for image
> > upload.
> >
> > What I want to do is add image upload field in backend and after
> > uploading image from admin section it shows in frontend
> >
> like this
> http://code.google.com/p/appfusedjango/source/browse/#svn/trunk/thumbs_prj
> ?
>
>
> --
> Antoni Aloy López
> Blog: http://trespams.com
> Site: http://apsl.net
>
> >
>


-- 
Dhruv Adhia
http://thirdimension.com

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



Re: Using Django authentication for web pages outside Django?

2009-06-05 Thread BenW

I did something similar while migrating an old app to Django.  Since
auth was the first step for me in the migration, I set up the users
and session data in a table accessible by both apps and used Django
for auth while I migrated the rest.  This method requires sharing a
secret between three entities though (browser/django/old app)

On Jun 5, 1:26 pm, Adam Stein  wrote:
> I'm trying to figure out a way to use Django authentication to control
> access to web pages (on the same web server) that are NOT under Django.
>
> I have found some information regarding setting up Apache for basic
> authentication using mod_wsgi, but in this case Apache puts up it's own
> login window.
>
> I'm looking for a solution using Django and/or Apache directives that
> would put up Django's login page.  It should look exactly the same as if
> the URL were under Django control.
>
> Has anyone done anything like this?  I'm currently using Django v1.0.2
> and Apache v2.2 but can upgrade either if necessary.
> --
> Adam Stein @ Xerox Corporation       Email: a...@eng.mc.xerox.com
>
> Disclaimer: Any/All views expressed
> here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to group_by..

2009-06-05 Thread Alex Gaynor
On Fri, Jun 5, 2009 at 12:03 PM, Darren  wrote:

>
> That's cool. You don't happen to have an updated estimate of the 1.1
> release date by any chance?
>
> Thanks,
> Darren
>
> On Jun 5, 12:35 pm, Russell Keith-Magee 
> wrote:
> > On Sat, Jun 6, 2009 at 12:20 AM, Darren
> wrote:
> >
> > > Fantastic, thanks!
> >
> > > This is 1.1 only though correct?
> >
> > Apologies, I should have mentioned this. Yes, the syntax I gave will
> > only work with Django trunk (soon to be v1.1)
> >
> > Yours,
> > Russ Magee %-)
> >
>
At this point 1.1 will be released as soon as the last 30 or so bugs have
been fixed.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: How to group_by..

2009-06-05 Thread Russell Keith-Magee

On Sat, Jun 6, 2009 at 7:55 AM, Alex Gaynor wrote:
>
>
> On Fri, Jun 5, 2009 at 12:03 PM, Darren  wrote:
>>
>> That's cool. You don't happen to have an updated estimate of the 1.1
>> release date by any chance?
>>
> At this point 1.1 will be released as soon as the last 30 or so bugs have
> been fixed.

To clarifiy - of the 30 or so bugs, there are really only 10 that are
actually bugs that need fixing. The remaining 20 are mostly
translations and documentation. Based on current progress, I'd hazard
a wild guess that we're O(weeks) away from a release.

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



Re: Using Django authentication for web pages outside Django?

2009-06-05 Thread Graham Dumpleton

Have a look at:

  http://www.openfusion.com.au/labs/mod_auth_tkt/

Graham

On Jun 6, 6:26 am, Adam Stein  wrote:
> I'm trying to figure out a way to use Django authentication to control
> access to web pages (on the same web server) that are NOT under Django.
>
> I have found some information regarding setting up Apache for basic
> authentication using mod_wsgi, but in this case Apache puts up it's own
> login window.
>
> I'm looking for a solution using Django and/or Apache directives that
> would put up Django's login page.  It should look exactly the same as if
> the URL were under Django control.
>
> Has anyone done anything like this?  I'm currently using Django v1.0.2
> and Apache v2.2 but can upgrade either if necessary.
> --
> Adam Stein @ Xerox Corporation       Email: a...@eng.mc.xerox.com
>
> Disclaimer: Any/All views expressed
> here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



default settings for applications

2009-06-05 Thread ben

I'm wondering if a convention exists for dealing with applications
settings.  I'm thinking of having the default  settings to be
specified in my application in a default_settings.py file but be
overridden by any values in DJANGO_SETTINGS_MODULE.  I can do this
easily enough, but it feels like something that might be already
standardised.  Does a convention exist, and if so what is it?

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



Re: default settings for applications

2009-06-05 Thread Ben Davis
I'm not sure that there's a real "standard" for it,  but that's more or less
what I've done for my projects,  except my multi-environment setup looks
like this:

settings/
__init__.py
defaults.py
development.py
staging.py
production.py

all my default/common settings go in defaults.py,  and for each environment
(development, staging, production) I have  "from defaults import *" at the
top.   I then set DJANGO_SETTINGS_MODULE to one of the appropriate modules,
eg: "settings.development".   I'm not sure how standard that is, but it
works well for me.




On Fri, Jun 5, 2009 at 11:39 PM, ben  wrote:

>
> I'm wondering if a convention exists for dealing with applications
> settings.  I'm thinking of having the default  settings to be
> specified in my application in a default_settings.py file but be
> overridden by any values in DJANGO_SETTINGS_MODULE.  I can do this
> easily enough, but it feels like something that might be already
> standardised.  Does a convention exist, and if so what is it?
>
> >
>

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