Re: forms messing up css, help?

2011-06-10 Thread raj
I also noticed one more thing, in general, all html functions stopped
working with render_to_response i think. Like i have a function that
gets the current path ({% request.path == ".." %}). That also isn't
working. And even when I hard-code it, it doesn't make a difference.
any suggestions?

On Jun 11, 12:17 am, raj  wrote:
> Another thing i just noticed, When i view the source of my contact
> form, all the css/javascript includes are missing part of the path
> where i placed a {{ STATIC_URL }} tag. Why isn't this tag being
> rendered? Thank you.
>
> On Jun 11, 12:14 am, raj  wrote:
>
>
>
>
>
>
>
> > Hey guys, Whenever i try and add a contact form (from the django book)
> > into my current website, all my css/javascripts stop working. What is
> > the issue? Here are my codes:
>
> > #views.py
>
> > def contact(request):
> >     if request.method == 'POST':
> >         form = ContactForm(request.POST)
> >         if form.is_valid():
> >             cd = form.cleaned_data
> >             send_mail(
> >                 cd['subject'],
> >                 cd['message'],
> >                 cd.get('email', 'nore...@example.com'),
> >                 ['siteow...@example.com'],
> >             )
> >             return HttpResponseRedirect('/contact/thanks/')
> >     else:
> >         form = ContactForm()
> >     return render_to_response('/var/djcode/oneadmin/templates/
> > oneadmissions/contact.html', {'form': form})
>
> > #forms.py
>
> > from django import forms
>
> > class ContactForm(forms.Form):
> >     subject = forms.CharField()
> >     email = forms.EmailField()
> >     message = forms.CharField()
> >     name = forms.CharField()
>
> > #urls.py
> > urlpatterns = patterns('',
> >     ...
> >      (r'^contact-form/', views.contact),
> >     ...
> >      )
>
> > I have my static folder and everything created properly, its working
> > perfectly fine until i input the chapter on forms. Help please!

-- 
You received this message because you are subscribed to the Google 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: forms messing up css, help?

2011-06-10 Thread raj
Another thing i just noticed, When i view the source of my contact
form, all the css/javascript includes are missing part of the path
where i placed a {{ STATIC_URL }} tag. Why isn't this tag being
rendered? Thank you.

On Jun 11, 12:14 am, raj  wrote:
> Hey guys, Whenever i try and add a contact form (from the django book)
> into my current website, all my css/javascripts stop working. What is
> the issue? Here are my codes:
>
> #views.py
>
> def contact(request):
>     if request.method == 'POST':
>         form = ContactForm(request.POST)
>         if form.is_valid():
>             cd = form.cleaned_data
>             send_mail(
>                 cd['subject'],
>                 cd['message'],
>                 cd.get('email', 'nore...@example.com'),
>                 ['siteow...@example.com'],
>             )
>             return HttpResponseRedirect('/contact/thanks/')
>     else:
>         form = ContactForm()
>     return render_to_response('/var/djcode/oneadmin/templates/
> oneadmissions/contact.html', {'form': form})
>
> #forms.py
>
> from django import forms
>
> class ContactForm(forms.Form):
>     subject = forms.CharField()
>     email = forms.EmailField()
>     message = forms.CharField()
>     name = forms.CharField()
>
> #urls.py
> urlpatterns = patterns('',
>     ...
>      (r'^contact-form/', views.contact),
>     ...
>      )
>
> I have my static folder and everything created properly, its working
> perfectly fine until i input the chapter on forms. Help please!

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



forms messing up css, help?

2011-06-10 Thread raj
Hey guys, Whenever i try and add a contact form (from the django book)
into my current website, all my css/javascripts stop working. What is
the issue? Here are my codes:

#views.py

def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
send_mail(
cd['subject'],
cd['message'],
cd.get('email', 'nore...@example.com'),
['siteow...@example.com'],
)
return HttpResponseRedirect('/contact/thanks/')
else:
form = ContactForm()
return render_to_response('/var/djcode/oneadmin/templates/
oneadmissions/contact.html', {'form': form})

#forms.py

from django import forms

class ContactForm(forms.Form):
subject = forms.CharField()
email = forms.EmailField()
message = forms.CharField()
name = forms.CharField()

#urls.py
urlpatterns = patterns('',
...
 (r'^contact-form/', views.contact),
...
 )

I have my static folder and everything created properly, its working
perfectly fine until i input the chapter on forms. Help please!

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



Dynamic Nested Formsets?

2011-06-10 Thread Sontek
I have 3 Models:

class Workflow(models.Model):
name = models.CharField(max_length=255)
company = models.ForeignKey(Company)
class Meta:
unique_together = ('name', 'company')

class Milestone(models.Model):
workflow = models.ForeignKey(Workflow)
tasks = models.ManyToManyField(Task)

class Task(models.Model):
task = models.CharField(max_length=255)

How could I create a form that allows me to add many milestones to a
workflow and many tasks to a milestone?

-- 
You received this message because you are subscribed to the Google 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: 'ValuesListQuerySet' object has no attribute 'META'

2011-06-10 Thread javatina
You are absolutely correct. I certainly need to improve my Python
skills, think more Python and get rid of some old habits. Another
lesson - I could easily find the problem myself if I trusted more
myself instead of sending tracebacks asking for help. So, I guess
double thanks are in order.

Serge

On Jun 10, 11:29 am, Ian Clelland  wrote:
> On Fri, Jun 10, 2011 at 5:55 AM, javatina  wrote:
>
> > = in views.py: ===
> > see formattedhttp://dpaste.com/hold/552703/
>
> > same as:
>
> > def test(request, slug=None):
> >    slugs = Concept.objects.filter(status__slug = 'active').order_by('-
> > published_on').values_list('slug', flat=True)
> >    try:
> >        concept = Concept.objects.get(slug = slug, status__slug =
> > 'active')
> >    except Page.DoesNotExist:
> >        raise Http404
>
> >    slugs_list = list(slugs)      # ==> problem line
>
> > =  traceback =
> >http://dpaste.com/552702/
>
>  According to your traceback, when you call list(slugs), on line 446, it is
> not using the python list() built-in, but calling what appears to be a list
> function that you have defined earlier (around line 400)
>
> My initial guess would be that you have something like this above the code
> you have pasted:
>
> def list(request):
>     ...
>     context_instance=RequestContext(request)
>     ...
>
> And that call is throwing an exception, because you are passing a QuerySet
> into RequestContext(), which is expecting an HttpRequest, and its
> accompanying META attribute.
>
> Check to see if that's the case, and rename your list() view if it is.
>
> --
> Regards,
> Ian Clelland
> 

-- 
You received this message because you are subscribed to the Google 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: Need help getting this snippet to work in Django 1.2...

2011-06-10 Thread mhulse
Hi Martin! Thanks so much for the help, I really appreciate it. :)

> The snippet is a form field, not a model field.

Well, that would explain things! Lol.

When I read this in the instructions:

"Usage eg: yob = BirthYearField(label="What year were you born?")"

I thought that was a model field.

Thanks for pointing me in the right direction! :)

Have a nice day.

Cheers,
Micky

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/BPbNW-I4VC8J.
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: Need help getting this snippet to work in Django 1.2...

2011-06-10 Thread Martin
I think this is not how it works. The snippet is a form field, not a model
field. Basically I think you should use an IntegerField (you just want to
store a year, right?). Then somehow you need to override the widget or so
and make sure that in the admin that form will be used for that
IntegerField. This form field basically just makes sure, that people don't
enter anything stupid, but what is being saved will just be a normal
integer, I guess.

Sorry, don't have enough time to give a better hint.

Best regards,
Martin

On Sat, Jun 11, 2011 at 9:53 AM, mhulse  wrote:

> I feel like this should be simple...
>
> I would like to replace this model field:
>
> date = models.DateField(_(u'Year'), unique=True)
>
> ...with this snippet:
>
> http://djangosnippets.org/snippets/508/
>
> I have spent the last couple hours banging my head on my keyboard...
>
> During the course of my tests, at one point, I was getting an error that
> said something like "__init__() got an unexpected keyword argument 'unique'"
> (I think I was trying to extend IntegerField).
>
> Any tips on how to convert that snippet so I can do:
>
> from app.fields import YearField
> ...
> year = YearField(_(u'Year'), unique=True)
> ...
>
> Normally I wouldn't ask, but I am ready to give up... At this point, I am
> just curious to see how it's done for the sake of learning something new.
>
> Thanks so much!
>
> Cheers,
> Micky
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/Ov8sCyIqUUIJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Need help getting this snippet to work in Django 1.2...

2011-06-10 Thread mhulse
I feel like this should be simple...

I would like to replace this model field:

date = models.DateField(_(u'Year'), unique=True)

...with this snippet:

http://djangosnippets.org/snippets/508/

I have spent the last couple hours banging my head on my keyboard...

During the course of my tests, at one point, I was getting an error that 
said something like "__init__() got an unexpected keyword argument 'unique'" 
(I think I was trying to extend IntegerField).

Any tips on how to convert that snippet so I can do:

from app.fields import YearField
...
year = YearField(_(u'Year'), unique=True)
...

Normally I wouldn't ask, but I am ready to give up... At this point, I am 
just curious to see how it's done for the sake of learning something new.

Thanks so much!

Cheers,
Micky

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Ov8sCyIqUUIJ.
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: Email Accounts

2011-06-10 Thread Kenneth Gonsalves
On Fri, 2011-06-10 at 16:23 +0100, Cal Leeming [Simplicity Media Ltd]
wrote:
> 
> I didn't realise I had accidently sent this email to the list, rather
> than
> directly to the OP.
> 
> Thank you for letting me know.
> 
> 

I have faced this problem - whether I click 'reply to all' or 'reply to
sender', the reply goes *only* to the group.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.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: Help with custom model method for query

2011-06-10 Thread Chris McComas
Bruno,

Thanks. It wasn't exactly working properly, so I just had to
add .order_by('feed__feed_type__order_by') and it seems to be working
properly.




On Jun 10, 3:33 pm, bruno desthuilliers
 wrote:
> On 10 juin, 17:23, Chris McComas  wrote:
>
> > Sorry for the confusion, this is what I am trying to achieve. It's the
> > FeedType and then FeedItems whose feed (fk) has a (fk) to FeedType.
>
> > The HTML would be:
>
> > {% for feed_type in FeedType %}
> >         {{ feed_type.name
> >         
> >                 {% for FeedItem in Feed in FeedType %}
> >                         {{ feeditem.title }}
> >         
> > {% endfor %}
>
> Ok.
>
> Then you need to correct your view:
>
> # views.py
>
> def news(request, city_id):
>     city = get_object_or_404(City, pk=city_id)
>     feeditems =
> FeedItem.objects.filter(feed__city=city).select_related(depth=2)
>     return render_to_response(
>         "path/to/template.html",
>         dict(city=city, feeditems=feeditems)
>         )
>
> And then in your template:
>
> {% regroup feeditems by feed_type as feeditems_list %}
> 
>   {% for feed_type in feeditems_list %}
>   
>     {{ feed_type.grouper }}
>     
>       {% for entry in feed_type.list %}
>       {{ entry.title }}
>       {% endfor %}
>     
>   
>   {% endfor %}
> 
>
> Obviously untested code, but this should work or, at least, get you
> started.

-- 
You received this message because you are subscribed to the Google 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 query for ModelChoiceField using request.user.get_profile() as a part of the criteria

2011-06-10 Thread geraldcor
Hello all,

I am wondering how to access a user's profile when creating the
queryset for a ModelChoiceField. I would like to be able to use the
ModelChoiceField to display contacts from another table based on a
parameter saved in the user profile i.e. who =
forms.ModelChoiceField(queryset=Contacts.objects.filter(id__exact=request.user.get_profile().main_company))

Is there a better way to do this (beyond an ajax picker in the
template)?

Greg

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

2011-06-10 Thread Sergiy Khohlov
Not is is related to django.

A lot of email system stores email account   (not mailbox) in the
database. It is not hard task to create a  django class using database
which is used for  SMTP system.  Take a look at the next URL:
http://bowe.id.au/michael/isp/postfix-server.htm
part of mysql :
CREATE TABLE mailbox_domains (

domain varchar(255) NOT NULL default '',
description varchar(255) NOT NULL default 'Postfix virtual mailbox domain',
maxaliases int(10) NOT NULL default '-1',
maxmailboxes int(10) NOT NULL default '-1',


 and it is possible to create django model for this:

 class mailbox_domains(model.Models):
domain=models.CharField(max_length=256)
...


 I think  idea is clear. But your mail server should use database  for
user auth and mailbox storing


 Thanks,
Serge






2011/6/10 Cal Leeming [Simplicity Media Ltd]
:
> My apologies.
> I didn't realise I had accidently sent this email to the list, rather than
> directly to the OP.
> Thank you for letting me know.
> Cal
>
> On Fri, Jun 10, 2011 at 4:14 PM, Brian Bouterse  wrote:
>>
>> This conversation is off topic, and should not be facilitated through the
>> Django users mailing list.  There are sites setup for these kinds of things.
>> Brian
>>
>> On Fri, Jun 10, 2011 at 11:09 AM, Cal Leeming [Simplicity Media Ltd]
>>  wrote:
>>>
>>> Hey Lillian,
>>> I've noticed a few emails on the list from you.. Could you possibly
>>> explain a little bit about the situation you are currently in, and what it
>>> is you are looking for? I might be able to offer some assistance, depending
>>> on what the problem is.
>>> Cal
>>>
>>> On Fri, Jun 10, 2011 at 2:40 PM, lillian 
>>> wrote:

 Thanks for the recommendation.

 Any IT guys out there?

 Also, is it difficult to set up email accounts with Django or do I
 require an IT guy for that as well?

 Need to set up some accounts and could use a little help.

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

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

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



Re: Help with custom model method for query

2011-06-10 Thread bruno desthuilliers
On 10 juin, 17:23, Chris McComas  wrote:
> Sorry for the confusion, this is what I am trying to achieve. It's the
> FeedType and then FeedItems whose feed (fk) has a (fk) to FeedType.
>
> The HTML would be:
>
> {% for feed_type in FeedType %}
>         {{ feed_type.name
>         
>                 {% for FeedItem in Feed in FeedType %}
>                         {{ feeditem.title }}
>         
> {% endfor %}

Ok.

Then you need to correct your view:


# views.py

def news(request, city_id):
city = get_object_or_404(City, pk=city_id)
feeditems =
FeedItem.objects.filter(feed__city=city).select_related(depth=2)
return render_to_response(
"path/to/template.html",
dict(city=city, feeditems=feeditems)
)

And then in your template:

{% regroup feeditems by feed_type as feeditems_list %}

  {% for feed_type in feeditems_list %}
  
{{ feed_type.grouper }}

  {% for entry in feed_type.list %}
  {{ entry.title }}
  {% endfor %}

  
  {% endfor %}


Obviously untested code, but this should work or, at least, get you
started.

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



Re: Is there anyway to put a Django site into maintenance mode using fabric?

2011-06-10 Thread Eric Chamberlain
We make the change at the web server and redirect all traffic to a static page.

If the site is down for maintenance, then the middleware won't work either.

On Jun 10, 2011, at 9:24 AM, Garth Humphreys wrote:

> I'm using the MaintenanceModeMiddleware to put my site into
> maintenance mode, but I was wondering if there is a way to put my site
> into maintenance via fabric. I would like to do something like;
> 
> fab maintenance_on
> 
> If this is not possible what are other common ways of remotely putting
> a Django site into maintenance mode?
> 

-- 
You received this message because you are subscribed to the Google 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: VERY cheap django hosting?

2011-06-10 Thread Eric Chamberlain
We use Amazon AWS.  If you register a new account, you can get free service for 
a year on their lowest tier.


On Jun 7, 2011, at 11:30 PM, raj wrote:

> Hey guys,
> Just wondering if you could give me some hosts that are very cheap for
> django hosting? Is hostgator any good? I really don't know what to
> look for in a host. A lot of people are recommending web faction, but
> its around $9 bucks a month. I was looking in the $5 bucks a month
> range. Any ideas? Thank you.
> -Raj

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

2011-06-10 Thread Greg Donald
On Fri, Jun 10, 2011 at 12:41 PM, Nan  wrote:
> I encountered that error at one point when upgrading Sorl Thumbnail
> versions.  Can't remember exactly how I worked around it, but it had
> something to do with clearing out caches.

My cache is clean, this is a new app.  My key/value table is empty,
and my cache directory is empty and writable.

> There are data caches that
> you can clear with Sorl's custom management commands and disk caches
> that you can delete.
>
> Also make sure that you're passing valid parameters -- i.e. that
> up.image is an ImageField.

It is, it's a sorl thumbnail ImageField to be exact.


-- 
Greg Donald
destiney.com | gregdonald.com

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



Re: sorl thumbnail

2011-06-10 Thread Nan

I encountered that error at one point when upgrading Sorl Thumbnail
versions.  Can't remember exactly how I worked around it, but it had
something to do with clearing out caches.  There are data caches that
you can clear with Sorl's custom management commands and disk caches
that you can delete.

Also make sure that you're passing valid parameters -- i.e. that
up.image is an ImageField.


On Jun 10, 1:11 pm, Greg Donald  wrote:
> On Fri, Jun 10, 2011 at 11:59 AM, Greg Donald  wrote:
> >  File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py", line
> > 52, in raise_ioerror
> >   raise IOError(message + " when reading image file")
>
> > IOError: broken data stream when reading image file
>
> And then more baffling is the fact that it works using `manage.py shell`
>
> In [1]: from sorl.thumbnail import get_thumbnail
>
> In [2]: im = 
> get_thumbnail('/myproject/static/images/user_profiles/1/11-20-2010-2_5.jpg',
> '32x32', crop='center' )
>
> In [3]: im
> Out[3]: 
>
> In [4]: im.url
> Out[4]: 'http://example.com/cache/ff/31/ff318b4a995ff345d1d48e79b67ec62b.jpg'
>
> It made the thumbnail, just won't make one via the template code.
>
> --
> Greg Donald
> destiney.com | gregdonald.com

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



Re: Updating static files: Still in browser cache

2011-06-10 Thread Malcolm Box
On 10 June 2011 14:54, Thomas Guettler  wrote:

>  On 09.06.2011 19:18, Malcolm Box wrote:
> > On 9 Jun 2011, at 14:21, DrBloodmoney  wrote:
> >
> >> On Thu, Jun 9, 2011 at 9:16 AM, Malcolm Box 
> wrote:
> >>> On 9 June 2011 08:09, Thomas Guettler  wrote:
> which application does not cache URLs with a query string? I think most do,
> or am I wrong?Malcolm Box
>

http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/

Squid for one (at least in some configurations). There are no doubt others.

First rule of caching: there will always be a totally borked cache between
you and your users.

Malcolm

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



Re: sorl thumbnail

2011-06-10 Thread Greg Donald
On Fri, Jun 10, 2011 at 11:59 AM, Greg Donald  wrote:
>  File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py", line
> 52, in raise_ioerror
>   raise IOError(message + " when reading image file")
>
> IOError: broken data stream when reading image file


And then more baffling is the fact that it works using `manage.py shell`


In [1]: from sorl.thumbnail import get_thumbnail

In [2]: im = 
get_thumbnail('/myproject/static/images/user_profiles/1/11-20-2010-2_5.jpg',
'32x32', crop='center' )

In [3]: im
Out[3]: 

In [4]: im.url
Out[4]: 'http://example.com/cache/ff/31/ff318b4a995ff345d1d48e79b67ec62b.jpg'

It made the thumbnail, just won't make one via the template code.



-- 
Greg Donald
destiney.com | gregdonald.com

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



Re: How to add CSRF to context when using test client???

2011-06-10 Thread Matteius
Yes I Have this in the setUp function which causes my POST request to
get a 403 forbidden because I don't actually include the CSRF field in
the context as the middleware does on a deployed version of the site.
I need a function to call or something to get the CSRF context value,
or a function that I can pass a context which will add it in the
CSRF.  Otherwise there is not much of a point to enable CSRF with the
test client because you'll get 403 errors.

-Matt

On Jun 10, 1:46 am, Artemenko Alexander  wrote:
> Hi Matt,
>
> Use:
>
> from django.test import Client
> csrf_client = Client(enforce_csrf_checks=True)
>
> https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#testing
>
> 10.06.2011, 08:48, "Matteius" :
>
>
>
> > Greetings,
>
> > I am writing unit tests for my application, and I want to leave CSRF
> > checks enabled in testing. This means on my POST I am getting 403
> > because I have not figured out how to add csrf to my context when
> > using the test client. Please advise on how to most easily do this:
>
> > # Issue a POST request.
> > response = self.client.post('/student/open_enrollments/',
> > {'course': 3})
> > # Check that the response is 200 OK.
> > self.assertEqual(response.status_code, 200)
> > # Verify template is the expected one.
> > self.assertTemplateUsed(response, 'student_portal/
> > open_enrollments.html')
> > # Check that the rendered context contains now 0 Courses.
> > self.assertEqual(len(response.context['courses']), 0)
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

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



sorl thumbnail

2011-06-10 Thread Greg Donald
Sorry if this is off-topic, I was unable to find a user group for my
exact issue.

I'm using sorl thumbnail with Django.  On my local setup it works
fine, but in production the thumbnails are not made.

My code looks like this:

{% load thumbnail %}
{% thumbnail up.image "32x32" crop="center" as im %}

{% empty %}

{% endthumbnail %}


I enabled logging and the trace looks like this:

Traceback (most recent call last):

 File 
"/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/templatetags/thumbnail.py",
line 45, in render
   return self._render(context)

 File 
"/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/templatetags/thumbnail.py",
line 97, in _render
   file_, geometry, **options

 File 
"/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/base.py",
line 49, in get_thumbnail
   thumbnail)

 File 
"/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/base.py",
line 74, in _create_thumbnail
   image = default.engine.create(source_image, geometry, options)

 File 
"/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/engines/base.py",
line 14, in create
   image = self.colorspace(image, geometry, options)

 File 
"/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/engines/base.py",
line 24, in colorspace
   return self._colorspace(image, colorspace)

 File 
"/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/engines/pil_engine.py",
line 33, in _colorspace
   return image.convert('RGB')

 File "/usr/local/lib/python2.6/dist-packages/PIL/Image.py", line 679,
in convert
   self.load()

 File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py", line
215, in load
   raise_ioerror(e)

 File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py", line
52, in raise_ioerror
   raise IOError(message + " when reading image file")

IOError: broken data stream when reading image file


The error isn't very helpful since the file is there and is readable
by all.  I'm not sure how to get a more explicit error, or what to try
and fix.  Stuck.


Thanks,


-- 
Greg Donald
destiney.com | gregdonald.com

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



Is there anyway to put a Django site into maintenance mode using fabric?

2011-06-10 Thread Garth Humphreys
I'm using the MaintenanceModeMiddleware to put my site into
maintenance mode, but I was wondering if there is a way to put my site
into maintenance via fabric. I would like to do something like;

fab maintenance_on

If this is not possible what are other common ways of remotely putting
a Django site into maintenance mode?

-- 
You received this message because you are subscribed to the Google 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: storing django object into javascript array

2011-06-10 Thread Ian Clelland
On Fri, Jun 10, 2011 at 7:48 AM, jay K.  wrote:

>
> Hello,
>
> I am not a django developer, but I have a background on html, css,
> javascript, jquery and php.
>
> I was wondering if you can help me with a question regarding django,
> since I'm working on a website built on django (which was not started
> by me)
>
> I want to store a django object into a javascript array. So far I have
> this code:
>
> In my template file:
>
> 
>
> var map_schools = {{ city.school_set.all }};
>
> 
>
> Unfortunately the django object is not stored as desired, but instead
> it gets stored like the following:
>
> var map_schools = [School: Oxford, Eckersley]
>
>
[] is the printable representation of your query
set (what you get when you call city.school_set.all()) -- what you need to
do is build up a JavaScript literal that you can insert into the code. There
are two fairly simple ways of doing this:

1. Use a loop in the template:

var map_schools = [{% for school in city.school_set.all %}"{{
school|escapejs }}"{% if not forloop.last %},{% endif %}{% endfor %}];

You'll notice a couple of things there:
  - there is a "for" loop there, to iterate over all of the schools in the
result set
  - the quotes are present in the template, to make sure that the school
names are strings in the JavaScript
  - there is a test after every string to see if a "," is needed as a
separator (some javascript implementations are not very forgiving if you put
a comma after the last element)
  - Every school name is passed through the "escapejs" filter, to avoid
breaking out of the string.

2. Construct a JSON string in python:

In your view, do something like this:

from django.utils.simplejson import dumps
...
school_list = dumps([school.name for school in city.school_set.all()])

and then add school_list to the context variables that are passed to the
template. Then in the template, you can just use {{ school_list }}, and it
will be a properly formatted JavaScript array.



-- 
Regards,
Ian Clelland


-- 
You received this message because you are subscribed to the Google 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: storing django object into javascript array

2011-06-10 Thread Brice Leroy
Hello Jay,

When you call  city.school_set.all ,you get an array of object. the template
render the string representation of the object.

You might want to loop other them. Check the json serializer too :

https://docs.djangoproject.com/en/dev/topics/serialization/#serialization-formats

Brice
2011/6/10 jay K. 

>
> Hello,
>
> I am not a django developer, but I have a background on html, css,
> javascript, jquery and php.
>
> I was wondering if you can help me with a question regarding django,
> since I'm working on a website built on django (which was not started
> by me)
>
> I want to store a django object into a javascript array. So far I have
> this code:
>
> In my template file:
>
> 
>
> var map_schools = {{ city.school_set.all }};
>
> 
>
> Unfortunately the django object is not stored as desired, but instead
> it gets stored like the following:
>
> var map_schools = [School: Oxford, Eckersley]
>
> I am unable to work with the javascript array. Right now this piece of
> code is commented out because enabling it prevents the rest of the js
> code from running properly
>
> Any suggestions are welcome
>
> Thanks,
>
> Regards,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
blog: http://www.debrice.com
Time tracking tool: http://alpha.kaaloo.com
Django site generator: http://alpha.djangogenerator.com
linkedin: http://www.linkedin.com/in/bricepleroy

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



Trying to keep upload filename from disappearing - with python 2.7.1/django 1.2.4

2011-06-10 Thread djangobeginner
I'm new to django and python but I'm working on a new screen for a
project I'm on. The screen is supposed to capture a bunch of text
information as well as allow a user to browse and select a file on
their local machine for uploading. I'm having a problem with the
filename disappearing from the selected filename textbox, whenever I
submit the screen to begin uploading the file and I have an error on
the screen. If I have an error on the screen the screen is returned
showng an error message, but without the original filename selected
being displayed (empty filename textbox), which will force the user to
reselect the file again. Has anyone had this problem before, and if so
how do I prevent the filename from disappearing? I have tried making a
copy of the request.FILES similar to the way I have done previously
with a request.POST (request.POST.copy()) capturing the filename data
when entering my view, but when I try to add it back to the
request.FILES by doing this in my error logic branch:

request.FILES['filename'] = filename

I get an AttributeError exception "can't set attribute". So since this
doesn't work what is the proper way 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.



storing django object into javascript array

2011-06-10 Thread jay K.

Hello,

I am not a django developer, but I have a background on html, css,
javascript, jquery and php.

I was wondering if you can help me with a question regarding django,
since I'm working on a website built on django (which was not started
by me)

I want to store a django object into a javascript array. So far I have
this code:

In my template file:



var map_schools = {{ city.school_set.all }};



Unfortunately the django object is not stored as desired, but instead
it gets stored like the following:

var map_schools = [School: Oxford, Eckersley]

I am unable to work with the javascript array. Right now this piece of
code is commented out because enabling it prevents the rest of the js
code from running properly

Any suggestions are welcome

Thanks,

Regards,

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



Re: 'ValuesListQuerySet' object has no attribute 'META'

2011-06-10 Thread Ian Clelland
On Fri, Jun 10, 2011 at 5:55 AM, javatina  wrote:

>
> = in views.py: ===
> see formatted http://dpaste.com/hold/552703/
>
> same as:
>
> def test(request, slug=None):
>slugs = Concept.objects.filter(status__slug = 'active').order_by('-
> published_on').values_list('slug', flat=True)
>try:
>concept = Concept.objects.get(slug = slug, status__slug =
> 'active')
>except Page.DoesNotExist:
>raise Http404
>
>slugs_list = list(slugs)  # ==> problem line
>
>
>

> =  traceback =
> http://dpaste.com/552702/
>

 According to your traceback, when you call list(slugs), on line 446, it is
not using the python list() built-in, but calling what appears to be a list
function that you have defined earlier (around line 400)

My initial guess would be that you have something like this above the code
you have pasted:

def list(request):
...
context_instance=RequestContext(request)
...

And that call is throwing an exception, because you are passing a QuerySet
into RequestContext(), which is expecting an HttpRequest, and its
accompanying META attribute.

Check to see if that's the case, and rename your list() view if it is.

-- 
Regards,
Ian Clelland


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

2011-06-10 Thread Cal Leeming [Simplicity Media Ltd]
My apologies.

I didn't realise I had accidently sent this email to the list, rather than
directly to the OP.

Thank you for letting me know.

Cal


On Fri, Jun 10, 2011 at 4:14 PM, Brian Bouterse  wrote:

> This conversation is off topic, and should not be facilitated through the
> Django users mailing list.  There are sites setup for these kinds of
> things .
>
> Brian
>
> On Fri, Jun 10, 2011 at 11:09 AM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>> Hey Lillian,
>>
>> I've noticed a few emails on the list from you.. Could you possibly
>> explain a little bit about the situation you are currently in, and what it
>> is you are looking for? I might be able to offer some assistance, depending
>> on what the problem is.
>>
>> Cal
>>
>>
>> On Fri, Jun 10, 2011 at 2:40 PM, lillian wrote:
>>
>>> Thanks for the recommendation.
>>>
>>> Any IT guys out there?
>>>
>>> Also, is it difficult to set up email accounts with Django or do I
>>> require an IT guy for that as well?
>>>
>>> Need to set up some accounts and could use a little help.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Brian Bouterse
> ITng Services
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Email Accounts

2011-06-10 Thread Brian Bouterse
This conversation is off topic, and should not be facilitated through the
Django users mailing list.  There are sites setup for these kinds of
things
.

Brian

On Fri, Jun 10, 2011 at 11:09 AM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> Hey Lillian,
>
> I've noticed a few emails on the list from you.. Could you possibly explain
> a little bit about the situation you are currently in, and what it is you
> are looking for? I might be able to offer some assistance, depending on what
> the problem is.
>
> Cal
>
>
> On Fri, Jun 10, 2011 at 2:40 PM, lillian wrote:
>
>> Thanks for the recommendation.
>>
>> Any IT guys out there?
>>
>> Also, is it difficult to set up email accounts with Django or do I
>> require an IT guy for that as well?
>>
>> Need to set up some accounts and could use a little help.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Brian Bouterse
ITng Services

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

2011-06-10 Thread Cal Leeming [Simplicity Media Ltd]
Hey Lillian,

I've noticed a few emails on the list from you.. Could you possibly explain
a little bit about the situation you are currently in, and what it is you
are looking for? I might be able to offer some assistance, depending on what
the problem is.

Cal

On Fri, Jun 10, 2011 at 2:40 PM, lillian wrote:

> Thanks for the recommendation.
>
> Any IT guys out there?
>
> Also, is it difficult to set up email accounts with Django or do I
> require an IT guy for that as well?
>
> Need to set up some accounts and could use a little help.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Help with custom model method for query

2011-06-10 Thread bruno desthuilliers
On Jun 10, 3:12 pm, Chris McComas  wrote:
> tethered my phone to my laptop to test it out...have this code in my
> template:
>
> {% regroup feeds by feed_type as feed_list %}
> {% for feed_type in feed_list %}
>         {{ feed_type.grouper }}
>
>         {% for entry in feed_type.list %}
>                 {{ entry.title }}
>         {% endfor %}
> {% endfor %}
>
> it does the first {% for %} loop perfectly, the second {% for %} loop
> gets the Feed from the database for that FeedType,

??? Not sure I understand what you mean...

> but I need it to
> get FeedItems for Feed in FeedType

You mean something like this ?

{% regroup feeds by feed_type as feed_list %}


  {% for feed_type in feed_list %}
  
{{ feed_type.grouper }}
 
   {% for feed in feed_type.list %}
   
 {{ feed.title }}
 
   {% for feeditem in feed.items %}
   {{ item.title }}
   {% endfor %}

  
  {% endfor %}

  
  {% endfor %}


-- 
You received this message because you are subscribed to the Google 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: Updating static files: Still in browser cache

2011-06-10 Thread Thomas Guettler

On 09.06.2011 19:18, Malcolm Box wrote:
> 
> 
> Sent from my iPhone, please excuse any typos
> 
> On 9 Jun 2011, at 14:21, DrBloodmoney  wrote:
> 
>> On Thu, Jun 9, 2011 at 9:16 AM, Malcolm Box  wrote:
>>> On 9 June 2011 08:09, Thomas Guettler  wrote:

 My static files (JS/CSS) are cached in the browser. But if there is a bug
 in a file, an update won't help people which have already cached the old
 file.

 You would need a new URL for every change in the JS/CSS files.

>>>
>>> Version all static assets, bump the version when you change them.
>>
>> I keep the file name the same and append a querystring eg.
>> /static/js/mycustom.js?v=1001 then just increment the querystring on
>> versioning.
> 
> That works but may bust intermediate caches. Some won't cache anything with a 
> query string. 

Hi Malcolm,

which application does not cache URLs with a query string? I think most do, or 
am I wrong?

  Thomas


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

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



Email Accounts

2011-06-10 Thread lillian
Thanks for the recommendation.

Any IT guys out there?

Also, is it difficult to set up email accounts with Django or do I
require an IT guy for that as well?

Need to set up some accounts and could use a little help.

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



Re: Help with custom model method for query

2011-06-10 Thread Chris McComas
tethered my phone to my laptop to test it out...have this code in my
template:

{% regroup feeds by feed_type as feed_list %}
{% for feed_type in feed_list %}
{{ feed_type.grouper }}

{% for entry in feed_type.list %}
{{ entry.title }}
{% endfor %}
{% endfor %}

it does the first {% for %} loop perfectly, the second {% for %} loop
gets the Feed from the database for that FeedType, but I need it to
get FeedItems for Feed in FeedType

Thanks for any help

On Jun 10, 8:54 am, Chris McComas  wrote:
> Thanks very much!
>
> The city is passed to the view as an argument.
>
> How would I run the regroup? I'm on the road and not around my laptop
> for a few hours.
>
> would it be:
>
> {% regroup feeds by type as feed_list %}
>         {% for type by feed_list %}
>                 {{ type.name }}
>                 
>                 {% for entry in feed.list %}
>                         {{ entry.title }}
>                 {% endfor %}
>                 
>         {% endfor %}
>
> On Jun 10, 6:21 am, bruno desthuilliers
>
>
>
>
>
>
>
>  wrote:
> > On Jun 10, 6:13 am, Chris McComas  wrote:
>
> > > I have this views.py and models.py:
>
> > >http://dpaste.com/552615/
>
> > > On the view what I want to do is display a list of all the feed types
> > > (News, Sports, etc general categories), then then below each of those
> > > feed type headings display the FeedItems for each feed for that city.
>
> > Which city ?
>
> > > Prior to adding the City model it was pretty easy, I was able to just
> > > do this in my template:
>
> > >http://dpaste.com/552616/
>
> > > Maybe it's because it's late and I'm out of coffee, but this is
> > > totally stumping me on how to do this best. Any help would be greatly
> > > appreciated!
>
> > Assuming the city is passed as an argument to the view (dummy code,
> > may have a few errors):
>
> > # views.py
>
> > def news(request, city_id):
> >     city = get_object_or_404(City, pk=city_id)
> >     feeds = Feed.objects.filter(city=city).select_related("type")
> >     return render_to_response(
> >         "path/to/template.html",
> >         dict(city=city, feeds=feeds)
> >         )
>
> > then in you template you just {% regroup %} feeds by 
> > type,cfhttps://docs.djangoproject.com/en/1.3/ref/templates/builtins/#regroup

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



"Serge Illaryonov wants to chat" - My apology

2011-06-10 Thread javatina
It looks like I accidentally clicked yesterday on that small thing in
my Google email client while reading Django digest - evidently that
resulted in this embarrassing message. I want to apologize - I never
meant to spam the group.

Serge

-- 
You received this message because you are subscribed to the Google 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: 'ValuesListQuerySet' object has no attribute 'META'

2011-06-10 Thread javatina
> What are you doing with the list once you generate it? Are you just running
> that single line of code, for instance, in a Python shell, or is this error
> generated in a view?

Attempt to "cast" QuerySet to list appeared during my experimentation
with Python/Django to see what I can do with both, and how practical
efficient both are for me. In this particular case, I am trying to
reproduce in Django one of the simplest techniques to implement
"Previous"/Next" type of navigation from records. So, in this case, I
open a Concept record. Instead of going back to a page with the list
of "concepts" I want to go directly to the next concept that would
appear next in such list.

> Can you post the rest of the code around this, or at least more of a
> traceback, unless that is really all that there is? And if it is, then I'd
> really like to take a look at your model definition.

Absolutely. I am glad you are willing to look at it - many thanks. See
below. Also, I would like to mention that there is no problem to find
workaround (in fact, on of them is in the code below (commented out)).
But I was just surprised that I could even do such seemingly simple
thing as list(QuerySet).

Best, regards,
Serge

= in urls.py: ==
(r'^test/([-a-z0-9]+)/$', views.test),

= in views.py: ===
see formatted http://dpaste.com/hold/552703/

same as:

def test(request, slug=None):
slugs = Concept.objects.filter(status__slug = 'active').order_by('-
published_on').values_list('slug', flat=True)
try:
concept = Concept.objects.get(slug = slug, status__slug =
'active')
except Page.DoesNotExist:
raise Http404

slugs_list = list(slugs)  # ==> problem line

#object_slug = concept.slug
#index = 1;
#break_at_index = - 1;
#previous_slug = None;
#next_slug = None;
#
#for slug in slugs:
#if object_slug == slug:
#break_at_index = index + 1
#else:
#if index == break_at_index:
#next_slug = slug
#break
#else:
#previous_slug = slug
#
#index += 1

concept_opportunities =
Opportunity.objects.filter(opportunity_concepts = concept.concept_id,
status__slug = 'active')
concept_resources = concept.concept_resources.all()
concept_types = concept.concept_types.all()
concept_tags = concept.tags.all()
context = {
'header_title':'Concept',
'object': concept,
'concept_resources': concept_resources,
'concept_types': concept_types,
'concept_opportunities': concept_opportunities,
'concept_tags': concept_tags,
'previous_slug':previous_slug,
'next_slug':next_slug,
'page_marker':'co',
'index': index - 1,
}
return render_to_response('page_concept.html',
  context,
 
context_instance=RequestContext(request))

= in models.py 
class Concept(models.Model):

concept_id = models.AutoField(primary_key=True)
name = models.CharField(unique=True, max_length=100)
slug = models.SlugField(max_length=45, blank=True, unique=True)
meta_keywords = models.CharField(null=True, blank=True,
max_length=300 )
meta_description = models.CharField(null=True, blank=True,
max_length=300 )
status = models.ForeignKey(Status)
enable_comments = models.BooleanField()
description = models.CharField(null=True, blank=True,
max_length=1500, help_text='The body of concept item')
published_on = models.DateField(null=True, blank=True)
review_by = models.DateField(null=True, blank=True,
help_text='Date when the record should be reviewed to verify if the
concept still holds true.')
date_created = models.DateField(auto_now_add=True, editable=False)
date_updated = models.DateField(auto_now=True, editable=False)
created_by = models.ForeignKey(User, null=True, blank=True,
related_name="concept_created_by", editable=False)
updated_by = models.ForeignKey(User, null=True, blank=True,
related_name="concept_updated_by", editable=False)
concept_resources = models.ManyToManyField(Resource)
concept_types = models.ManyToManyField(Type)
tags = TaggableManager(blank=True)

class Meta:
ordering = ['published_on']
verbose_name = "Concept"
verbose_name_plural = "Concepts"

def __unicode__(self):
return self.name

=  traceback =
http://dpaste.com/552702/

-- 
You received this message because you are subscribed to the Google 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 custom model method for query

2011-06-10 Thread Chris McComas
Thanks very much!

The city is passed to the view as an argument.

How would I run the regroup? I'm on the road and not around my laptop
for a few hours.

would it be:

{% regroup feeds by type as feed_list %}
{% for type by feed_list %}
{{ type.name }}

{% for entry in feed.list %}
{{ entry.title }}
{% endfor %}

{% endfor %}


On Jun 10, 6:21 am, bruno desthuilliers
 wrote:
> On Jun 10, 6:13 am, Chris McComas  wrote:
>
> > I have this views.py and models.py:
>
> >http://dpaste.com/552615/
>
> > On the view what I want to do is display a list of all the feed types
> > (News, Sports, etc general categories), then then below each of those
> > feed type headings display the FeedItems for each feed for that city.
>
> Which city ?
>
> > Prior to adding the City model it was pretty easy, I was able to just
> > do this in my template:
>
> >http://dpaste.com/552616/
>
> > Maybe it's because it's late and I'm out of coffee, but this is
> > totally stumping me on how to do this best. Any help would be greatly
> > appreciated!
>
> Assuming the city is passed as an argument to the view (dummy code,
> may have a few errors):
>
> # views.py
>
> def news(request, city_id):
>     city = get_object_or_404(City, pk=city_id)
>     feeds = Feed.objects.filter(city=city).select_related("type")
>     return render_to_response(
>         "path/to/template.html",
>         dict(city=city, feeds=feeds)
>         )
>
> then in you template you just {% regroup %} feeds by 
> type,cfhttps://docs.djangoproject.com/en/1.3/ref/templates/builtins/#regroup

-- 
You received this message because you are subscribed to the Google 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: VERY cheap django hosting?

2011-06-10 Thread Andre Terra
site5.com  is a no-brainer when it
comes to inexpensive django hosting. Coupons for free domain registration,
and plans starting at $4.95/mo with *unlimited *disk space *and *bandwidth.
What else could you ask for? And it's got a wide range of server locations
as well (6 in the US, 2 in Canada, plus UK, Australia and The Netherlands).

No, i don't work for them.. I'm just a very happy customer!


Sincerely,
André Terra

On Fri, Jun 10, 2011 at 3:39 AM, Samuel Fuentes wrote:

> I use djangoeurope.com which is a rebranding of djangohosting.ch with
> slightly different prices, I think. Quite happy with the service.
>
> On Jun 9, 12:52 am, Alasdair Nicol  wrote:
> > I have used djangohosting.ch before and recommend them. As BR says it's
> > very easy to deploy, and I thought their support was super.
> >
> > Alasdair
> >
> > On 08/06/11 22:13, Tiago Almeida wrote:
> >
> >
> >
> > > I usehttp://djangohosting.ch/for a small company website and haven't
> > > experienced any issues on the last 4 months.
> > > It is a shared hosting account but the machine is quite beefy and
> > > always idle :)
> > > you pay 12 every 3 months.
> > > It is very easy to deploy django project there, unlike vps where you
> > > have to configure everything.
> > > BR,
> >
> > > On Jun 8, 7:30 am, raj  wrote:
> > >> Hey guys,
> > >> Just wondering if you could give me some hosts that are very cheap for
> > >> django hosting? Is hostgator any good? I really don't know what to
> > >> look for in a host. A lot of people are recommending web faction, but
> > >> its around $9 bucks a month. I was looking in the $5 bucks a month
> > >> range. Any ideas? Thank you.
> > >> -Raj
> >
> > --
> > Alasdair Nicol
> > Developer, MEMSET Dedicated Hosting
> >
> > mail: alasd...@memset.com
> >   web:http://www.memset.com/
> >
> > Memset Ltd., registration number 4504980. 25 Frederick Sanger Road,
> Guildford, Surrey, GU2 7YD, UK.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: ManyToManyField linking to Users in another database

2011-06-10 Thread Benedict Verheyen
On 10/06/2011 13:37, Benedict Verheyen wrote:
> Hi,
> 
> 
> (2nd attempt, as after a few hours the message still doesn't show up)
> First, to sketch the situation.
> To authenticate users, I use my own login backend. Nothing special, checks 
> the users in AD.
> I have 1 project with all users in it, and other projects have their own 
> limited set of users.
> These "local" users as I call them are not used to login people, only to 
> provide extra
> information, for example, if the user is staff or superuser and so on.
> 
> I did this to provide a central login capability: if a user logs in in 1 of 
> the projects,
> the user is also logged in, in the other projects.
> Now I want a ManyToManyField from a model in one of the other projects to 
> link to
> the users from the central database instead of the it's own user database.
> 
> As i said, the local user database is only used to specify wether a user is 
> staff or superuser and so on.
> 
> For checking users, you can do this, where central_users is the central 
> database
> user = User.objects.using('central_users').get(pk=user_id)
> 
> Is there something similar for models?
> I have a model "Call" that can have several Users linked too.
> ...
> initiator = models.ManyToManyField(User)
> ...
> 
> Is there a way to have this link to the users in the central_users database?
> 
> Regards,
> Benedict
> 

I found that i could change this in the form:

class CallForm(forms.ModelForm):
...
initiator = 
forms.ModelMultipleChoiceField(queryset=User.objects.using('central_users').order_by('first_name'),
widget=FilteredSelectMultiple("User",False,attrs={'rows':'10'}))
...

This showed the users from the central db in the form.
However on save i get an error:

ValueError at /calltracking/call/new/

Cannot add "": instance is on database "default", value is on 
database "central_users"


If I cannot solve this, I will have to populate the local User database with 
all our users to get them
in the list on the form and save the call.

Anybody know of an idea to get this to work?

Regards,
Benedict

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



ManyToManyField linking to Users in another database

2011-06-10 Thread Benedict Verheyen
Hi,


(2nd attempt, as after a few hours the message still doesn't show up)
First, to sketch the situation.
To authenticate users, I use my own login backend. Nothing special, checks the 
users in AD.
I have 1 project with all users in it, and other projects have their own 
limited set of users.
These "local" users as I call them are not used to login people, only to 
provide extra
information, for example, if the user is staff or superuser and so on.

I did this to provide a central login capability: if a user logs in in 1 of the 
projects,
the user is also logged in, in the other projects.
Now I want a ManyToManyField from a model in one of the other projects to link 
to
the users from the central database instead of the it's own user database.

As i said, the local user database is only used to specify wether a user is 
staff or superuser and so on.

For checking users, you can do this, where central_users is the central database
user = User.objects.using('central_users').get(pk=user_id)

Is there something similar for models?
I have a model "Call" that can have several Users linked too.
...
initiator = models.ManyToManyField(User)
...

Is there a way to have this link to the users in the central_users database?

Regards,
Benedict

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



Re: Syntax Error at requested method GET !!!

2011-06-10 Thread Tom Evans
On Fri, Jun 10, 2011 at 7:27 AM, Gagan (GPS)  wrote:
> I have experienced this error on my Ubuntu 11.04. I am unable to even
> view the / page on this site. Kindly help. I was trying to learn
> Django by following the video regarding creating a wiki on
> showmedo.com . The link to the video is:
> http://showmedo.com/videotutorials/video?name=110=110
>
> Kindly Help.
>
> Following is the Traceback for reference.
>
> Environment:
>  18.   (r'^wikicamp/(?[^/]+)/save/$',
>  245.         raise error, v # invalid expression

This re is invalid, specifically "(?[^/]+)". I presume you
meant "(?P[^/]+)".

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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 custom model method for query

2011-06-10 Thread bruno desthuilliers
On Jun 10, 6:13 am, Chris McComas  wrote:
> I have this views.py and models.py:
>
> http://dpaste.com/552615/
>
> On the view what I want to do is display a list of all the feed types
> (News, Sports, etc general categories), then then below each of those
> feed type headings display the FeedItems for each feed for that city.

Which city ?

> Prior to adding the City model it was pretty easy, I was able to just
> do this in my template:
>
> http://dpaste.com/552616/
>
> Maybe it's because it's late and I'm out of coffee, but this is
> totally stumping me on how to do this best. Any help would be greatly
> appreciated!

Assuming the city is passed as an argument to the view (dummy code,
may have a few errors):

# views.py

def news(request, city_id):
city = get_object_or_404(City, pk=city_id)
feeds = Feed.objects.filter(city=city).select_related("type")
return render_to_response(
"path/to/template.html",
dict(city=city, feeds=feeds)
)

then in you template you just {% regroup %} feeds by type,cf
https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#regroup

-- 
You received this message because you are subscribed to the Google 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 add CSRF to context when using test client???

2011-06-10 Thread Artemenko Alexander
Hi Matt,

Use:

from django.test import Client
csrf_client = Client(enforce_csrf_checks=True)

https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#testing

10.06.2011, 08:48, "Matteius" :
> Greetings,
>
> I am writing unit tests for my application, and I want to leave CSRF
> checks enabled in testing.  This means on my POST I am getting 403
> because I have not figured out how to add csrf to my context when
> using the test client.  Please advise on how to most easily do this:
>
> # Issue a POST request.
> response = self.client.post('/student/open_enrollments/',
> {'course': 3})
> # Check that the response is 200 OK.
> self.assertEqual(response.status_code, 200)
> # Verify template is the expected one.
> self.assertTemplateUsed(response, 'student_portal/
> open_enrollments.html')
> # Check that the rendered context contains now 0 Courses.
> self.assertEqual(len(response.context['courses']), 0)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: VERY cheap django hosting?

2011-06-10 Thread Samuel Fuentes
I use djangoeurope.com which is a rebranding of djangohosting.ch with
slightly different prices, I think. Quite happy with the service.

On Jun 9, 12:52 am, Alasdair Nicol  wrote:
> I have used djangohosting.ch before and recommend them. As BR says it's
> very easy to deploy, and I thought their support was super.
>
> Alasdair
>
> On 08/06/11 22:13, Tiago Almeida wrote:
>
>
>
> > I usehttp://djangohosting.ch/for a small company website and haven't
> > experienced any issues on the last 4 months.
> > It is a shared hosting account but the machine is quite beefy and
> > always idle :)
> > you pay 12 every 3 months.
> > It is very easy to deploy django project there, unlike vps where you
> > have to configure everything.
> > BR,
>
> > On Jun 8, 7:30 am, raj  wrote:
> >> Hey guys,
> >> Just wondering if you could give me some hosts that are very cheap for
> >> django hosting? Is hostgator any good? I really don't know what to
> >> look for in a host. A lot of people are recommending web faction, but
> >> its around $9 bucks a month. I was looking in the $5 bucks a month
> >> range. Any ideas? Thank you.
> >> -Raj
>
> --
> Alasdair Nicol
> Developer, MEMSET Dedicated Hosting
>
> mail: alasd...@memset.com
>   web:http://www.memset.com/
>
> Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, 
> Guildford, Surrey, GU2 7YD, UK.

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



Syntax Error at requested method GET !!!

2011-06-10 Thread Gagan (GPS)
I have experienced this error on my Ubuntu 11.04. I am unable to even
view the / page on this site. Kindly help. I was trying to learn
Django by following the video regarding creating a wiki on
showmedo.com . The link to the video is:
http://showmedo.com/videotutorials/video?name=110=110

Kindly Help.

Following is the Traceback for reference.

Environment:

Request Method: GET
Request URL: http://192.168.2.127:8000/
Django Version: 1.2.5
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'wikicamp.wiki']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/lib/pymodules/python2.7/django/core/handlers/base.py" in
get_response
  91. request.path_info)
File "/usr/lib/pymodules/python2.7/django/core/urlresolvers.py" in
resolve
  215. for pattern in self.url_patterns:
File "/usr/lib/pymodules/python2.7/django/core/urlresolvers.py" in
_get_url_patterns
  244. patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
File "/usr/lib/pymodules/python2.7/django/core/urlresolvers.py" in
_get_urlconf_module
  239. self._urlconf_module =
import_module(self.urlconf_name)
File "/usr/lib/pymodules/python2.7/django/utils/importlib.py" in
import_module
  35. __import__(name)
File "/home/demonstrator/django_projects/wikicamp/../wikicamp/urls.py"
in 
  18.   (r'^wikicamp/(?[^/]+)/save/$',
'wikicamp.wiki.views.save_page'),
File "/usr/lib/pymodules/python2.7/django/conf/urls/defaults.py" in
patterns
  24. t = url(prefix=prefix, *t)
File "/usr/lib/pymodules/python2.7/django/conf/urls/defaults.py" in
url
  34. return RegexURLResolver(regex, urlconf_module, kwargs,
app_name=app_name, namespace=namespace)
File "/usr/lib/pymodules/python2.7/django/core/urlresolvers.py" in
__init__
  143. self.regex = re.compile(regex, re.UNICODE)
File "/usr/lib/python2.7/re.py" in compile
  190. return _compile(pattern, flags)
File "/usr/lib/python2.7/re.py" in _compile
  245. raise error, v # invalid expression

Exception Type: error at /
Exception Value: syntax error

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



Django-based daily deals aggregator

2011-06-10 Thread Dealshelve (deals aggregator)
Hi guys,

We are working on a Django-based project at http://dealshelve.com (hosted by
WebFaction) with the hope to aggregate daily deals from as many group buying
sites as possible. We plan to make our aggregator framework to be available
publicly to allow anyone to submit new sites with the necessary
configuration to start crawling deals from the new sites, assuming those
sites do not already provide API/RSS feeds with the deals information.

We look forward to your feedback!
If you prefer to send in anonymous feedback, you can do so at
http://dealshelve.com/feedback/

Cheers,
Dealshelve Team
http://dealshelve.com

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



Re: Passing cookies around?

2011-06-10 Thread Lucian Nicolescu
I am sure someone already replied to a somewhat similar situation, he
advised for using a process called session handoff. Search the
discussion history and see if that helps.

On Fri, Jun 10, 2011 at 12:26 AM, Roy Smith  wrote:
> We're using django as a front end to a pre-existing web site
> implemented in PHP.  The PHP code has a vaguely RESTful interface,
> where you can make HTTP calls on it and get back JSON-ized data.  The
> django layer sits in front of that and talks directly to the browser.
> We're not using any models in django; just using the views to render
> django templates using the data from the PHP back end.
>
> Authentication on the original site was via session cookies maintained
> in the browser.  We're trying to figure out how to make the django
> layer deal with authentication.  My thought is that it shouldn't.  It
> should be entirely stateless, and just transparently pass cookie
> headers back and forth between the browser and the PHP back end.
> Probably by using some middleware to do this.
>
> Has anybody done anything like this before?  Am I heading off into
> weeds?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Authentication in API (REST)

2011-06-10 Thread Malcolm Box
On 10 June 2011 01:26, Yohanes Adhi Nugraha  wrote:

>
> Not that one, if we use django.contrib.auth and @login_required,  it's
> only redirects you to login page.
> What I saw from another site is, browser will popup an alert with
> username and password to be filled.
>
>

View source is your friend. Have a look at the other site and figure out how
they do it.

My guess is that they will have an unauthenticated page with some JS on it
that tries to make an authenticated call, catches any return error and
prompts for login.

Malcolm

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