Template Inheritance - best solution

2009-08-28 Thread eeyore


I am working on an app that currently has two main base templates.

What I would like to do is to avoid having multiple base templates and
having duplicated code withing my templates.

For example I might have navigation include in the base template, but
on the login screen there is no navigation.

What's the most flexible and efficient way to accomplish 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Error binding parameter 1 - probably unsupported type.Request Method: POST

2009-08-28 Thread riven

Error binding parameter 1 - probably unsupported type.Request Method:
POST
Request URL: http://127.0.0.1:8000/save/
Exception Type: InterfaceError
Exception Value: Error binding parameter 1 - probably unsupported
type.
Exception Location: d:\Python26\lib\site-packages\django\db\backends
\sqlite3\base.py in execute, line 193
Python Executable: d:\Python26\python.exe


this is my views.py:
def bookmark_save_page(request):
  if request.method == 'POST':
form = BookmarkSaveForm(request.POST)
if form.is_valid():
# get_or_create()will ruturn an object and a boolean value
  link, dummy = Link.objects.get_or_create(url=form.cleaned_data
['url'])
  bookmark, created = Bookmark.objects.get_or_create(
user=request.user,
link=link
  )
  bookmark.title = form.cleaned_data['title']
  if not created:
bookmark.tag_set.clear()
  tag_names = form.cleaned_data['tags'].split()
  for tag_name in tag_names:
tag, dummy = Tag.objects.get_or_create(name=tag_name)
bookmark.tag_set.add(tag)
  bookmark.save()
  return HttpResponseRedirect('/user/%s/' % request.user.username)
  else:
form = BookmarkSaveForm()
  variables = RequestContext(request, {
'form': form
  })
  return render_to_response('bookmark_save.html', variables)

this is my models.py:
class Bookmark(models.Model):
title = models.CharField(max_length=200)
user = models.ForeignKey(User)
link = models.ForeignKey(Link)
def __str__(self):
return'%s,%s'%(self.user.username,self.link.url)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: SOAPLIB issue with django upgrade

2009-08-28 Thread Wombatpm

For the record.  SOAPLIB 0.8.1 has a bug in generating the WSDL file
for Arrays.

> 
> -
> 
>  name="string"/>
> 
> 

the type declaration should be type="xs:string"


The unicode issue is being raised by lxml inside of soaplib.  Calls
from .NET clients include an xml declaration and an encoding type.
Calls from SOAPUI do not include the xml declaration.  Under python
2.6 strings are unicode so lxml raises the error.

Question to django world:  Where is the best place to fix this bug?
lxml where they punted on unicode strings effectively?  Soaplib which
should sanitize its calls?  or Django since it knows what it received
over the intertubes and is in the best position to create the string
correctly?

WombatPM


On Aug 25, 7:14 pm, Wombatpm  wrote:
> I had a working web service that I built with django 1.0.1 , python
> 2.3,soaplibusing the djangostack from BitNami.  Everything worked
> fine with the development server.  I never could get my service
> working under mod_python and the BitNami apache install.
>
> Throwing caution to the wind, I did a clean install of apache 2.2,
> mod_wsgi release candidate 4, activestate python 2.6, downloaded the
> easy_install package, and loaded the eggs for django andsoaplib.
> Installing everything went easy, and I could quickly see my new WSDL
> file.  Problem is,  anything that trys to read the WSDL file (excel
> macros, SOAPUI ) throw errors.  SOAPUI gives me a Java.Null Exception
> and the Excel macros tells me "Unicode strings with encoding
> declaration are not supported"
>
> So what am I missing?
> Is this python 2.3 - > 2.6 issue?
> or django 1.0.1 -> 1.1 issue?
> orsoaplib0.79 -> 0.81 issue?
>
> Any help would be appreciated.
>
> #
> New NON-working WSDL file
> http://my.namespace.org/soap/;
> name="HelloWorldService">
> -
> 
> -
> http://my.namespace.org/soap/;>
> 
> -
> 
> -
> 
> 
> 
> 
> 
> -
> 
> -
> 
> 
> 
> 
> 
> -
> 
> -
> 
>  name="string"/>
> 
> 
> 
> 
> 
> -
> 
> 
> 
> -
> 
> 
> 
> -
> 
> -
> 
> 
> 
> 
> 
> 
> -
> 
> -
> 
> 
> 
> 
> -
> 
> http://schemas.xmlsoap.org/
> soap/http"/>
> -
> 
> 
> -
> 
> 
> 
> -
> 
> 
> 
> 
> 
> -
> 
> -
> 
> http://10.217.51.71:8080/AIIM/hello_world/
> service"/>
> 
> 
> 
>
> #
> OLD Working WSDL file.
> 
> -
> 
> -
> http://my.namespace.org/soap/;>
> 
> -
> 
> -
> 
> 
> 
> 
> 
> 
> -
> 
> -
> 
> 
> 
> 
> -
> 
> -
> 
>  type="xs:string"/>
> 
> 
> 
> 
> 
> -
> 
> 
> 
> -
> 
> 
> 
> -
> 
> -
> 
> 
> 
> 
> 
> 
> -
> 
> -
> 
> 
> 
> 
> -
> 
> http://schemas.xmlsoap.org/
> soap/http"/>
> -
> 
> 
> -
> 
> 
> 
> -
> 
> 
> 
> 
> 
> -
> 
> -
> 
> http://10.217.51.71/AIIM/hello_world/service"/
>
> 
> 
> 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 set field value of a form object before render it?

2009-08-28 Thread Karen Tracey
On Fri, Aug 28, 2009 at 10:35 PM, hao he  wrote:

> hi.
>
> this following code show what I want to do,but 'red' line is incorrect,
>
>  if request.method == "POST":
>   form = MyForm(request.POST)
>   c = form.data["a"] + form.data["b"]
>   form.data["c"] = c
>   return render_to_response(template_name , {"form": form})
>
> how to modify it? thanks.


Perhaps if you put a few more words around what it is you are trying to do
someone might be able to offer useful help.  This code looks quite odd to
me.  You generally don't want to take values from form.data (which will not
have been normalized) but rather validate the form and then take values from
form.cleaned_data (which will be both validated and normalized).   Doing
nothing with what you've got other than displaying the form (again?) also
seems a bit odd.

Karen

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



Re: create a link from an object - template tag or?

2009-08-28 Thread Karen Tracey
On Fri, Aug 28, 2009 at 10:34 PM, MIL  wrote:

>
> Hi :o)
>
> I am attempting to create a simpler way to create my links. and I
> developed this template tag:
>
>
> class LinkNode(Node):
>def __init__(self, object):
>self.object = object
>
>def render(self, context):
>model_name = self.object.get_model_name()
>linktext = self.object.get_linktext()
>url = self.object.get_absolute_url()
>if model_name and linktext and url:
>return '%s' % (url,
> model_name.lower(),
> linktext)
>return ''
>
> @register.tag
> def create_a_link(parser, token):
># {% create_a_link to object %}
>bits = token.contents.split()
>if len(bits) != 3:
>raise TemplateSyntaxError, "create_a_link tag takes exactly
> three
> arguments"
>if bits[1] != 'to':
>raise TemplateSyntaxError, "second argument to create_a_link
> tag
> must be 'to'"
>return LinkNode(bits[2],)
>
>
> But I get this error message:
> TemplateSyntaxError at /
> Caught an exception while rendering: 'unicode' object has no attribute
> 'get_model_name'
>
> What am I doing wrong
>

You did not do the work required to access a template variable passed to
your tag.  Your tag gets a string, the name of the variable in the context,
not the variable itself.  This is covered in the doc here:

http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#passing-template-variables-to-the-tag


>
> Is there a simpler and better way to do this job?
>

Yes, see:

http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#shortcut-for-simple-tags

>From a brief glance it looks to me like what you are writing could easily be
just a simple tag, which is much easier to write and frees you from having
to resolve the variables (the step you have missed) and also check the
required number of arguments, etc.


>
> I would also like to develop something that can make it simpler to
> create tables and lists, but that later on.
>

Do read through to the end of that page on custom template tags.  Inclusion
tags may be useful for you here.

Karen

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



how to set field value of a form object before render it?

2009-08-28 Thread hao he
hi.

this following code show what I want to do,but 'red' line is incorrect,

 if request.method == "POST":
  form = MyForm(request.POST)
  c = form.data["a"] + form.data["b"]
  form.data["c"] = c
  return render_to_response(template_name , {"form": form})

how to modify it? 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
-~--~~~~--~~--~--~---



create a link from an object - template tag or?

2009-08-28 Thread MIL

Hi :o)

I am attempting to create a simpler way to create my links. and I
developed this template tag:


class LinkNode(Node):
def __init__(self, object):
self.object = object

def render(self, context):
model_name = self.object.get_model_name()
linktext = self.object.get_linktext()
url = self.object.get_absolute_url()
if model_name and linktext and url:
return '%s' % (url, 
model_name.lower(),
linktext)
return ''

@register.tag
def create_a_link(parser, token):
# {% create_a_link to object %}
bits = token.contents.split()
if len(bits) != 3:
raise TemplateSyntaxError, "create_a_link tag takes exactly 
three
arguments"
if bits[1] != 'to':
raise TemplateSyntaxError, "second argument to create_a_link tag
must be 'to'"
return LinkNode(bits[2],)


But I get this error message:
TemplateSyntaxError at /
Caught an exception while rendering: 'unicode' object has no attribute
'get_model_name'

What am I doing wrong

Is there a simpler and better way to do this job?

I would also like to develop something that can make it simpler to
create tables and lists, but that later on.

Thank you :o)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: archive_week argument error

2009-08-28 Thread Karen Tracey
On Fri, Aug 28, 2009 at 8:13 PM, Eric Montgomery  wrote:

>
> I'm experiencing a really odd problem with the archive_week generic
> view.
>
> I am trying to call it like I do a bunch of other generic views
> throughout my app, but archive_week seem to not like the arguments I'm
> giving it.
> Here is my code:
>
> return archive_week(request,
>year = year,
>week = week,
>queryset = Submission.objects.all(),
>date_field = 'pub_date',
>template_object_name = 'submission')
>
> I'm getting a TypeError with the exception "archive_week() got an
> unexpected keyword argument 'queryset'" with that code. I looked at
> the source code of the generic views and thought that maybe since the
> request, year, week, queryset, date_field arguments were not keyword
> args, I should simplify the call to:
>
> return archive_week(request,
>year,
>week,
>Submission.objects.all(),
>'pub_date',
>template_object_name = 'submission')
>
> However, this gives me a TypeError with the exception 'archive_week()
> takes exactly 3 non-keyword arguments (5 given)".
>
> The real kicker is that if I go change the name of the function in the
> django source code (I renamed it to archive_wk) and change the import
> and function call to match, both of the above examples work perfectly.
>

Sounds like you have another archive_week function defined (or imported)
after your import of Django's function.  This other one takes only three
arguments and does not include queryset among them.

Karen

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



Re: Temporary session directory

2009-08-28 Thread Russell Keith-Magee

On Sat, Aug 29, 2009 at 1:13 AM, John Barham wrote:
>
> I'd like to store per-session files so need a way to reliably create a
> per-session temp directory.  Is it reasonable to use the
> session.session_key to generate a unique name?

It's a reasonable candidate. It's unique by definition. I can't think
of any obvious reason the session key wouldn't work as a temp
directory name.

> Also, is there a way to have Django automatically run some code to
> cleanup my session once it has expired?  Or do I have to resort to
> cron?  (I'm using the file-based session backend.)

Yes. It's call cron :-)

Sessions don't expire on their own. They are evaluated as expired when
you check them against the current date. Django ships with a cleanup
method (manage.py cleanup) that you can run once a day as a cron to
find and purge stale session data from the database. This command
won't work out of the box if you're using the file backend for
sessions, but it won't be too hard to write an analogous management
command.

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



subprocess.Popen in django production - are file descriptors closed?

2009-08-28 Thread aaron smith

Hey All, quick question.

I have a small snippet of code that runs a ruby script, which I read
the stdout when it's done. But, I'm not getting the stdout when it's
in django production.

Here's my python snippet:

def generate_license(paymentForm,dsaPrivFile):
name = paymentForm.cleaned_data['firstname'] + " " +
paymentForm.cleaned_data['lastname']
product = paymentForm.cleaned_data['product_code']
command = "/usr/bin/ruby licensing/genlicense.rb " + "'" +
dsaPrivFile + "'" + " " + product + " '"+name+"'"
process = subprocess.Popen(command,stdout=subprocess.PIPE,shell=True)
stdout_value = process.communicate()[0]
print process.stdout.read()
print stdout_value
return stdout_value

I have a couple prints in there just for testing in debug. My question
is how to get this to behave normally in django production
environment. I've tried a couple different things with opening tmp
files and using that for stdout for subprocess. But no luck. Any help
is much appreciated.

Thanks

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



Serve dynamic info pages in the admin tool

2009-08-28 Thread Wim De Houwer
Hi All,

I'm new to this list and maybe i'm asking a question which might have 
passed here already, but i couldn't find a answer on the archives.

I have a Model which holds a list of people :

This is the most important info out of that model:

class Members(models.Model):
MemberId = models.AutoField(primary_key=True)
MemberFirstName = 
models.CharField(blank=True,max_length=200,verbose_name='Voornaam')
MemberLastName = 
models.CharField(blank=True,max_length=200,verbose_name='Familienaam')
MemberStreet = 
models.CharField(blank=True,max_length=200,verbose_name='Straat')
MemberHouseNumber = 
models.CharField(blank=True,max_length=6,verbose_name='Huisnummer')
MemberBusNumber = models.SmallIntegerField(blank=True,verbose_name='Bus')
MemberPostalCode = 
models.SmallIntegerField(blank=True,verbose_name='Postcode')
MemberTown = 
models.CharField(blank=True,max_length=200,verbose_name='Stad/Gemeente')
MemberBirthday = 
models.DateField(verbose_name='Geboortedatum',default=datetime.date.today)
MemberAssociation = 
models.CharField(max_length=10,choices=FederationChoices,blank=True,null=True,verbose_name='Aangesloten
 Federatie')
MemberOfficialRegNumber = 
models.CharField(blank=True,max_length=20,verbose_name='VVB/VLM 
Aansluitingsnummer')

I want to serve to my staff members a page with some statistics from the 
data in this model like:
- How many people between 0 and 18 years old
- How many people within a specific Postal Code
- How many people with active subscriptions to the official volleybal 
federation

And combinations of the above.

This still is not really a problem, the hard part is that I want to 
integrate that into a page shown in the admin interface as a link or 
semi static page.

I know it's abusing the admin a little, but I presume it must be possible.

Thanks for your answer !!

Wim





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



MultiWidget Help

2009-08-28 Thread Rob Broadhead

I have a MultiWidget class shown below that combines a selec and
textfield widget. I want to return only the value of the textinput
though. I have done a lot of Googling and have the compress-decompress
methods competely confused in my head so my question is "How does one
create a multiwidget and return only the value from one of the widgets
it contains?"

Any help will be greatly appreciated,
Rob

class Suggester(widgets.MultiWidget):
CHANGE_CODE = """
... nothing useful here...
"""

def __init__(self, attrs=None):
def tag_choices():
from django.db import connection
cursor = connection.cursor()
cursor.execute(""")
tag_list = cursor.fetchall()
return tag_list

TAG_LIST = tag_choices()
widget_list = (widgets.TextInput(attrs=attrs),widgets.Select
(choices=TAG_LIST))
super(Suggester, self).__init__(widget_list,attrs)

def render(self, name, value, attrs=None):
output = super(Suggester, self).render(name, value, attrs)
return output + mark_safe(self.CHANGE_CODE % (name,name))

def decompress(self, value):
return value

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



archive_week argument error

2009-08-28 Thread Eric Montgomery

I'm experiencing a really odd problem with the archive_week generic
view.

I am trying to call it like I do a bunch of other generic views
throughout my app, but archive_week seem to not like the arguments I'm
giving it.
Here is my code:

return archive_week(request,
year = year,
week = week,
queryset = Submission.objects.all(),
date_field = 'pub_date',
template_object_name = 'submission')

I'm getting a TypeError with the exception "archive_week() got an
unexpected keyword argument 'queryset'" with that code. I looked at
the source code of the generic views and thought that maybe since the
request, year, week, queryset, date_field arguments were not keyword
args, I should simplify the call to:

return archive_week(request,
year,
week,
Submission.objects.all(),
'pub_date',
template_object_name = 'submission')

However, this gives me a TypeError with the exception 'archive_week()
takes exactly 3 non-keyword arguments (5 given)".

The real kicker is that if I go change the name of the function in the
django source code (I renamed it to archive_wk) and change the import
and function call to match, both of the above examples work perfectly.

Is there some argument checking going that is tied to the
"archive_week" name that doesn't happen when I change the name to
"archive_wk"?

Thanks,
Eric
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Session problem?

2009-08-28 Thread David

Hi Angel,

Thanks so much for your prompt reply. Appreciated.

Reading your script, I can see that you use my_id=request.user.id. In
my code I used username = request.user.username. (notice my commented
code? I just tested request.user.id. The problem exists.)  So there is
no major difference as it has the same logic. However, the problem
loops back to my original question: why can not request.user give the
correct logined user? Why one session seems to over-write the other?

When I wrote my scripts, I used request.user first. As it could not
give me a correct user's name, I turned to session. However, session
had the same problem.

I read online DjangoBook again and again, trying to find what I missed
or what I did wrong. I spent much time on googling online. However I
can not find what caused this problem.



On Aug 28, 2:57 pm, Angel Cruz  wrote:
> Your implementation is dependent upon session cookies, and I am sure you
> have a good reason for it.  I am as stomped as you are why that is (unless
> you are like me, who confuses 127.0.0.1:8080 w/ localhost as I open multiple
> browsers in testing my site...each will have different session cookies).
>
> My implementation is dependent more on the user id being passed in from the
> login page if a user is not logged in and just passing the User object into
> the template:
>
> my view.py has:
> ---
> @login_required
> def index(request):
> .
> .
> .
>  if request.user.is_authenticated():
>      my_id=request.user.id
>      user = get_object_or_404(User, id=my_id)
>
>      context = {'my_auth_user': user, blah blah }
> .
> .
> .
>      return render_to_response('registration/detail.html',
>                                   context,
>                                   context_instance =
> RequestContext(request))
>
> my template ('registration/detail.html') has:
> -
> {{ my_auth_user.username}}
> {{ my_auth_user.first_name}}
> {{ my_auth_user.last_name}}
> {{ my_auth_user.email}}
>
> This ensures the the User object for that id belongs to is being called to
> get the username and other information.
>
> Of course, you can pass into the template the cookies and session id stuff
> by placing them in the context variable.
>
>
>
> On Fri, Aug 28, 2009 at 1:15 PM, David  wrote:
>
> > Hi Angel,
>
> > Thanks for your reply. I just tested with decorator @login_required.
> > The problem still exists.
>
> > Following is script for my homepage.
>
> > # this is the homepage
> > @login_required
> > def my_view(request):
> >    if request.session.test_cookie_worked():
> >        #username = request.user.username
> >        if request.user.is_authenticated():
> >            username = request.session['username']
> >            #username = request.user.username
> >            return render_to_response('my_view.html',
> > {'username':username})
> >    else:
> >        return HttpResponse("Please enable cookies and try again.")
>
> > Neither request.session nor request.user can give a correct user's
> > name all the time. In my login(request) I have
>
> >  if request.method == "POST" :
> >        username = request.POST['username']
> >        password = request.POST['password']
>
> >        user = authenticate(username=username, password=password)
> >        if user is not None:
> >            if user.is_active:
>
> >                request.session['password'] = password
> >                request.session['username'] = username
> >                request.session.set_expiry(0)
>
> >                login(request, user)
> > 
>
> > So, why can not session bind username to it? And why can not
> > request.user give the correct logined user? it seems to me that
> > sessions are interweaved when two users login at the same time. Or one
> > session over-writes the other? Checking session keys in session table,
> > I can see that each session key is unique.
>
> > Thanks again for your reply. I appreciate it. Do you have more ideas
> > where I missed?
>
> > On Aug 28, 12:35 pm, Angel Cruz  wrote:
> > > How does your view.py look like?
>
> > > I use the decorator @login_required right before each def that I want to
> > > ensure is viewable only to the logged-in user.
>
> > > On Fri, Aug 28, 2009 at 12:00 PM, David  wrote:
>
> > > > hello Django community,
>
> > > > I met this problem and can not find a solution. I wonder if any people
> > > > has met this problem before? Can anybody give a clue or hint how to
> > > > fix it?
>
> > > > For my project, I have enabled sessions and I use
> > > > contrib.auth.models.User. If one user logins into his/her account, all
> > > > is perfect. However, if another user logins (no matter if it is from
> > > > the same computer or from another computer), then the two users sees
> > > > each other's information in their own account.
>
> > > > I also found that
>
> > 

Re: Session problem?

2009-08-28 Thread Angel Cruz
Your implementation is dependent upon session cookies, and I am sure you
have a good reason for it.  I am as stomped as you are why that is (unless
you are like me, who confuses 127.0.0.1:8080 w/ localhost as I open multiple
browsers in testing my site...each will have different session cookies).

My implementation is dependent more on the user id being passed in from the
login page if a user is not logged in and just passing the User object into
the template:

my view.py has:
---
@login_required
def index(request):
.
.
.
 if request.user.is_authenticated():
 my_id=request.user.id
 user = get_object_or_404(User, id=my_id)

 context = {'my_auth_user': user, blah blah }
.
.
.
 return render_to_response('registration/detail.html',
  context,
  context_instance =
RequestContext(request))

my template ('registration/detail.html') has:
-
{{ my_auth_user.username}}
{{ my_auth_user.first_name}}
{{ my_auth_user.last_name}}
{{ my_auth_user.email}}

This ensures the the User object for that id belongs to is being called to
get the username and other information.

Of course, you can pass into the template the cookies and session id stuff
by placing them in the context variable.



On Fri, Aug 28, 2009 at 1:15 PM, David  wrote:

>
> Hi Angel,
>
> Thanks for your reply. I just tested with decorator @login_required.
> The problem still exists.
>
> Following is script for my homepage.
>
> # this is the homepage
> @login_required
> def my_view(request):
>if request.session.test_cookie_worked():
>#username = request.user.username
>if request.user.is_authenticated():
>username = request.session['username']
>#username = request.user.username
>return render_to_response('my_view.html',
> {'username':username})
>else:
>return HttpResponse("Please enable cookies and try again.")
>
>
> Neither request.session nor request.user can give a correct user's
> name all the time. In my login(request) I have
>
>  if request.method == "POST" :
>username = request.POST['username']
>password = request.POST['password']
>
>user = authenticate(username=username, password=password)
>if user is not None:
>if user.is_active:
>
>request.session['password'] = password
>request.session['username'] = username
>request.session.set_expiry(0)
>
>login(request, user)
> 
>
> So, why can not session bind username to it? And why can not
> request.user give the correct logined user? it seems to me that
> sessions are interweaved when two users login at the same time. Or one
> session over-writes the other? Checking session keys in session table,
> I can see that each session key is unique.
>
> Thanks again for your reply. I appreciate it. Do you have more ideas
> where I missed?
>
>
>
>
>
>
>
>
>
>
> On Aug 28, 12:35 pm, Angel Cruz  wrote:
> > How does your view.py look like?
> >
> > I use the decorator @login_required right before each def that I want to
> > ensure is viewable only to the logged-in user.
> >
> >
> >
> > On Fri, Aug 28, 2009 at 12:00 PM, David  wrote:
> >
> > > hello Django community,
> >
> > > I met this problem and can not find a solution. I wonder if any people
> > > has met this problem before? Can anybody give a clue or hint how to
> > > fix it?
> >
> > > For my project, I have enabled sessions and I use
> > > contrib.auth.models.User. If one user logins into his/her account, all
> > > is perfect. However, if another user logins (no matter if it is from
> > > the same computer or from another computer), then the two users sees
> > > each other's information in their own account.
> >
> > > I also found that
> >
> > > (1.) request.user.username gives another logined user's name instead
> > > of this one (the correct one) even though I called
> > > request.user.is_authenticated().
> >
> > > (2.)  request.session['username']  does not give the username that I
> > > assigned it earlier.
> >
> > > (3.) Old session is still there even though a user log-out correctly,
> > > closes the browser (IE) and then opens another browser (Firefox).
> >
> > > I have put "SESSION_EXPIRE_AT_BROWSER_CLOSE = True" in settings
> > > already. In my code I have request.session.set_expiry(0).
> >
> > > Checking my session table, I can see that the "expire date" for
> > > sessions are in two weeks. Does this mean that
> > > "SESSION_EXPIRE_AT_BROWSER_CLOSE = True" did not work?
> >
> > > Any suggestions?
> >
> > > Thanks so much.- Hide quoted text -
> >
> > - Show quoted text -
>  >
>

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

Remove leading and trailing whitespaces in TinyMCE text area.

2009-08-28 Thread Sonal Breed

Hi all,

I have a textfield which I am rendering as a TinyMCE widget. So the
value entered in this text field is passed in html format to the
server. I want to trim leading and trailing whitespaces from the
value. Since the value sent back is always in following format:
 some value , even though I use strip/rstrip/lstrip functions,
they are of no use.
I am currently trying to modify render(self, name, value, attrs=None):
function in tinymce/widgets.py as there the function call is directed.
Something like this:

def render(self, name, value, attrs=None):
if value is None: value = ''
value = smart_unicode(value)
value = value.strip()
final_attrs = self.build_attrs(attrs)
final_attrs['name'] = name
assert 'id' in final_attrs, "TinyMCE widget attributes must
contain 'id'"

mce_config = mygo.tinymce.settings.DEFAULT_CONFIG.copy()
mce_config.update(get_language_config(self.content_language))
if mygo.tinymce.settings.USE_FILEBROWSER:
mce_config['file_browser_callback'] = "djangoFileBrowser"
mce_config.update(self.mce_attrs)
mce_config['mode'] = 'exact'
mce_config['elements'] = final_attrs['id']
mce_config['strict_loading_mode'] = 1
mce_json = simplejson.dumps(mce_config)


html = [u'%s' % (flatatt(final_attrs),
escape(value))]
if mygo.tinymce.settings.USE_COMPRESSOR:
compressor_config = {
'plugins': mce_config.get('plugins', ''),
'themes': mce_config.get('theme', 'advanced'),
'languages': mce_config.get('language', ''),
'diskcache': True,
'debug': False,
}
compressor_json = simplejson.dumps(compressor_config)
html.append(u'tinyMCE_GZ.init(%s)' % compressor_json)
html.append(u'tinyMCE.init(%s)' % mce_json)

return mark_safe(u'\n'.join(html))


But somehow it is not getting reflected. When I replaced value with
some hard string like 'Sonal' and use .strip(), then it works, so I
guessing the type of value variable here. Did anybody have this
problem??

Joost, Can you please tell me what I am doing wrong here?

Thanks in advance,

Sincerely,
Sonal.

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



Re: Custom User Model and the Django Admin Site

2009-08-28 Thread Karen Tracey
On Fri, Aug 28, 2009 at 10:20 AM, Bryan  wrote:

>
> So, my "solution" was to duplicate this logic in my admin class, and
> it works just fine now.  Anyone have any better ideas?


Base your admin class on the UserAdmin class. Inherit whatever you need from
it and override whatever you want to customize yourself.

Karen

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



Re: QuerySet without result_cache?

2009-08-28 Thread Sam Tregar
On Thu, Aug 27, 2009 at 8:18 PM, Alex Gaynor  wrote:

>
> On Thu, Aug 27, 2009 at 5:56 PM, Sam Tregar wrote:
> > On Thu, Aug 27, 2009 at 5:47 PM, Alex Gaynor 
> wrote:
> >>
> >> Instead of iterating over the QuerySet itself, use
> >> QuerySet.iterator(), this will avoid populating the result cache.
> >
> > Thanks, works great!  This would make a good addition to the manual
> section
> > that describes how the QuerySet cache system works.  Maybe I'll see about
> a
> > patch.
> >
> > -sam
> >
> >
> > >
> >
>
> Note that the iterator() method is documented in the QuerySet
> documentation:
> http://docs.djangoproject.com/en/dev/ref/models/querysets/#iterator


Good point.  If the description had used the word "cache" I might have even
found it when I was searching for a workaround.

-sam

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
Yea, i thought about that, but for me this seems like an ugly workaround.
Dont misunderstand me, i dont know enough about django and its database
internals, but why should i use a third model for something i can access
directly?

The solution i posted above was exactly what i was looking for and what
seems logic to me, but i could of course be wrong too.


Greetings
Sven

On Fri, Aug 28, 2009 at 6:19 PM, patrickk  wrote:

>
> I could be mistaken ... but why not using a third model.
>
> C(models.model):
>   a = models.ForeignKey('A')
>   b = models.ForeignKey('B')
>
> when editing either A or B, you could use C as inlines.
>
> regards,
> patrick
>
>
> On 28 Aug., 17:18, Sven Richter  wrote:
> > But i wonder how this would help me further.
> > In the End it doesnt matter for me on which model i define the M2M
> relation.
> > But i need to access the M2M Table from both models, at least in the view
> or
> > in the template if not in the admin interface.
> >
> > I am having a hard time finding out how to achieve that.
> >
> > Any Ideas?
> >
> > Greetings
> > Sven
> >
> > On Fri, Aug 28, 2009 at 3:04 PM, Sven Richter  >wrote:
> >
> > > I've opened a bug/feature request at:
> > >http://code.djangoproject.com/ticket/11795#comment:2
> > > if someone is interested.
> >
> > > Greetings
> > > Sven
> >
> > > On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan  >wrote:
> >
> > >> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter >
> > >> wrote:
> > >> > I found this thread:
> >
> > >>http://stackoverflow.com/questions/660260/django-admin-form-for-many-.
> ..
> > >> > on Stackoverflow, but when i try the suggested TabularInline thing i
> get
> > >> the
> > >> > error:
> >
> > >> >  has no ForeignKey to
> > >>  > >> > 'politlog.entry.models.Entries'>
> >
> > >> At least with Django 1.0.x, the admin interface does not support
> > >> many-to-many relationships on inlines -- it will always return an
> > >> error like the one you got above.  Indeed, the message is technically
> > >> accurate, because m2m relationships get implemented as a separate
> > >> table, so there is no direct relationship between the two.
> > >> InlineModelAdmin works great for one-to-many but not for many-to-many.
> >
> > >> I'd also be interested in solutions to this, not having found anything
> > >> in a bunch of Google searches.  The alternative I'm planning on is
> > >> having to hand-code some views, forms, and templates that let me do
> > >> the right thing -- not a huge amount of work, but having admin do it
> > >> for us would be way cool.
> >
> > >> Craig
> >
> > >> > Greetings
> > >> > Sven
> >
> >
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: some teory help (sorry i couldnt find title for that question)

2009-08-28 Thread Chris Babcock
On Fri, 28 Aug 2009 18:03:15 +0300
Mirat Bayrak  wrote:

> Hi, i am trying to build a site thats like twitter (but not same).
> Users can delete or edit their entries in my site but i coulndt find
> how can i show options.
> 
> I want to list entries and if an entry is users (logged user i mean)
> i want to show edit end delete options. How can i do that?

You might be doing more work than you need to do:

http://pinaxproject.com/docs/dev/search.html?q=tweets_keywords=yes=default

( or http://bit.ly/Yg7qb )

Chris



signature.asc
Description: PGP signature


Re: Session problem?

2009-08-28 Thread David

Hi Angel,

Thanks for your reply. I just tested with decorator @login_required.
The problem still exists.

Following is script for my homepage.

# this is the homepage
@login_required
def my_view(request):
if request.session.test_cookie_worked():
#username = request.user.username
if request.user.is_authenticated():
username = request.session['username']
#username = request.user.username
return render_to_response('my_view.html',
{'username':username})
else:
return HttpResponse("Please enable cookies and try again.")


Neither request.session nor request.user can give a correct user's
name all the time. In my login(request) I have

 if request.method == "POST" :
username = request.POST['username']
password = request.POST['password']

user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:

request.session['password'] = password
request.session['username'] = username
request.session.set_expiry(0)

login(request, user)


So, why can not session bind username to it? And why can not
request.user give the correct logined user? it seems to me that
sessions are interweaved when two users login at the same time. Or one
session over-writes the other? Checking session keys in session table,
I can see that each session key is unique.

Thanks again for your reply. I appreciate it. Do you have more ideas
where I missed?










On Aug 28, 12:35 pm, Angel Cruz  wrote:
> How does your view.py look like?
>
> I use the decorator @login_required right before each def that I want to
> ensure is viewable only to the logged-in user.
>
>
>
> On Fri, Aug 28, 2009 at 12:00 PM, David  wrote:
>
> > hello Django community,
>
> > I met this problem and can not find a solution. I wonder if any people
> > has met this problem before? Can anybody give a clue or hint how to
> > fix it?
>
> > For my project, I have enabled sessions and I use
> > contrib.auth.models.User. If one user logins into his/her account, all
> > is perfect. However, if another user logins (no matter if it is from
> > the same computer or from another computer), then the two users sees
> > each other's information in their own account.
>
> > I also found that
>
> > (1.) request.user.username gives another logined user's name instead
> > of this one (the correct one) even though I called
> > request.user.is_authenticated().
>
> > (2.)  request.session['username']  does not give the username that I
> > assigned it earlier.
>
> > (3.) Old session is still there even though a user log-out correctly,
> > closes the browser (IE) and then opens another browser (Firefox).
>
> > I have put "SESSION_EXPIRE_AT_BROWSER_CLOSE = True" in settings
> > already. In my code I have request.session.set_expiry(0).
>
> > Checking my session table, I can see that the "expire date" for
> > sessions are in two weeks. Does this mean that
> > "SESSION_EXPIRE_AT_BROWSER_CLOSE = True" did not work?
>
> > Any suggestions?
>
> > Thanks so much.- 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: Model-level data integrity constraints?

2009-08-28 Thread William

On Aug 20, 9:06 pm, Russell Keith-Magee 
wrote:

> You've pretty much captured the current situation as well as the ways
> that you can respond.
>
> Yes, the current situation is less than ideal, and yes, this is a
> feature we want to add - hopefully it will be in v1.2.

Gotcha. Thank you, Russ.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Session problem?

2009-08-28 Thread Angel Cruz
How does your view.py look like?

I use the decorator @login_required right before each def that I want to
ensure is viewable only to the logged-in user.

On Fri, Aug 28, 2009 at 12:00 PM, David  wrote:

>
> hello Django community,
>
> I met this problem and can not find a solution. I wonder if any people
> has met this problem before? Can anybody give a clue or hint how to
> fix it?
>
> For my project, I have enabled sessions and I use
> contrib.auth.models.User. If one user logins into his/her account, all
> is perfect. However, if another user logins (no matter if it is from
> the same computer or from another computer), then the two users sees
> each other's information in their own account.
>
> I also found that
>
> (1.) request.user.username gives another logined user's name instead
> of this one (the correct one) even though I called
> request.user.is_authenticated().
>
> (2.)  request.session['username']  does not give the username that I
> assigned it earlier.
>
> (3.) Old session is still there even though a user log-out correctly,
> closes the browser (IE) and then opens another browser (Firefox).
>
> I have put "SESSION_EXPIRE_AT_BROWSER_CLOSE = True" in settings
> already. In my code I have request.session.set_expiry(0).
>
> Checking my session table, I can see that the "expire date" for
> sessions are in two weeks. Does this mean that
> "SESSION_EXPIRE_AT_BROWSER_CLOSE = True" did not work?
>
> Any suggestions?
>
> 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
-~--~~~~--~~--~--~---



Re: Single sign-in

2009-08-28 Thread Chris McCormick

Hi All,

My workmate just pointed out that somebody has now done this. Hooray!


Chris.

On Tue, May 05, 2009 at 05:15:16PM +0100, Chris McCormick wrote:
> 
> Hi All,
> 
> I am sensing a need for a library which allows for a user to sign into Django
> apps using any of their existing credentials with another site, and I wanted 
> to
> start a library project for providing this to Django programmers. I thought I
> would ask here first and see if there is something existing before I start.
> Essentially this will give the Django site creator the ability to let their
> users sign in with Facebook Connect, Google Friend Connect, Yahoo sign-in,
> Twitter Sign-in, Open ID, or generic OAuth. The module will automatically
> create a local Django user linked to whatever the Profile module is after the
> user signs in to the Django driven site.
> 
> I'd like it to be as simple to use as possible, and use as much existing code
> as possible. For example, the Open ID sign in would use the existing Open ID
> Django code which is out there. The Facebook Connect sign in would use all the
> great exising Django Facebook code that's out there. I'd also like it to be as
> modular and fail-proof as possible, so that if someone hasn't yet (for 
> example)
> set up their Facebook API key or whatever, they can still support some of the
> other login methods on their site.
> 
> I guess this will be a package consisting of mostly some different
> authentication backends, but probably a bunch of other glue code and templates
> to support the myriad of different sign-on methods which are out there.
> 
> Will this be useful to others? Does anyone want to help me by integrating 
> their
> existing external-sign-in-code into this library?
> 
> Best,
> 
> Chris.
> 
> ---
> http://mccormick.cx
> 
> > 
---
http://mccormick.cx

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
But i wonder how this would help me further.
In the End it doesnt matter for me on which model i define the M2M relation.
But i need to access the M2M Table from both models, at least in the view or
in the template if not in the admin interface.

I am having a hard time finding out how to achieve that.

Any Ideas?


Greetings
Sven

On Fri, Aug 28, 2009 at 3:04 PM, Sven Richter wrote:

> I've opened a bug/feature request at:
> http://code.djangoproject.com/ticket/11795#comment:2
> if someone is interested.
>
>
> Greetings
> Sven
>
>
> On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote:
>
>>
>> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter
>> wrote:
>> > I found this thread:
>> >
>> http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
>> > on Stackoverflow, but when i try the suggested TabularInline thing i get
>> the
>> > error:
>> >
>> >  has no ForeignKey to
>> > > 'politlog.entry.models.Entries'>
>> >
>>
>> At least with Django 1.0.x, the admin interface does not support
>> many-to-many relationships on inlines -- it will always return an
>> error like the one you got above.  Indeed, the message is technically
>> accurate, because m2m relationships get implemented as a separate
>> table, so there is no direct relationship between the two.
>> InlineModelAdmin works great for one-to-many but not for many-to-many.
>>
>> I'd also be interested in solutions to this, not having found anything
>> in a bunch of Google searches.  The alternative I'm planning on is
>> having to hand-code some views, forms, and templates that let me do
>> the right thing -- not a huge amount of work, but having admin do it
>> for us would be way cool.
>>
>> Craig
>>
>>
>> > Greetings
>> > Sven
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Session problem?

2009-08-28 Thread David

hello Django community,

I met this problem and can not find a solution. I wonder if any people
has met this problem before? Can anybody give a clue or hint how to
fix it?

For my project, I have enabled sessions and I use
contrib.auth.models.User. If one user logins into his/her account, all
is perfect. However, if another user logins (no matter if it is from
the same computer or from another computer), then the two users sees
each other's information in their own account.

I also found that

(1.) request.user.username gives another logined user's name instead
of this one (the correct one) even though I called
request.user.is_authenticated().

(2.)  request.session['username']  does not give the username that I
assigned it earlier.

(3.) Old session is still there even though a user log-out correctly,
closes the browser (IE) and then opens another browser (Firefox).

I have put "SESSION_EXPIRE_AT_BROWSER_CLOSE = True" in settings
already. In my code I have request.session.set_expiry(0).

Checking my session table, I can see that the "expire date" for
sessions are in two weeks. Does this mean that
"SESSION_EXPIRE_AT_BROWSER_CLOSE = True" did not work?

Any suggestions?

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



Re: Initial value in admin form based on url parameter

2009-08-28 Thread bhomnick

Actually figured it out by looking at the modeladmin source.  If you
have, for instance, an object called Payment with a foreign key User,
you can just go the url payment/add?user= and the user select
field will default to that user.

On Aug 28, 11:04 am, bhomnick  wrote:
> I have a model with a foreign key where I want the select box on the
> admin add form to default to whatever id is passed in a url
> parameter.  Any ideas how to do 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: some teory help (sorry i couldnt find title for that question)

2009-08-28 Thread Masood Ahmed

On Aug 28, 8:03 pm, Mirat Bayrak  wrote:
> Hi, i am trying to build a site thats like twitter (but not same). Users can
> delete or edit their entries in my site but i coulndt find how can i show
> options.
>
> I want to list entries and if an entry is users (logged user i mean) i want
> to show edit end delete options. How can i do that?

Hi Mirat,

You can user, user.is_authenticated() method to check whether the user
is
authenticated or not.

For more details please visit:
http://docs.djangoproject.com/en/dev/topics/auth/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
Ah, and google does help or at least django_snippets.
I found the solution here:
http://www.djangosnippets.org/snippets/1295

The trick is to create a column in both models and in one with the option to
not syncdb.
Its really simple, just 6 lines at all.


Greetings and a nice Weekend
Sven

On Fri, Aug 28, 2009 at 5:18 PM, Sven Richter wrote:

> But i wonder how this would help me further.
> In the End it doesnt matter for me on which model i define the M2M
> relation.
> But i need to access the M2M Table from both models, at least in the view
> or in the template if not in the admin interface.
>
> I am having a hard time finding out how to achieve that.
>
> Any Ideas?
>
>
> Greetings
> Sven
>
>
> On Fri, Aug 28, 2009 at 3:04 PM, Sven Richter wrote:
>
>> I've opened a bug/feature request at:
>> http://code.djangoproject.com/ticket/11795#comment:2
>> if someone is interested.
>>
>>
>> Greetings
>> Sven
>>
>>
>> On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote:
>>
>>>
>>> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter
>>> wrote:
>>> > I found this thread:
>>> >
>>> http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
>>> > on Stackoverflow, but when i try the suggested TabularInline thing i
>>> get the
>>> > error:
>>> >
>>> >  has no ForeignKey to
>>> >> > 'politlog.entry.models.Entries'>
>>> >
>>>
>>> At least with Django 1.0.x, the admin interface does not support
>>> many-to-many relationships on inlines -- it will always return an
>>> error like the one you got above.  Indeed, the message is technically
>>> accurate, because m2m relationships get implemented as a separate
>>> table, so there is no direct relationship between the two.
>>> InlineModelAdmin works great for one-to-many but not for many-to-many.
>>>
>>> I'd also be interested in solutions to this, not having found anything
>>> in a bunch of Google searches.  The alternative I'm planning on is
>>> having to hand-code some views, forms, and templates that let me do
>>> the right thing -- not a huge amount of work, but having admin do it
>>> for us would be way cool.
>>>
>>> Craig
>>>
>>>
>>> > Greetings
>>> > Sven
>>>
>>> >>>
>>>
>>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: some teory help (sorry i couldnt find title for that question)

2009-08-28 Thread Masklinn

On 28 Aug 2009, at 17:03 , Mirat Bayrak wrote:
> Hi, i am trying to build a site thats like twitter (but not same).  
> Users can
> delete or edit their entries in my site but i coulndt find how can i  
> show
> options.
>
> I want to list entries and if an entry is users (logged user i mean)  
> i want
> to show edit end delete options. How can i do that?
Erm... {% if user.is_authenticated %}{%  
endif %}?

Of course you'd also have to check that the current user is the owner  
of the page.

you could also build a custom templatetag to handle all that, FWIW.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



some teory help (sorry i couldnt find title for that question)

2009-08-28 Thread Mirat Bayrak
Hi, i am trying to build a site thats like twitter (but not same). Users can
delete or edit their entries in my site but i coulndt find how can i show
options.

I want to list entries and if an entry is users (logged user i mean) i want
to show edit end delete options. How can i do that?

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



Re: Many-to-many column admin interface

2009-08-28 Thread patrickk

I could be mistaken ... but why not using a third model.

C(models.model):
   a = models.ForeignKey('A')
   b = models.ForeignKey('B')

when editing either A or B, you could use C as inlines.

regards,
patrick


On 28 Aug., 17:18, Sven Richter  wrote:
> But i wonder how this would help me further.
> In the End it doesnt matter for me on which model i define the M2M relation.
> But i need to access the M2M Table from both models, at least in the view or
> in the template if not in the admin interface.
>
> I am having a hard time finding out how to achieve that.
>
> Any Ideas?
>
> Greetings
> Sven
>
> On Fri, Aug 28, 2009 at 3:04 PM, Sven Richter wrote:
>
> > I've opened a bug/feature request at:
> >http://code.djangoproject.com/ticket/11795#comment:2
> > if someone is interested.
>
> > Greetings
> > Sven
>
> > On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote:
>
> >> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter
> >> wrote:
> >> > I found this thread:
>
> >>http://stackoverflow.com/questions/660260/django-admin-form-for-many-...
> >> > on Stackoverflow, but when i try the suggested TabularInline thing i get
> >> the
> >> > error:
>
> >> >  has no ForeignKey to
> >>  >> > 'politlog.entry.models.Entries'>
>
> >> At least with Django 1.0.x, the admin interface does not support
> >> many-to-many relationships on inlines -- it will always return an
> >> error like the one you got above.  Indeed, the message is technically
> >> accurate, because m2m relationships get implemented as a separate
> >> table, so there is no direct relationship between the two.
> >> InlineModelAdmin works great for one-to-many but not for many-to-many.
>
> >> I'd also be interested in solutions to this, not having found anything
> >> in a bunch of Google searches.  The alternative I'm planning on is
> >> having to hand-code some views, forms, and templates that let me do
> >> the right thing -- not a huge amount of work, but having admin do it
> >> for us would be way cool.
>
> >> Craig
>
> >> > Greetings
> >> > Sven
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 500 error when DEBUG = False but not True

2009-08-28 Thread Tracy Reed
On Fri, Aug 28, 2009 at 08:51:46AM -0400, Karen Tracey spake thusly:
> Yes, unless you are running an SMTP server on the same machine you need to
> set EMAIL_HOST to point to one, and set whatever other EMAIL_ settings are
> required to use the server you point to:

Finally, I have some debugging output! I didn't think I needed this
because I am running an SMTP server on that machine. But it turns out
that EMAIL_HOST defaults to localhost and postfix is not listening
there. I set it to point to the right place and all is well. Thanks!

-- 
Tracy Reed
http://tracyreed.org


pgpuzG17NbNyN.pgp
Description: PGP signature


Temporary session directory

2009-08-28 Thread John Barham

I'd like to store per-session files so need a way to reliably create a
per-session temp directory.  Is it reasonable to use the
session.session_key to generate a unique name?

Also, is there a way to have Django automatically run some code to
cleanup my session once it has expired?  Or do I have to resort to
cron?  (I'm using the file-based session backend.)

Thanks,

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



Custom User Model and the Django Admin Site

2009-08-28 Thread Bryan

Hi All,

Just a quick query to see if anyone has any ideas on this one.

I have a model in my application that inherits from the django User
model.  In the admin site, without any extra configuration (just using
ModelAdmin), I get a standard edit form with the custom model's fields
as well as the django User fields.

The problem that I have is that a "change password" link is generated
(which is desirable), but the url is not routed properly - resulting
in an error.  The url looks like "/CustomModel/id/password".  Digging
around in /contrib/auth/admin.py (working off of memory :P) it looks
like UserAdmin does some voodu magic to hijack the request and execute
some "view logic" in the case of a url that looks like a password
change request.

It looks something like this (psuedocode):

 // inside of __call__ method
 if url is a password url:
  return result of change password method call on UserAdmin
object
 else
  delegate to base class

I can get the change password form to work by simply using the
UserAdmin class, but it explicitly defined the fieldsets (which of
course don't include my custom fields).  As a side note, might it be
possible to define the fieldsets in __init__?  I was under the
impression that the fieldsets are metadata for the class not the
instance.  Even if this is the case I believe I would still have to
duplicate the User model fieldsets.

Multiple inheritance doesn't seem to work (not surprisingly), and I
wouldn't be thrilled about that approach anyway.

So, my "solution" was to duplicate this logic in my admin class, and
it works just fine now.  Anyone have any better ideas?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Initial value in admin form based on url parameter

2009-08-28 Thread bhomnick

I have a model with a foreign key where I want the select box on the
admin add form to default to whatever id is passed in a url
parameter.  Any ideas how to do 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to get LANGUAGE_CODE variable in flatpage's template

2009-08-28 Thread victor

No one suffered?
On 8月28日, 下午1时20分, victor  wrote:
> i need get LANGUAGE_CODE variable in flatpage's template,but only got
> it under Debug status.
> when set debug=False,any request to flatpage will got 500 error:
> VariableDoesNotExist: Failed lookup for key [LANGUAGE_CODE] in u'[{}]'
> when set debug=True,all works.
> can anyone know how to get it in flatpage's template when disable
> debug status?
> thx a lot.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: invalid template tag

2009-08-28 Thread nixon66

Anyone have any suggestions on this. I've tried all recommendations
and still getting same Template errors

On Aug 27, 7:17 pm, nixon66  wrote:
> Still getting the same errors.
>
> On Aug 27, 7:10 pm, Javier Guerra  wrote:
>
> > On Thu, Aug 27, 2009 at 2:03 PM, nixon66 wrote:
> > > register.filter(uscurrency)
>
> > should be
>
> > register.filter ('uscurrency', uscurrency)
>
> > --
> > Javier
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Execute code after sending a http response?

2009-08-28 Thread Alex Robbins

You'll have to set something in a table and run a cron to send it
later. Django-mailer [1] has all of this set up for, along with some
other cool features. I've used it in a project before and been happy
with it.

[1] http://code.google.com/p/django-mailer/

On Aug 28, 1:10 am, Shadow  wrote:
> Hi,
>
> Is it possible to execute code after sending the actual http response?
>
> For my website, users can optionally give an email address, and if
> they do, the site sends a confirmation email. But I was thinking it's
> more logical to spend time sending the email after the signup
> confirmation page is sent to the user. Since sending the email doesn't
> affect the http reponse at all?
>
> Is this possible?
>
> cheers
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TemplateSyntaxError at /admin/ Caught an exception while rendering: (1146, "Table 'winzees.django_admin_log' doesn't exist")

2009-08-28 Thread Karen Tracey

On Aug 28, 7:57 am, "s.molinari"  wrote:
> Hiya!
> I tried to access the django admin page and I got that error. How do i
> fix it? I am stuck...
> I am new at using django as well... just to let you know ;)
>
> [snip]
> Exception Type: TemplateSyntaxError at /admin/
> Exception Value: Caught an exception while rendering: (1146, "Table
> 'winzees.django_admin_log' doesn't exist")

One of the tables needed for admin does not exist.  It appears you did
not run python manage.py syncdb after adding admin to your
INSTALLED_APPS.  You need to run syncdb after adding apps so that
their tables will be created.

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



Re: Help with the url template tags

2009-08-28 Thread Fil

For the sake of completeness and in case someone with less regex-fu
that Karen, here is the correct urlpatterns:

urlpatterns = patterns('',
   url(r'^$',
   date_based.archive_index,
   entry_info_dict,
   name='entry_archive_index'),
   url(r'^(?P\d{4})/$',
   date_based.archive_year,
   dict(entry_info_dict,
make_object_list=True, template_object_name='entry'),
   name='entry_archive_year'),
   url(r'^(?P\d{4})/(?P\d{1,2})/$',
   date_based.archive_month,
   dict(entry_info_dict, month_format='%m'),
   name='entry_archive_month'),
   url(r'^(?P\d{4})/(?P\d{1,2})/(?
P\d{1,2})/$',
   date_based.archive_day,
   dict(entry_info_dict, month_format='%m'),
   name='entry_archive_day'),
   url(r'^(?P\d{4})/(?P\d{1,2})/(?
P\d{1,2})/(?P[-\w]+)/$',
   date_based.object_detail,
   dict(entry_info_dict, slug_field='slug',
month_format='%m'),
   name='entry_detail'),
   )

On Aug 28, 3:23 pm, Fil  wrote:
> I knew it was stupid !
>
> Working now, of course.
>
> Thx a lot Karen.
>
> On Aug 28, 2:44 pm, Karen Tracey  wrote:
>
>
>
> > On Fri, Aug 28, 2009 at 4:34 AM, Phil  wrote:
>
> > > Guys,
>
> > > I have this error in my template when rendering my view: "Caught an
> > > exception while rendering: Reverse for 'entry_archive_month' with
> > > arguments '()' and keyword arguments '{'month': 8, 'year': 2009}' not
> > > found."
>
> > Your urlpattern for entry_archive_month is:
>
> > url(r'^(?P\d{4})/(?P\d{2})/ ,
> >     date_based.archive_month,
> >     dict(entry_info_dict, month_format='%m'),
> >     name='entry_archive_month'),
>
> > That (since you specified {2} after the \d where you capture the month)
> > requires exactly 2 digits in the month.  Per the error message you only have
> > one digit in the month, so no reverse can be found for the kwargs you have
> > specified.
>
> > Karen
>
> > > I've starred at my code for too long and I can't see where the problem
> > > lies. I'm sure it's a stupid and silly error, but I've look too much
> > > at my code and can't seem to figure out what is happening.
>
> > > Basically, the tag {% url blog:entry_archive_month
> > > year=date.year,month=date.month %} is throwing the 'reverse for
> > > 'entry_archive_month not found'.
> > > I've tried with args instead of kwargs (i.e.: {% url
> > > blog:entry_archive_monthdate.year,date.month %} but without success
>
> > > In another template, I have {% url blog:entry_archive_year
> > > year=year.year %} and it works perfectly fine (and even the 'args'
> > > version, which seems to indicate that this is some serious flaw in my
> > > understanding of url namespace and reversing in django).
>
> > > I'm just baffled and to tired to see clearly what is my stupipd
> > > mistake.
>
> > > Here is the traceback:http://dpaste.com/86470/
>
> > > Here is some part of my code (the two urls.py):
> > >http://dpaste.com/hold/86487/
>
> > > Can anyone help me with this one ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Admin inlines onetoone related object not saved

2009-08-28 Thread Jean Stebens

Hi there,

I have the following models:

class A(models.Model):
id = models.AutoField(primary_key=True)

class B(models.Model):
mya = models.OneToOneField(A, primary_key=True)
text = models.TextField(default='Init')

In admin interface, I have used an inline to include B when
changing/adding an A. Adding/Changing an A without touching the B inline
results in A beeing saved, but not B. Changing the textfield from B into
sth other than default and it works, but I want to keep the default as
is - Is there any solution for this?

Thanks!
Jean


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: '%d-%m-%Y' format for DateTimefield in django

2009-08-28 Thread Karen Tracey

On Aug 28, 3:19 am, Jigar  wrote:
> Hi All,
>
> I am trying to add the '%d-%m-%Y' format in DateTimefield. As django
> does not support this format so when I add different date formats, it
> gives "invalid date/time" error in django console.This error occurs
> because the form is not valid(form.is_valid()) as above mentioned date
> format is not supported by django.

It is not correct to say that Django does not support that format.
That format is not one that is accepted by default as an input format
for the DateTimeField form field.  However, you can easily specify
your own input_formats and then your form will accept that format:

http://docs.djangoproject.com/en/dev/ref/forms/fields/#datetimefield

> Also, I want to store this date in
> the mysql database.
>

It does not make sense to say you want to store that format in MySQL.
The value stored in MySQL is a DATETIME, independent of any particular
format.  Since you are using Django you do not need to be concerned
with what format is used when Django stores the data to MySQL or
retrieves it from MySQL.  What you need to adjust is the input formats
your field accepts, and the output format used by your form field's
widget to display existing data (see the format parameter here, for
example: 
http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.DateTimeInput)

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



Re: show user and date in change_list

2009-08-28 Thread Sandra Django
Thank's Alex, but it don't seem the problem, because I tested with another
method name "author" and "pub_date", and returns (None) too. Why?

On Thu, Aug 27, 2009 at 5:03 PM, Alex Gaynor  wrote:

>
> On Thu, Aug 27, 2009 at 12:18 PM, Sandra Django
> wrote:
> > Hi, I want display in change_list view, user who added an object and
> date. I
> > did that:
> > - models.py ---
> >>
> >> class One(models.Model):
> >> ..
> >> def user(self):
> >> return self.user.username
> >>
> >> def date(self):
> >> return self.date
> >
> >
> >>
> >> -- admin.py ---
> >> class OneAdmin(admin.ModelAdmin):
> >> list_display = ['name', 'user', 'date']
> >
> >
> >>
> >> But both functions returns (None). Why I can do it?
> >>
> >>
> >
> >
> > >
> >
>
> You can't have methods with the same names as fields on your models,
> since this would mean an object having two attributes by the same
> name.
>
> 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
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me
>
> >
>

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



Re: Django scalability with files

2009-08-28 Thread James Bennett

On Thu, Aug 27, 2009 at 2:22 PM, Rafael Ferreira wrote:
> The queue idea is a good one, and you can use Gearman to do that really
> easily. Another, even simpler, way to handle this is to use some kind of
> shared NFS mount for the storage. All things being equal, scaling a filer or
> SAN will be much easier than scaling your DB, specially if - like most
> similar cases I've seen in the past - most of you db becomes blob data.

There are also distributed file stores like MogileFS.


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



Re: Help with the url template tags

2009-08-28 Thread Fil

I knew it was stupid !

Working now, of course.

Thx a lot Karen.

On Aug 28, 2:44 pm, Karen Tracey  wrote:
> On Fri, Aug 28, 2009 at 4:34 AM, Phil  wrote:
>
> > Guys,
>
> > I have this error in my template when rendering my view: "Caught an
> > exception while rendering: Reverse for 'entry_archive_month' with
> > arguments '()' and keyword arguments '{'month': 8, 'year': 2009}' not
> > found."
>
> Your urlpattern for entry_archive_month is:
>
> url(r'^(?P\d{4})/(?P\d{2})/ ,
>     date_based.archive_month,
>     dict(entry_info_dict, month_format='%m'),
>     name='entry_archive_month'),
>
> That (since you specified {2} after the \d where you capture the month)
> requires exactly 2 digits in the month.  Per the error message you only have
> one digit in the month, so no reverse can be found for the kwargs you have
> specified.
>
> Karen
>
>
>
>
>
> > I've starred at my code for too long and I can't see where the problem
> > lies. I'm sure it's a stupid and silly error, but I've look too much
> > at my code and can't seem to figure out what is happening.
>
> > Basically, the tag {% url blog:entry_archive_month
> > year=date.year,month=date.month %} is throwing the 'reverse for
> > 'entry_archive_month not found'.
> > I've tried with args instead of kwargs (i.e.: {% url
> > blog:entry_archive_monthdate.year,date.month %} but without success
>
> > In another template, I have {% url blog:entry_archive_year
> > year=year.year %} and it works perfectly fine (and even the 'args'
> > version, which seems to indicate that this is some serious flaw in my
> > understanding of url namespace and reversing in django).
>
> > I'm just baffled and to tired to see clearly what is my stupipd
> > mistake.
>
> > Here is the traceback:http://dpaste.com/86470/
>
> > Here is some part of my code (the two urls.py):
> >http://dpaste.com/hold/86487/
>
> > Can anyone help me with this one ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
I've opened a bug/feature request at:
http://code.djangoproject.com/ticket/11795#comment:2
if someone is interested.


Greetings
Sven

On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote:

>
> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter
> wrote:
> > I found this thread:
> >
> http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
> > on Stackoverflow, but when i try the suggested TabularInline thing i get
> the
> > error:
> >
> >  has no ForeignKey to
>  > 'politlog.entry.models.Entries'>
> >
>
> At least with Django 1.0.x, the admin interface does not support
> many-to-many relationships on inlines -- it will always return an
> error like the one you got above.  Indeed, the message is technically
> accurate, because m2m relationships get implemented as a separate
> table, so there is no direct relationship between the two.
> InlineModelAdmin works great for one-to-many but not for many-to-many.
>
> I'd also be interested in solutions to this, not having found anything
> in a bunch of Google searches.  The alternative I'm planning on is
> having to hand-code some views, forms, and templates that let me do
> the right thing -- not a huge amount of work, but having admin do it
> for us would be way cool.
>
> Craig
>
>
> > Greetings
> > Sven
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 500 error when DEBUG = False but not True

2009-08-28 Thread Karen Tracey
On Fri, Aug 28, 2009 at 7:01 AM, Tracy Reed  wrote:

> Do I
> have to give django an smtp server address or anything else to enable
> it to report errors and tracebacks somewhere?
>

Yes, unless you are running an SMTP server on the same machine you need to
set EMAIL_HOST to point to one, and set whatever other EMAIL_ settings are
required to use the server you point to:

http://docs.djangoproject.com/en/dev/ref/settings/#email-host

Karen

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



'%d-%m-%Y' format for DateTimefield in django

2009-08-28 Thread Jigar

Hi All,

I am trying to add the '%d-%m-%Y' format in DateTimefield. As django
does not support this format so when I add different date formats, it
gives "invalid date/time" error in django console.This error occurs
because the form is not valid(form.is_valid()) as above mentioned date
format is not supported by django. Also, I want to store this date in
the mysql database.

I have tried following:
I have converted the string (date entered in html page) in to the date
object which is in '%d-%m-%Y' in views.py before form_is_valid()
called. Now I am not able to set the attribute value for a particular
field so that form.is_valid() gets the correct date object.

Any Ideas for this issue ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



TemplateSyntaxError at /admin/ Caught an exception while rendering: (1146, "Table 'winzees.django_admin_log' doesn't exist")

2009-08-28 Thread s.molinari

Hiya!
I tried to access the django admin page and I got that error. How do i
fix it? I am stuck...
I am new at using django as well... just to let you know ;)

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.1
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'winzees.competitions',
 'winzees.items',
 'winzees.members',
 'winzees.favourites',
 'winzees.blog',
 'winzees.advertisements',
 'winzees.transfers']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Template error:
In template /usr/local/lib/python2.6/dist-packages/django/contrib/
admin/templates/admin/index.html, error at line 57
   Caught an exception while rendering: (1146, "Table
'winzees.django_admin_log' doesn't exist")
   47 : 


   48 : {% endblock %}


   49 :


   50 : {% block sidebar %}


   51 : 


   52 : 


   53 : {% trans 'Recent Actions' %}


   54 : {% trans 'My Actions' %}


   55 : {% load log %}


   56 : {% get_admin_log 10 as admin_log for_user user %}


   57 :  {% if not admin_log %}


   58 : {% trans 'None available' %}


   59 : {% else %}


   60 : 


   61 : {% for entry in admin_log %}


   62 : 


   63 : {% if entry.is_deletion %}


   64 : {{ entry.object_repr }}


   65 : {% else %}


   66 : 
{{ entry.object_repr }}


   67 : {% endif %}


Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py" in get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in wrapper
  196. return self.admin_view(view, cacheable)(*args,
**kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in inner
  186. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in index
  374. context_instance=context_instance
File "/usr/local/lib/python2.6/dist-packages/django/shortcuts/
__init__.py" in render_to_response
  20. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/template/
loader.py" in render_to_string
  108. return t.render(context_instance)
File "/usr/local/lib/python2.6/dist-packages/django/template/
__init__.py" in render
  178. return self.nodelist.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
__init__.py" in render
  779. bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.6/dist-packages/django/template/debug.py"
in render_node
  71. result = node.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
loader_tags.py" in render
  97. return compiled_parent.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
__init__.py" in render
  178. return self.nodelist.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
__init__.py" in render
  779. bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.6/dist-packages/django/template/debug.py"
in render_node
  71. result = node.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
loader_tags.py" in render
  97. return compiled_parent.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
__init__.py" in render
  178. return self.nodelist.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
__init__.py" in render
  779. bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.6/dist-packages/django/template/debug.py"
in render_node
  71. result = node.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
loader_tags.py" in render
  24. result = self.nodelist.render(context)
File "/usr/local/lib/python2.6/dist-packages/django/template/
__init__.py" in render
  779. bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.6/dist-packages/django/template/debug.py"
in 

Re: ugettext() and ugettext_lazy() - error and difference

2009-08-28 Thread Karen Tracey
On Fri, Aug 28, 2009 at 2:49 AM, Léon Dignòn  wrote:

>
> Hi,
>
> I don't exactly understand the difference between ugettext() and
> ugettext_lazy(). I read the documentation and I've read that
> ugettext_lazy translates a string on access. Sounds more efficient.
> But why do I get this error on that code?
>
> from django.db import models
> from django.utils.translation import ugettext_lazy as _
>
> class Country(models.Model):
>name   = models.CharField(max_length=256, unique=True)
>name_iso_2 = models.CharField(max_length=2,   unique=True,
> help_text='http://de.wikipedia.org/wiki/ISO-3166-1-Kodierliste')
>name_iso_3 = models.CharField(max_length=3,   unique=True,
> help_text='http://de.wikipedia.org/wiki/ISO-3166-1-Kodierliste')
>
>def __unicode__(self):
>return _(self.name)
>
>
>
> Exception Type: TemplateSyntaxError at /admin/skins/country/
> Exception Value: Caught an exception while rendering: coercing to
> Unicode: need string or buffer, __proxy__ found


Python's unicode function must return a unicode object.  If your __unicode__
implementation does not return a unicode object then Python coerces it to
unicode.  But there are only a limited number of types that Python can
coerce to unicode (strings and buffers, or so the message implies).  So if
you return neither a unicode object, nor a string or buffer, then you get
this error.

There are places where ugettext_lazy cannot be used.  This would appear to
be one of them.

Karen

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



Re: Help with the url template tags

2009-08-28 Thread Karen Tracey
On Fri, Aug 28, 2009 at 4:34 AM, Phil  wrote:

>
> Guys,
>
> I have this error in my template when rendering my view: "Caught an
> exception while rendering: Reverse for 'entry_archive_month' with
> arguments '()' and keyword arguments '{'month': 8, 'year': 2009}' not
> found."


Your urlpattern for entry_archive_month is:

url(r'^(?P\d{4})/(?P\d{2})/ ,
date_based.archive_month,
dict(entry_info_dict, month_format='%m'),
name='entry_archive_month'),

That (since you specified {2} after the \d where you capture the month)
requires exactly 2 digits in the month.  Per the error message you only have
one digit in the month, so no reverse can be found for the kwargs you have
specified.

Karen


>
>
> I've starred at my code for too long and I can't see where the problem
> lies. I'm sure it's a stupid and silly error, but I've look too much
> at my code and can't seem to figure out what is happening.
>
> Basically, the tag {% url blog:entry_archive_month
> year=date.year,month=date.month %} is throwing the 'reverse for
> 'entry_archive_month not found'.
> I've tried with args instead of kwargs (i.e.: {% url
> blog:entry_archive_monthdate.year,date.month %} but without success
>
> In another template, I have {% url blog:entry_archive_year
> year=year.year %} and it works perfectly fine (and even the 'args'
> version, which seems to indicate that this is some serious flaw in my
> understanding of url namespace and reversing in django).
>
> I'm just baffled and to tired to see clearly what is my stupipd
> mistake.
>
> Here is the traceback: http://dpaste.com/86470/
>
> Here is some part of my code (the two urls.py):
> http://dpaste.com/hold/86487/
>
> Can anyone help me with this one ?
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Execute code after sending a http response?

2009-08-28 Thread Daniel Roseman

On Aug 28, 10:00 am, Jarek Zgoda  wrote:
> Wiadomość napisana w dniu 2009-08-28, o godz. 08:10, przez Shadow:
>
> > Is it possible to execute code after sending the actual http response?
>
> > For my website, users can optionally give an email address, and if
> > they do, the site sends a confirmation email. But I was thinking it's
> > more logical to spend time sending the email after the signup
> > confirmation page is sent to the user. Since sending the email doesn't
> > affect the http reponse at all?
>
> > Is this possible?
>
> Yes, but not in view function, you can use signals. 
> Seehttp://docs.djangoproject.com/en/dev/topics/signals/.

Signals won't help, they are still executed in-process.
--
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: print PDF on windows

2009-08-28 Thread Sam Lai

2009/8/27 mettwoch :
>
> Apache is running under a system account. A quick test of running
> Apache under my user account enabled printing indeed. I'll follow your
> suggestion and create a dedicated user with restricted rights to run
> Apache under.

I'd leave Apache running under the system account - that's how it is
by default, and I would think that there are good reasons for it.

Try using python to impersonate another user to launch foxit/adobe
reader in another user account context, or the easier way is to
leverage the 'runas' command to run an app under another user account.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/runas.mspx?mfr=true

> Thanks so much for your help
>
> Marc
>
> On Aug 27, 2:42 am, Sam Lai  wrote:
>> 2009/8/27 mettwoch :
>>
>>
>>
>> > I'm now using Foxit Reader. Thanks for the tip. The following works
>> > perfectly in the Django shell and prints the document in
>> > attachment.file.path to the specified network printer:
>>
>> > p = Popen (['C:\\Program Files\\Foxit Software\\Foxit Reader\\Foxit
>> > Reader.exe',
>> >        '/t',
>> >        attachment.file.path,
>> >        'SM03\\HPCOMPTOIR0'])
>>
>> > The same code works silently in a Apache / mod_wsgi context but does
>> > not produce any result on the printer. Do You have any ideas?
>>
>> Could be a permissions issue - what user is apache running under?
>>
>> Also, you might want to try enabling the 'allow service to interact
>> with desktop' option to see if that works. If it does, you might have
>> to look at another solution or somehow impersonating another user to
>> do the printing as there are security risks associated with this
>> option.
>>
>>
>>
>> > Marc
>>
>> > On Aug 26, 1:46 am, Sam Lai  wrote:
>> >> Use python to call a PDF reader via the command line -
>>
>> >>http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm
>>
>> >>http://foxit.vo.llnwd.net/o28/pub/foxit/manual/enu/FoxitReader30_Manu...
>> >> (see the Command Line section)
>>
>> >> Depending on the complexity of your PDFs, I'd recommend using Foxit
>> >> instead; Adobe Reader on windows isn't the most stable especially when
>> >> it comes to open many PDFs - you might have to manually manage
>> >> instances to make sure it doesn't eat up all your memory. Foxit Reader
>> >> however doesn't render all PDFs perfectly, or at least the same way
>> >> that Adobe Reader does. YMMV though.
>>
>> >> 2009/8/26 mettwoch :
>>
>> >> > How do the Django people handle printing directly on Windows? I
>> >> > remembered abouthttp://timgolden.me.uk/python/win32_how_do_i/print.html,
>> >> > but unfortunately his method for PDFs only print on the default
>> >> > printer. I need the server to produce the PDF, save it (works already)
>> >> > and send it to a specific shared printer on the network. The printer
>> >> > should be determined from a table that holds 'host' - 'printer' pairs
>> >> > e.g. ('PC01', '\\PC01\PR01'). The host ('PC01') determined from the
>> >> > http request allows to choose the right printer ('\\PC01\PR01') from
>> >> > that table.
>>
>> >> > Printing should be executed directly when the user has submitted the
>> >> > request. Any solution that pops up the document locally in a PDFReader
>> >> > and where the user has to hit the print button is not viable.
>>
>> >> > Kindly Yours
>> >> > Marc
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Model Theory 101 - Video Sharing App

2009-08-28 Thread thornomad

Hi thanks for the response - I had looked at oembed, but it didn't
seem like it would grab the title, description, play count, etc ...
which was the information I was going for.  There is also a markdown
plugin, that seems to work similiar.  If I went the route of just
posting video (which I may, if I get tired of working on the complex)
this would work great.  I'm also looked at django-syncr, which is
similiar to what I am aiming for ...

On Aug 27, 10:08 am, Bill Freeman  wrote:
> Look at django-oembed.  A CharField will serve for every (supported)
> provider.
>
> On Wed, Aug 26, 2009 at 8:17 PM, thornomad  wrote:
>
> > Hi - need some suggestions.
>
> > I am trying to put together an app that allows users to submit links
> > to videos at popular video sharing sites (e.g., youtube, vimeo, etc)
> > -- the links get submitted, data about the video (title, description,
> > play count, etc) is collected from the respective site and populates
> > model fields, and the video entry is queued for review.
>
> > Caveats: I would like to keep the original "synced" data in its own
> > field and the "approved" data (as edited) in separate field.  I
> > imagine that the data first gets brought into the "edit" field, admin
> > may make changes and save, but the "originating" data will remain
> > separate and continue to be updated (synced).
>
> > This means I need at least
>
> > I am stuck, though, on the most appropriate/logical approach to this
> > app.  Some approaches I've considered.
>
> > [1] My first thought is to create base model "Video" (with the main
> > fields) and then create child models like YoutubeVideo and VimeoVideo
> > and BlipVideo ... when the user submits a url, would do a regex on it
> > in the view, and send it through the appropriate child class.  I could
> > then grab the base Video model in my views (not having to distinguish
> > the type of video) and use a "leaf" technique (eg,
> >http://www.djangosnippets.org/snippets/1031/) to run the child's
> > "sync" or "update" command.  CONS: seems tacky and not easy to build
> > on.  The leaf technique isn't working when I override the save()
> > function in leaf models.
>
> > [2] Perhaps create only a single model and then create separate
> > classes/functions to handle the the syncing of data based on the
> > URLField data ... so, perhaps when Video.update() is called, it would
> > run the logic then to see what kind of url it has, and how to update
> > it.  CONS: I thought maybe I could just create a ForeignKey field to a
> > non-model group of classes with common functions (update, sync,
> > etc) ... but I am not sure how, or if, I can do that.
>
> > [3] Outsourcing.
>
> > Hope this makes sense and folks have some feedback about how they
> > might approach this.  I would like this to be easily expandable -- for
> > example, add YouTube and Vimeo support to start, and easily add other
> > sites without having to "hack" it.
>
> > I know this is a huge question, but am interested in your "Design
> > Approach" thoughts ...
>
> > Thanks,
> > Damon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 500 error when DEBUG = False but not True

2009-08-28 Thread Tracy Reed
On Fri, Aug 28, 2009 at 11:21:07AM +0200, Daniel Hepper spake thusly:
> The stacktrace shows that the 500.html template is missing [1], so go
> ahead and create one. You should also make sure that you have
> configured the admin email address and settings for sending mail
> correctly, so Django can send you a traceback by mail when DEBUG =
> False

Thanks Jarek and Daniel. I saw that message in the traceback but
thought that a 500 page was only required to show something sensible
to the end user merely saying there had been an error.

I have put in a 500.html template and I have configured my email
address in the settings.py to a valid email address. The system is
configured to deliver mail. But it does not appear to be sending any
mail nor am I getting anything in the apache error_log anymore. I just
get my 500.html template displayed.

So it seems I still have no info on what the real problem is. Do I
have to give django an smtp server address or anything else to enable
it to report errors and tracebacks somewhere?

-- 
Tracy Reed
http://tracyreed.org


pgpQZpJz7BATX.pgp
Description: PGP signature


Re: Django test suite does not discover test method "test_string_regex"

2009-08-28 Thread Gregor Müllegger

I discovered that it gets not execute by looking at the coverage statistics.

But you're totally right. I had a second method that is called the same.
Very embarrassing for me. Sorry.

Gregor

2009/8/28 Karen Tracey :
> On Thu, Aug 27, 2009 at 2:21 PM, Gregor Müllegger 
> wrote:
>>
>> Hi,
>>
>> i have an issue with the standard test runner of django. If i try to
>> run the testsuite of an app everything gets executed in the right
>> fashion. While all executed tests pass without errors, the test method
>> "test_string_regex" is not evaluated! If i rename the method to any
>> athor name like "test_string_regex2", "test_string__regex" or
>> "test__string_regex" it is discovered by the test suite.
>> I also can execute the single test with the "python manage.py test
>> applabel.TestCaseName.test_string_regex".
>>
>> This seams very scary to me.
>> Is this a bug in the django testrunner?
>
> Unlikely.  More likely there is something in your test suite causing this.
> How are you determining that this method is not running when you run the
> full suite?  Are you sure you don't have multiple test_string_regex methods
> defined in this TestCase?
>
> FWIW, I just tried adding a method with that name to a test suite I have and
> it runs fine.
>
> Karen
>
> >
>

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



Re: 500 error when DEBUG = False but not True

2009-08-28 Thread Daniel Hepper

The stacktrace shows that the 500.html template is missing [1], so go
ahead and create one. You should also make sure that you have
configured the admin email address and settings for sending mail
correctly, so Django can send you a traceback by mail when DEBUG =
False

Cheers,
Daniel

[1] 
http://docs.djangoproject.com/en/1.0/topics/http/views/#the-500-server-error-view

On Fri, Aug 28, 2009 at 10:07 AM, Tracy Reed wrote:
> I appear to have a bit of a heisenbug. When I have debug = True
> everything works perfectly. When I have debug = False I get a 500
> error when accessing two views in particular. I'm not sure what makes
> those views special or why the app would behave differently depending
> on whether debug is True or False (aside from the obvious displaying
> of templates vs debugging info such as tracebacks). When I get the 500
> Internal server error the following appears in the apache error_log:
>
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112] mod_wsgi
> (pid=2046): Exception occurred processing WSGI script
> '/var/spool/filter/email_archive/django.wsgi'., referer:
> http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112] Traceback
> (most recent call last):, referer: http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
> "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py", line
> 241, in __call__, referer: http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]
> response = self.get_response(request), referer:
> http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
> "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line
> 134, in get_response, referer: http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]     return
> self.handle_uncaught_exception(request, resolver, exc_info), referer:
> http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
> "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line
> 166, in handle_uncaught_exception, referer:
> http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]     return
> callback(request, **param_dict), referer:
> http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
> "/usr/lib/python2.4/site-packages/django/views/defaults.py", line 23,
> in server_error, referer: http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]     t =
> loader.get_template(template_name) # You need to create a 500.html
> template., referer: http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
> "/usr/lib/python2.4/site-packages/django/template/loader.py", line 81,
> in get_template, referer: http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]     source,
> origin = find_template_source(template_name), referer:
> http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
> "/usr/lib/python2.4/site-packages/django/template/loader.py", line 74,
> in find_template_source, referer: http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]     raise
> TemplateDoesNotExist, name, referer: http://mx1.mydomain.com/unsure
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]
> TemplateDoesNotExist: 500.html, referer:
> http://mx1.mydomain.com/unsure
>
> Any ideas? I am using Django 1.1 on CentOS 5.3 with Apache 2.2.3 in
> case it matters.
>
> Thanks
>
> --
> Tracy Reed
> http://tracyreed.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Generating slugs

2009-08-28 Thread esatterwh...@wi.rr.com

You might look in to the Autoslug field in django command extensions
http://code.google.com/p/django-command-extensions/

the autoslug field is never displayed on a form, but you specify which
fields from which to create the slug from. so you can do it how ever
you want. I've found it very helpful.

On Aug 27, 8:55 am, RubenK  wrote:
> I've setup my 'prepopulate_fields' so that it should automatically
> enter a slug in the admin site, however when I click the 'add' link
> it gives me the following error:
>
> "Key 'slug' not found in Form"
>
> I've triple checked all my models and database tables and everything
> seems to be in order so I'm sort of stuck now!
> These are my files:
>
> http://dpaste.com/hold/86096/- models.pyhttp://dpaste.com/hold/86098/- 
> admin.py
>
> Could anyone please assist me?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 500 error when DEBUG = False but not True

2009-08-28 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-08-28, o godz. 10:07, przez Tracy Reed:

> I appear to have a bit of a heisenbug. When I have debug = True
> everything works perfectly. When I have debug = False I get a 500
> error when accessing two views in particular. I'm not sure what makes
> those views special or why the app would behave differently depending
> on whether debug is True or False (aside from the obvious displaying
> of templates vs debugging info such as tracebacks). When I get the 500
> Internal server error the following appears in the apache error_log:
>
> [Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]
> TemplateDoesNotExist: 500.html, referer:
> http://mx1.mydomain.com/unsure
>
> Any ideas? I am using Django 1.1 on CentOS 5.3 with Apache 2.2.3 in
> case it matters.


You do not have 500.html template and this error hides actual source  
of the error. See 
http://docs.djangoproject.com/en/dev/topics/http/views/#the-500-server-error-view
 
.

When DEBUG == True the 500 errors are processed by debugging view.

-- 
Artificial intelligence stands no chance against natural stupidity

Jarek Zgoda, R, 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
-~--~~~~--~~--~--~---



Re: Execute code after sending a http response?

2009-08-28 Thread Matthias Kestenholz

On Fri, Aug 28, 2009 at 8:10 AM, Shadow wrote:
>
> Hi,
>
> Is it possible to execute code after sending the actual http response?
>
> For my website, users can optionally give an email address, and if
> they do, the site sends a confirmation email. But I was thinking it's
> more logical to spend time sending the email after the signup
> confirmation page is sent to the user. Since sending the email doesn't
> affect the http reponse at all?
>
> Is this possible?
>

As Daniel said, you could use a queueing service or a database table
to store the fact that an email should be sent later.

Wouldn't you want to show the user an error message if sending the email failed?

Btw, the time needed to send an email is not so long normally. I think
the benefits (possibility of showing an error message, less
complexity) outweigh the downsides (a bit longer processing time)


Matthias


-- 
FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Help with the url template tags

2009-08-28 Thread Phil

Guys,

I have this error in my template when rendering my view: "Caught an
exception while rendering: Reverse for 'entry_archive_month' with
arguments '()' and keyword arguments '{'month': 8, 'year': 2009}' not
found."

I've starred at my code for too long and I can't see where the problem
lies. I'm sure it's a stupid and silly error, but I've look too much
at my code and can't seem to figure out what is happening.

Basically, the tag {% url blog:entry_archive_month
year=date.year,month=date.month %} is throwing the 'reverse for
'entry_archive_month not found'.
I've tried with args instead of kwargs (i.e.: {% url
blog:entry_archive_monthdate.year,date.month %} but without success

In another template, I have {% url blog:entry_archive_year
year=year.year %} and it works perfectly fine (and even the 'args'
version, which seems to indicate that this is some serious flaw in my
understanding of url namespace and reversing in django).

I'm just baffled and to tired to see clearly what is my stupipd
mistake.

Here is the traceback: http://dpaste.com/86470/

Here is some part of my code (the two urls.py): http://dpaste.com/hold/86487/

Can anyone help me with this one ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Generating slugs

2009-08-28 Thread Ruben Knol
That is excellent! thanks for pointing this out!!

On Fri, Aug 28, 2009 at 11:04 AM, esatterwh...@wi.rr.com <
esatterwh...@wi.rr.com> wrote:

>
> You might look in to the Autoslug field in django command extensions
> http://code.google.com/p/django-command-extensions/
>
> the autoslug field is never displayed on a form, but you specify which
> fields from which to create the slug from. so you can do it how ever
> you want. I've found it very helpful.
>
> On Aug 27, 8:55 am, RubenK  wrote:
> > I've setup my 'prepopulate_fields' so that it should automatically
> > enter a slug in the admin site, however when I click the 'add' link
> > it gives me the following error:
> >
> > "Key 'slug' not found in Form"
> >
> > I've triple checked all my models and database tables and everything
> > seems to be in order so I'm sort of stuck now!
> > These are my files:
> >
> > http://dpaste.com/hold/86096/- 
> > models.pyhttp://dpaste.com/hold/86098/-admin.py
> >
> > Could anyone please assist me?
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Execute code after sending a http response?

2009-08-28 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-08-28, o godz. 08:10, przez Shadow:

> Is it possible to execute code after sending the actual http response?
>
> For my website, users can optionally give an email address, and if
> they do, the site sends a confirmation email. But I was thinking it's
> more logical to spend time sending the email after the signup
> confirmation page is sent to the user. Since sending the email doesn't
> affect the http reponse at all?
>
> Is this possible?


Yes, but not in view function, you can use signals. See 
http://docs.djangoproject.com/en/dev/topics/signals/ 
.

-- 
Artificial intelligence stands no chance against natural stupidity

Jarek Zgoda, R, 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
-~--~~~~--~~--~--~---



Custom form validation request or user-based

2009-08-28 Thread Enrico Sartorello
Hi,
i'm developing a Django application where i need to differentiate the
validation of an admin-site model form between different users: some user
must respect some particular restrictions (imposed via "clean_*" methods)
while others should do what they want without them.

The problem arises because during form validation i cannot access any
request object (so i can't build a permission-based criteria), and checking
everything in other places (like Model_admin.save_model() method or with
signals) can't do the job because there i can't raise form's validation
errors.

I've searched on the net but seems i cannot find any solution for that
problem.

Any hints?

Thanks for the attention


-- 
Enrico Sartorello

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Execute code after sending a http response?

2009-08-28 Thread Shadow

Hi,

Is it possible to execute code after sending the actual http response?

For my website, users can optionally give an email address, and if
they do, the site sends a confirmation email. But I was thinking it's
more logical to spend time sending the email after the signup
confirmation page is sent to the user. Since sending the email doesn't
affect the http reponse at all?

Is this possible?

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



Help with admin inlines

2009-08-28 Thread Léon Dignòn

Hi,

I tried to stack two models in the admin interface. Any ideas why I
get this error?

issubclass() arg 1 must be a class
File "C:\Django\myproject\myapp\admin.py" in 
  22. admin.site.register(Manufacturer, ManufacturerAdmin)

admin.py

class AeroplaneInline(admin.TabularInline):
model = Aeroplane
extra = 3

class ManufacturerAdmin(admin.ModelAdmin):
list_display = ('name', 'country', 'aeroplane.name')
inlines = ('AeroplaneInline',)

admin.site.register(Manufacturer, ManufacturerAdmin) # This is line 22



models.py

class Manufacturer(models.Model):
country = models.ForeignKey(Country)
name= models.CharField(max_length=32, unique=True)

class Aeroplane(models.Model):
manufacturer = models.ForeignKey(Manufacturer)
name= models.CharField(max_length=32, unique=True)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Execute code after sending a http response?

2009-08-28 Thread Daniel Roseman

On Aug 28, 7:10 am, Shadow  wrote:
> Hi,
>
> Is it possible to execute code after sending the actual http response?
>
> For my website, users can optionally give an email address, and if
> they do, the site sends a confirmation email. But I was thinking it's
> more logical to spend time sending the email after the signup
> confirmation page is sent to the user. Since sending the email doesn't
> affect the http reponse at all?
>
> Is this possible?
>
> cheers

Not directly - once you've returned from your view, that's it.

One possibility though is not to do the email sending within the view.
Instead, the view simply sets an attribute in a table somewhere to say
that an email needs to be sent to a certain user. Then you have a cron
job that runs regularly, extracts the users with the flag set, and
sends the email.

You could perhaps achieve the same thing using message queues - have
your view send a message to the queue, and a separate listener which
receives the message and sends the mail.
--
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
-~--~~~~--~~--~--~---



500 error when DEBUG = False but not True

2009-08-28 Thread Tracy Reed
I appear to have a bit of a heisenbug. When I have debug = True
everything works perfectly. When I have debug = False I get a 500
error when accessing two views in particular. I'm not sure what makes
those views special or why the app would behave differently depending
on whether debug is True or False (aside from the obvious displaying
of templates vs debugging info such as tracebacks). When I get the 500
Internal server error the following appears in the apache error_log:

[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112] mod_wsgi
(pid=2046): Exception occurred processing WSGI script
'/var/spool/filter/email_archive/django.wsgi'., referer:
http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112] Traceback
(most recent call last):, referer: http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
"/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py", line
241, in __call__, referer: http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]
response = self.get_response(request), referer:
http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
"/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line
134, in get_response, referer: http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112] return
self.handle_uncaught_exception(request, resolver, exc_info), referer:
http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
"/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line
166, in handle_uncaught_exception, referer:
http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112] return
callback(request, **param_dict), referer:
http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
"/usr/lib/python2.4/site-packages/django/views/defaults.py", line 23,
in server_error, referer: http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112] t =
loader.get_template(template_name) # You need to create a 500.html
template., referer: http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
"/usr/lib/python2.4/site-packages/django/template/loader.py", line 81,
in get_template, referer: http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112] source,
origin = find_template_source(template_name), referer:
http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]   File
"/usr/lib/python2.4/site-packages/django/template/loader.py", line 74,
in find_template_source, referer: http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112] raise
TemplateDoesNotExist, name, referer: http://mx1.mydomain.com/unsure
[Fri Aug 28 00:41:37 2009] [error] [client 216.105.40.112]
TemplateDoesNotExist: 500.html, referer:
http://mx1.mydomain.com/unsure

Any ideas? I am using Django 1.1 on CentOS 5.3 with Apache 2.2.3 in
case it matters.

Thanks

-- 
Tracy Reed
http://tracyreed.org


pgpBcZPHuNq9t.pgp
Description: PGP signature


Help admin edit

2009-08-28 Thread kawate

Suddenly I get admin index.html show 'You don't have permission to
edit anything.'.
I run this system several months without any problem with admin
interface.
I can't guess at least the cause of this change.
Could anyone help me.
Thank you 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 get LANGUAGE_CODE variable in flatpage's template

2009-08-28 Thread victor

i need get LANGUAGE_CODE variable in flatpage's template,but only got
it under Debug status.
when set debug=False,any request to flatpage will got 500 error:
VariableDoesNotExist: Failed lookup for key [LANGUAGE_CODE] in u'[{}]'
when set debug=True,all works.
can anyone know how to get it in flatpage's template when disable
debug status?
thx a lot.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Many-to-many column admin interface

2009-08-28 Thread Craig McClanahan

On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter wrote:
> I found this thread:
> http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
> on Stackoverflow, but when i try the suggested TabularInline thing i get the
> error:
>
>  has no ForeignKey to  'politlog.entry.models.Entries'>
>

At least with Django 1.0.x, the admin interface does not support
many-to-many relationships on inlines -- it will always return an
error like the one you got above.  Indeed, the message is technically
accurate, because m2m relationships get implemented as a separate
table, so there is no direct relationship between the two.
InlineModelAdmin works great for one-to-many but not for many-to-many.

I'd also be interested in solutions to this, not having found anything
in a bunch of Google searches.  The alternative I'm planning on is
having to hand-code some views, forms, and templates that let me do
the right thing -- not a huge amount of work, but having admin do it
for us would be way cool.

Craig


> Greetings
> Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



variable as a field name in a template?

2009-08-28 Thread Unnamed_Hero

Is it possible provide a variable for a field name in a template?

A have a database with a corporations. I want to create some kind of a
report generator. Users can choose necessary fields, specify some
filters and get a result.

I've created a form with checkboxes near field name, have created a
form with filters, have created a queryset from user request. My
problem that I can't understand how can I show only user selected
fields in a template. Can you show me the right way?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 custom widget

2009-08-28 Thread nbv4

I have a Flight model which has a foreignkey field that relates to a
route object. I created a custom field to go with my FlightForm that
allows me to enter a simple string, which is then, via the clean()
method, constructed into a Route object that is attached to the
flight. This works fine, but what I'm trying to do now is have it so
when I create a FlightForm formset, my route field is rendered as a
textbox with the __unicode__ representation, instead of just the
primary key as it is now. How can I do this? I understand I need to be
making a custom widget not a custom field to do this, right? This is
what I have so far:

###

class RouteWidget(widgets.TextInput):
def render(self, name, value, attrs=None):
return mark_safe("")

###

The problem is that the "value" value is never anything other than
None. Even though the form is being populated via a formset. What am I
missing here? The name attribute seems to be working...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin search error (using auto complete FK widget)

2009-08-28 Thread mr.kschan

Hi,

There is solution to use Jannis's widget with Django 1.1.

Please read the blog post's comment by Christian Abbott June 24, 2009.

The __call__ is deprecated in Django1.1 and you could better update
the code to use get_urls() instead. =]

I just tried and it works ^^

ks

On Aug 28, 12:01 pm, "mr.kschan"  wrote:
> Hi,
>
> On Aug 26, 9:34 pm, maco  wrote:
>
>
>
> > Jannis Liedel writes about a great widget for FK 
> > fieldshttp://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-m...
>
> > I manged to get it to work on one site, but not on others.
>
> > Widget uses admin search functionality through url:
> > /admin/app/model/search/?
> > q=foo_fields=my_field_label=my_app_name=my_model
>
> > However, on some sites using same code and on the same server (running
> > django 1.1 and python 2.5) I get error:
>
> > invalid literal for int() with base 10: 'search'
> > Exception Location: /Library/Python/2.5/site-packages/django/db/models/
> > fields/__init__.py in get_db_prep_value, line 361
> > Python Executable: /System/Library/Frameworks/Python.framework/
> > Versions/2.5/Resources/Python.app/Contents/MacOS/Python
> > Python Version: 2.5.1
>
> I was facing the same problem. Django 1.1 with py26
>
> But I think if u try fallback to Django 1.0.2 or 1.0.3 , the problem
> will not exist.
>
> > I tried several different aps, models and fields and got same result.
> > I googled about the error and all could get was that django can't
> > search on date fields that have None as default value, but that is not
> > the case for me here.
>
> I don't think that's related to any field but u may refer to the
> ticket #11678http://code.djangoproject.com/ticket/11678
>
> kschan.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



ugettext() and ugettext_lazy() - error and difference

2009-08-28 Thread Léon Dignòn

Hi,

I don't exactly understand the difference between ugettext() and
ugettext_lazy(). I read the documentation and I've read that
ugettext_lazy translates a string on access. Sounds more efficient.
But why do I get this error on that code?

from django.db import models
from django.utils.translation import ugettext_lazy as _

class Country(models.Model):
name   = models.CharField(max_length=256, unique=True)
name_iso_2 = models.CharField(max_length=2,   unique=True,
help_text='http://de.wikipedia.org/wiki/ISO-3166-1-Kodierliste')
name_iso_3 = models.CharField(max_length=3,   unique=True,
help_text='http://de.wikipedia.org/wiki/ISO-3166-1-Kodierliste')

def __unicode__(self):
return _(self.name)



Exception Type: TemplateSyntaxError at /admin/skins/country/
Exception Value: Caught an exception while rendering: coercing to
Unicode: need string or buffer, __proxy__ found
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin search error (using auto complete FK widget)

2009-08-28 Thread mr.kschan

Hi,

On Aug 26, 9:34 pm, maco  wrote:
> Jannis Liedel writes about a great widget for FK 
> fieldshttp://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-m...
>
> I manged to get it to work on one site, but not on others.
>
> Widget uses admin search functionality through url:
> /admin/app/model/search/?
> q=foo_fields=my_field_label=my_app_name=my_model
>
> However, on some sites using same code and on the same server (running
> django 1.1 and python 2.5) I get error:
>
> invalid literal for int() with base 10: 'search'
> Exception Location: /Library/Python/2.5/site-packages/django/db/models/
> fields/__init__.py in get_db_prep_value, line 361
> Python Executable: /System/Library/Frameworks/Python.framework/
> Versions/2.5/Resources/Python.app/Contents/MacOS/Python
> Python Version: 2.5.1
>

I was facing the same problem. Django 1.1 with py26

But I think if u try fallback to Django 1.0.2 or 1.0.3 , the problem
will not exist.

> I tried several different aps, models and fields and got same result.
> I googled about the error and all could get was that django can't
> search on date fields that have None as default value, but that is not
> the case for me here.

I don't think that's related to any field but u may refer to the
ticket #11678 http://code.djangoproject.com/ticket/11678


kschan.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---