Re: Newbie: how to tell a URL for a page?

2010-07-28 Thread BobAalsma
This question has been in the forum for about almost a week & no
response. So please help a newbie out: is it too easy or too difficult
to answer?

On Jul 24, 7:29 pm, BobAalsma  wrote:
> I'm working on a programme where I want the user to register comments
> on a third party web page.
> To show this third party page, I intend to use frames or iframes, but
> I discovered that some of the URLs redirect. This means that the page
> shown in the (i)frame will have a different URL from the URL I use.
> The redirection is in itself also information I want to show.
>
> So my question is: how can I tell the URL of the page (finally) shown
> in the (i)frame?

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



User Registration: Looking for tips

2010-07-28 Thread strayhand
I'm using the auth module for my project and I've got a registration
form that's based on the "UserCreationForm" provided by
"django.contrib.auth.forms" but it's only showing the username and
password fields.

I want a registration process that requires users to fill out ALL of
the "User" fields plus the fields in my "UserProfile" model.

If someone has some basic suggestions for how to modify the
UserCreationForm to include these additional fields I'm all ears. I
managed to find some basic examples of how to hide certain ModelForm
fields or change their labels but nothing about adding additional
fields, particularly from other models.

In addition to modifying the UserCreationForm I've come across a
couple of leads:

1. Build my own registration process following this example:

http://www.b-list.org/weblog/2006/sep/02/django-tips-user-registration/

I'm concerned with how old this post is. Is this approach still valid
given that it was posted in 2006? The author is using both the User
model and his own UserProfile model. I think that I could adapt this
for my purpose.

2. Use the django-registration package provided by the same author

http://bitbucket.org/ubernostrum/django-registration/overview

I'm concerned with having to install additional packages into Django.
It seems like this will make deploying my application on a Web host
more difficult. Can anyone speak to this?

Thank you for your suggestions. I've provided my code thus far below.

# forms.py

from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext

def register(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
new_user = form.save()
return HttpResponseRedirect("/somewhere/")
else:
form = UserCreationForm()
return render_to_response("registration/register.html",
{'form':form,}, context_instance=RequestContext(request))

# profiles.models.py

from django.db import models
from django.contrib.auth.models import User
from ylbbq.areas.models import Area

class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
phone = models.CharField(max_length=12)
address = models.CharField(max_length=70)
city = models.CharField(max_length=50)

STATES = (
('AK', 'Alaska'),
   ...
)

state_province = models.CharField(max_length=2, choices=STATES,
verbose_name='State or Province')

COUNTRIES = (
('USA', 'United States'),
('Canada', 'Canada')
)

country = models.CharField(max_length=20, choices=COUNTRIES)
zip_code = models.CharField(max_length=5)
birth_date = models.DateField()
areas = models.ManyToManyField(Area)

# templates/registration/register.html

{% extends "base.html" %}

{% block title %} Account Registration {% endblock %}

{% block content %}
Create an account

{% csrf_token %}
{{ form.as_p }}



{% endblock %}

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

2010-07-28 Thread Horst Gutmann
Have you already looked through this list? http://djangofriendly.com/hosts/

-- Horst

On Wed, Jul 28, 2010 at 9:41 PM, kostia  wrote:
> Our startup http://github.com/vaxXxa/projector has to be hosted
> somewhere.
>
> I'm looking for someone who can help.
>
> Be happy,
>
> Kostia.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: File sharing service on Django?

2010-07-28 Thread Artem
Well, that's what I intended to do - a least I would know a file is
started to download.
Problem is - way of file transfer. I got something like:

response = HttpResponse(open('/way/to/file/test.rar'),
mimetype='application/x-rar-compressed')
response['Content-Disposition'] = 'attachment;
filename=archive.rar'
return response

and it works fine on my desktop, but I don't know how it will go on
server with large files.

On 28 июл, 17:51, Christoph  wrote:
> Hi Artem,
>
> I don't know about it specifically but I have one possible solution.
> That may not be what you want and I'd like to hear critique on it:
>
> Have a model with fields id (or url or slug), status and filename (and
> more if you wish).
> This could be filled with: id=42, status=no_downloads_yet,
> filename="pictures.zip"
> Create urls that point to a view. Like this:www.mypage.foo/download/42
> A view would be called in which the status is tested and if
> appropriate the file is returned. The status should then be changed.
> (Shortcoming: I don't know off-hand how to test whether a download was
> completed or dropped or the like.)
>
> Comments welcome!
>
> Best regards,
> Christoph
>
> On 27 Jul., 22:55, Artem  wrote:
>
>
>
> > Is there any painless way to make Django able to serve files with one-
> > time urls, like in RapidShare?
> > First thought - use django.views.static.serve with some tweeks. But is
> > there a way to track status of download (dropped\complited)?
>
> > 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Newbie: how to tell a URL for a page?

2010-07-28 Thread BobAalsma
This question has been in the forum for about almost a week & no
response. So please help a newbie out: is it too easy or too difficult
to answer?

On Jul 24, 7:29 pm, BobAalsma  wrote:
> I'm working on a programme where I want the user to register comments
> on a third party web page.
> To show this third party page, I intend to use frames or iframes, but
> I discovered that some of the URLs redirect. This means that the page
> shown in the (i)frame will have a different URL from the URL I use.
> The redirection is in itself also information I want to show.
>
> So my question is: how can I tell the URL of the page (finally) shown
> in the (i)frame?

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



Re: Newbie: how to tell a URL for a page?

2010-07-28 Thread BobAalsma
This question has been in the forum for about almost a week & no
response. So please help a newbie out: is it too easy or too difficult
to answer?

On Jul 24, 7:29 pm, BobAalsma  wrote:
> I'm working on a programme where I want the user to register comments
> on a third party web page.
> To show this third party page, I intend to use frames or iframes, but
> I discovered that some of the URLs redirect. This means that the page
> shown in the (i)frame will have a different URL from the URL I use.
> The redirection is in itself also information I want to show.
>
> So my question is: how can I tell the URL of the page (finally) shown
> in the (i)frame?

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



Re: Newbie: how to tell a URL for a page?

2010-07-28 Thread BobAalsma
This question has been in the forum for about almost a week & no
response. So please help a newbie out: is it too easy or too difficult
to answer?

On Jul 24, 7:29 pm, BobAalsma  wrote:
> I'm working on a programme where I want the user to register comments
> on a third party web page.
> To show this third party page, I intend to use frames or iframes, but
> I discovered that some of the URLs redirect. This means that the page
> shown in the (i)frame will have a different URL from the URL I use.
> The redirection is in itself also information I want to show.
>
> So my question is: how can I tell the URL of the page (finally) shown
> in the (i)frame?

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



Re: Newbie: how to tell a URL for a page?

2010-07-28 Thread BobAalsma
This question has been in the forum for about almost a week & no
response. So please help a newbie out: is it too easy or too difficult
to answer?

On Jul 24, 7:29 pm, BobAalsma  wrote:
> I'm working on a programme where I want the user to register comments
> on a third party web page.
> To show this third party page, I intend to use frames or iframes, but
> I discovered that some of the URLs redirect. This means that the page
> shown in the (i)frame will have a different URL from the URL I use.
> The redirection is in itself also information I want to show.
>
> So my question is: how can I tell the URL of the page (finally) shown
> in the (i)frame?

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

2010-07-28 Thread shacker
Well, I think I've got a culprit on this one. I was seeing occasional
"/tmp is out of space" messages from the server lately as well, and
wondered whether these two things might be connected. It's a VPS and
the /tmp partition is locked at 100MBs - can't be made larger. So I
reconfigured mysql to use a separate directory for temp space, in /
home. The errors stopped happening immediately (knock wood).

It begs the question as to why this fairly low-traffic Django site
wanted so much /tmp space - there are dozens of WP sites on the same
server with more traffic, and it's never been an issue for them. So
I'm not sure about the cause, but I do seem to have found a fix.

Not sure it's still relevant but here's the output of "SHOW ENGINE
INNODB STATUS":

http://dpaste.com/223011/

Thanks guys.

./s

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



ModelChoiceField Question

2010-07-28 Thread Carlos Daniel Ruvalcaba Valenzuela
Hello list,

I was wondering which would be the best way to handle this situation
with ModelChoiceFields:

I have a form with a ModelChoiceField, the options presented in this
field may change at the view depending on the user, however,
ModelChoiceField requires the queryset to be given as a parameter when
defining the form, which is the best way to handle this? is there a
commonly used way for this? I was thinking on using a Factory method
like this:

def MyForm_builder(queryset):
class MyForm(forms.Form):
field = forms.ModelChoiceField(queryset=queryset)
return MyForm

Any thoughts on this?

Regards,
Carlos Daniel Ruvalcaba Valenzuela

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Best way to present N items in table row for list

2010-07-28 Thread Rainy


On Jul 27, 12:51 pm, Wadim  wrote:
> Hello.
> I have a list that i want to present in a table.
> Each row should have 5 items.
> For now i create the function that returns me new grouped list, that i
> use later in a template.
> def groupListByRow(list):
>         cnt=0
>         rows=[]
>         while cnt                 row=[]
>                 for x in range(5):
>                         if cnt                                 row.append(list[cnt])
>                         else:
>                                 row.append(None)
>                         cnt+=1
>                 rows.append(row)
>         return rows;
> is there better way to do this? May be it is possible to do it inside
> template?
> Thanks


Are you sure you need a table and you can't just make a
bunch of floating DIVs with some fixed width? If you need a
table, I would personally prefer to do this in python code,
like so:

lst = range(42)
rows = []
while lst:
row, lst = lst[:5], lst[5:]
rows.append(row + [None]*(5 - len(row)))

   -ak

--
 Django by Example Tutorials: http://lightbird.net/dbe/
 Pysuite - Python Vim plugins: http://lightbird.net/pysuite/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 1.2 modelformset_factory fails with meta: widgets

2010-07-28 Thread Jason
Traceback:
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File "C:\Documents and Settings\goodrich\PycharmProjects\CCC\Aggregator
\newsmail\views.py" in manage_articles
  174.   form = ArticleForm)
File "C:\Python25\lib\site-packages\django\forms\models.py" in
modelformset_factory
  669.
formfield_callback=formfield_callback)
File "C:\Python25\lib\site-packages\django\forms\models.py" in
modelform_factory
  407. return ModelFormMetaclass(class_name, (form,),
form_class_attrs)
File "C:\Python25\lib\site-packages\django\forms\models.py" in __new__
  220.   opts.exclude,
opts.widgets, formfield_callback)
File "C:\Python25\lib\site-packages\django\forms\models.py" in
fields_for_model
  178. formfield = formfield_callback(f, **kwargs)

Exception Type: TypeError at /newsmail/manage/
Exception Value: () got an unexpected keyword argument
'widget'



On Jul 28, 12:00 pm, Daniel Roseman  wrote:
> On Jul 28, 7:08 pm, Jason  wrote:
>
>
>
> > For example:
>
> > class ArticleForm(ModelForm):
> >     class Meta:
> >         model = Article
> >         widgets = {
> >              'pub_date': SplitSelectDateTimeWidget(),
> >              'expire_date': CalendarWidget(attrs={'class':'date-
> > pick'})
> >         }
>
> > And in a view function:
> > ...
> >     ArticleFormSet = modelformset_factory(Article,
> >                                           form = ArticleForm,
> >                                           extra=0)
> > ...
>
> > Removing 'widgets' from the Meta in ArticleForm fixes the error.
>
> > The new widgets convention here is really handy. I don't want to lose
> > it!
>
> > Any tips?
>
> How does it fail? What error do you get? If there's a traceback,
> please post it here.
> --
> 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-us...@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 INNER JOIN

2010-07-28 Thread Roald de Vries

On Jul 28, 2010, at 6:02 PM, kostia wrote:

Well, I used

projects = projects.filter(favourites__user = request.user)

And then I tired to order by 'date' field, which is in the Favourite
model like here:

projects = projects.filter(favourites__user =
request.user)#.order_by(filter_field)

And it throws me an error: "Cannot resolve keyword 'date' into field.
Choices are: author, benefit_description, category, creation_date,
description, favourites, id, published, resource_description, title,
video_link, votes"

favourites__date also did not help.

Any idea?


Because you're querying the Projects, you can not use Favourite fields  
as keywords. So you'll (more or less) have to stick with the other  
option.


Cheers, Roald

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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 doesn't load css

2010-07-28 Thread Andreas Pfrengle
Hallo everyone,

thanks for the many answers, the problem is solved. There must have
been an error in the urls.py. Now it works with the static serving:
# from urls.py:
site_media = os.path.join(os.path.dirname(__file__), 'site_media')

urlpatterns += patterns('',
url(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': site_media}),
)

Now we've also replaced the hardcoded urls with "{{MEDIA_URL}}css/
test.css"

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



Python/Django hosting

2010-07-28 Thread kostia
Our startup http://github.com/vaxXxa/projector has to be hosted
somewhere.

I'm looking for someone who can help.

Be happy,

Kostia.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 doesn't load css

2010-07-28 Thread kostia
static is a folder, it is not a view

our project code can be found here
http://github.com/vaxXxa/projector

You may look at and compare.

Good luck.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 1.2 modelformset_factory fails with meta: widgets

2010-07-28 Thread Daniel Roseman
On Jul 28, 7:08 pm, Jason  wrote:
> For example:
>
> class ArticleForm(ModelForm):
>     class Meta:
>         model = Article
>         widgets = {
>              'pub_date': SplitSelectDateTimeWidget(),
>              'expire_date': CalendarWidget(attrs={'class':'date-
> pick'})
>         }
>
> And in a view function:
> ...
>     ArticleFormSet = modelformset_factory(Article,
>                                           form = ArticleForm,
>                                           extra=0)
> ...
>
> Removing 'widgets' from the Meta in ArticleForm fixes the error.
>
> The new widgets convention here is really handy. I don't want to lose
> it!
>
> Any tips?

How does it fail? What error do you get? If there's a traceback,
please post it here.
--
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-us...@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 1.2 modelformset_factory fails with meta: widgets

2010-07-28 Thread Jason
For example:

class ArticleForm(ModelForm):
class Meta:
model = Article
widgets = {
 'pub_date': SplitSelectDateTimeWidget(),
 'expire_date': CalendarWidget(attrs={'class':'date-
pick'})
}


And in a view function:
...
ArticleFormSet = modelformset_factory(Article,
  form = ArticleForm,
  extra=0)
...

Removing 'widgets' from the Meta in ArticleForm fixes the error.

The new widgets convention here is really handy. I don't want to lose
it!

Any tips?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 doesn't load css

2010-07-28 Thread Daniel Roseman
On Jul 28, 4:21 pm, Andreas Pfrengle  wrote:
> Hi,
>
> we've been trying for hours now to include a css-file in our project,
> but it just doesn't work and we don't know why. We've already reduced
> the project to the absolute minimum of necessary code:
> 
> #settings.py:
> PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
> MEDIA_ROOT = os.path.normpath(os.path.join(PROJECT_PATH,
> 'site_media/'))
> TEMPLATE_DIRS = ('templates', )
>  app is included in ISTALLED_APPS>
>
> #site_media/css/test.css:
> body {
>         background: #9ba49b url("../images/test.jpg"); }
>
> #site_media/images/test.jpg:
> 
>
> #templates/base.html:
>    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;>
> 
> 
>         
> 
> 
> test
> 
> 
>
> #testapp/views.py:
> from django.shortcuts import render_to_response
> from django.template import Context, RequestContext
>
> def home(request):
>     data = {}
>     return render_to_response('base.html', RequestContext(request,
> data))
>
> 
> When I drag base.html in the browser, the css is included, loading the
> test.jpg image. When loading the page in the django-project, the css
> isn't loaded (neither the background color, nor the image). When I
> include the css code directly in base.html 

Re: Django doesn't load css

2010-07-28 Thread Antoni Aloy
2010/7/28 Andreas Pfrengle :
> Hello Kostia,
>
> I get a template syntax error with your method, since I haven't
> defined a "static" view. How does your static-view look like?
> I've already tried it like described here -->  docs.djangoproject.com/en/dev/howto/static-files/> but I don't get it
> work either, I get a TypeError: bad operand type for unary +: 'list'
> for the urlpattern that the docs suggest to include.
>
> Antoni, we've tried it already with the {{ MEDIA_URL }} variable, but
> to make it braindead simple we've hardcoded the paths.
> On the example you've linked: There is only a picture in the download
> section, no code.

Use subversion Luke :)

Sorry I can't resist. ;)

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 access a MySQL table in Django?

2010-07-28 Thread snipinben

I have the python-mysqldb installed already and i have  django up and
running. when i installed the python-mysqldb i had to hack the code kind of
so that it didnt check if the versions were the same so that it would work.
I got this idea from online. but anyways, I am wondering how to access
records that were already in the database before I started the project. i
know how to access records from data that i inserted through tables in the
models.py file. but i have no idea how to access them straight from the
database itself. please give me any info you got. thanks
-- 
View this message in context: 
http://old.nabble.com/How-to-access-a-MySQL-table-in-Django--tp29289314p29289314.html
Sent from the django-users mailing list archive at Nabble.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-us...@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 doesn't load css

2010-07-28 Thread Andreas Pfrengle
Hello Kostia,

I get a template syntax error with your method, since I haven't
defined a "static" view. How does your static-view look like?
I've already tried it like described here -->  but I don't get it
work either, I get a TypeError: bad operand type for unary +: 'list'
for the urlpattern that the docs suggest to include.

Antoni, we've tried it already with the {{ MEDIA_URL }} variable, but
to make it braindead simple we've hardcoded the paths.
On the example you've linked: There is only a picture in the download
section, no code.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Calculate distance between 2 latitude/longitude Point

2010-07-28 Thread !!CONDORIOUS!!
(lat , lon in radians)

pt 1 = lat, lon, alt=0
pt 2 = lat, lon, alt=0

p1_gcc = gd2gcc(p1)
p1_gcc = gd2gcc(p2)

gd2gcc ( is a standard operation found on the itnernet)

dis = sqrt(sum(pow(p1_gcc-p2-gcc, 2)))

cheers,

2010/7/28 Alexandre González :
> Hi! I'm using the Django GEOS API [1] in my project to see the distance
> between two users.
> I get the coordinates from google maps in latitude/longitude mode and I need
> to calculate the distance between them. I'm testing with .distance() method
> at GEOSGeometry but I receive a strange value.
> This is the result of one of my test:
> In [45]: Point(40.96312364002175,
> -5.661885738372803).distance(Point(40.96116097790996, -5.66283792257309))
> Out[45]: 0.0021814438604553388
> In Google Maps Distance Calculator [2] I can see that the result is: 0.145
> miles = 0.233 km = 0.126 nautical miles = 233 meters = 764.436 feet
> A friend told me on Google that perhaps I must calculate the distance in
> UTMs and the results surely is a lat/long distance. To test it I need pygps
> that is a project not maintained to import
> LLtoUTMfrom from LatLongUTMconversion
> Any idea about this?
> [1] http://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/
> [2] http://www.daftlogic.com/projects-google-maps-distance-calculator.htm
>
> --
> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> and/or .pptx
> http://mirblu.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-us...@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.
>



-- 
Condor
310.951.1177
condor.c...@gmail.com

:%s/war/peace/g

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Calculate distance between 2 latitude/longitude Point

2010-07-28 Thread Alexandre González
I've tested it yet multiplying in miles and kilometers but the result if K
miles/kms instead the correct result.

Thanks for your reply.

On Wed, Jul 28, 2010 at 19:00, Bill Freeman  wrote:

> Having done my geo distance by "hand" instead of Django GEOS, it may not
> be relevant, but have you tried multiplying the result you get by the
> radius of
> the earth?  Most formulas for this kind of thing are applicable to any
> size sphere,
> not just the earth, and return the distance as an angle, as seen from the
> center
> of the sphere, and typically in radians.
>
> Bill
>
> 2010/7/28 Alexandre González :
> > Hi! I'm using the Django GEOS API [1] in my project to see the distance
> > between two users.
> > I get the coordinates from google maps in latitude/longitude mode and I
> need
> > to calculate the distance between them. I'm testing with .distance()
> method
> > at GEOSGeometry but I receive a strange value.
> > This is the result of one of my test:
> > In [45]: Point(40.96312364002175,
> > -5.661885738372803).distance(Point(40.96116097790996, -5.66283792257309))
> > Out[45]: 0.0021814438604553388
> > In Google Maps Distance Calculator [2] I can see that the result is:
> 0.145
> > miles = 0.233 km = 0.126 nautical miles = 233 meters = 764.436 feet
> > A friend told me on Google that perhaps I must calculate the distance in
> > UTMs and the results surely is a lat/long distance. To test it I need
> pygps
> > that is a project not maintained to import
> > LLtoUTMfrom from LatLongUTMconversion
> > Any idea about this?
> > [1] http://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/
> > [2]
> http://www.daftlogic.com/projects-google-maps-distance-calculator.htm
> >
> > --
> > Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx,
> .ppt
> > and/or .pptx
> > http://mirblu.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-us...@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-us...@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.
>
>


-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.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-us...@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.



Thumbnail and separated media server approach

2010-07-28 Thread Michel Thadeu Sabchuk
Hi guys,

I manage a Brazilian free ads portal and recently I migrated the
static files to rackspace cloud files [1] (Amazon S3 like). Now the
site open much faster but the media files are still in the same server
of django.

I couldn't migrate the dynamic media files to rackspace cloud files
because I need to generate thumbnails for images.

I'm a sorl thumbnail user and I'm very happy with it but it seems it
will be no more supported [2] (at least no by the authors) and there
is some functionalities (like custom storage) that I need and is not
present in the current version.

I want to make it possible to have the dynamic media files on a
separated server, first because the boost on the site (2 connections
opening the same time) and to cost cutting (a media server are cheaper
as I can use a vps with nginx or even the rackspace cloud files). Do
you have any advice?

I already started searching for options and I found something:

1) I can have a pair of servers, the admin saves on the principal site
and a cron job copies files to the secundary server (based on the
timestamp). If a file is request on the 2nd server but it is not here
yet, just redirect to the 1st server.

2) Use easy thumbnails [2], from Smiley Chris, one of the authors of
sorl thumbnail. It seems pretty good. It solves one problem of thumbs
in cloud server: the timestamp of the file is cached on the database
(as amazon s3 ou rackspace cloud do not store it in the file).

3) I can have a pair of servers, the admin saves directly on the 2nd
server (maybe through nfs).

Did someone faced a similar problem? How do you solve it? Is there
anything broken in my ideas?

Best regards.

http://rackspacecloud.com/ [1]
http://code.google.com/p/sorl-thumbnail/wiki/Future [2]
http://github.com/SmileyChris/easy-thumbnails [3]

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Calculate distance between 2 latitude/longitude Point

2010-07-28 Thread Bill Freeman
Having done my geo distance by "hand" instead of Django GEOS, it may not
be relevant, but have you tried multiplying the result you get by the radius of
the earth?  Most formulas for this kind of thing are applicable to any
size sphere,
not just the earth, and return the distance as an angle, as seen from the center
of the sphere, and typically in radians.

Bill

2010/7/28 Alexandre González :
> Hi! I'm using the Django GEOS API [1] in my project to see the distance
> between two users.
> I get the coordinates from google maps in latitude/longitude mode and I need
> to calculate the distance between them. I'm testing with .distance() method
> at GEOSGeometry but I receive a strange value.
> This is the result of one of my test:
> In [45]: Point(40.96312364002175,
> -5.661885738372803).distance(Point(40.96116097790996, -5.66283792257309))
> Out[45]: 0.0021814438604553388
> In Google Maps Distance Calculator [2] I can see that the result is: 0.145
> miles = 0.233 km = 0.126 nautical miles = 233 meters = 764.436 feet
> A friend told me on Google that perhaps I must calculate the distance in
> UTMs and the results surely is a lat/long distance. To test it I need pygps
> that is a project not maintained to import
> LLtoUTMfrom from LatLongUTMconversion
> Any idea about this?
> [1] http://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/
> [2] http://www.daftlogic.com/projects-google-maps-distance-calculator.htm
>
> --
> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> and/or .pptx
> http://mirblu.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-us...@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-us...@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: generate cache by visiting protected links

2010-07-28 Thread Jirka Vejrazka
> i have cache enabled on a few heavy statistical views.
> I would like to generate the pages before a user goes to that page and maybe 
> even
> regenerate the pages every hour to avoid the initial delay.
> However, i can't seem to automate the caching as my site's authentication 
> gets in the way
> of automating this.
>
> I've tried code that i googled that performs a cookie based login
> using urllib and urllib2 but that didn't work.
>
> Basically, i would need a view that is started when the server starts and 
> gets called
> every hour to generate or visit the url of the stats page.
> And this would have to be via a logged in user as otherwise access to the 
> stats is forbidden.

  Hi,

  is the statistics user-dependent?

  If not, just create a cron job (or similar, depending on your
platform) that will calculate the statistics every hour and maybe even
create the main blocks of the page to be displayed.

  You can either create a custom management command to do this or
write a script that uses ORM (and templating system) and Django cache.

  It very much depends on you setup, but should not be too difficult.

  Basically, you probably don't need a "view" to populate the cache.

  HTH

Jirka

P.S. http://docs.djangoproject.com/en/dev/howto/custom-management-commands/

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



Re: Using sqlite3 to test locally

2010-07-28 Thread Zo
I had not, i ran it and created a superuser. should I be changing my
setting file for my user info?

I also changed DATABASE_ROUTERS = [] because it was previously set to
['test.ReportAdmin.routers.ReportAdminRouter']

and I went back to

DATABASES = {
'default' : {
'NAME' : 'C:/python-dev/pythonproject/test/sqlite3.db'
,'ENGINE' : 'django.db.backends.sqlite3'
}

}

those changes caused my tests to actually run, but now I get lots of
tests...

--
Ran 59 tests in 0.828s

FAILED (failures=16, errors=4)
Destroying test database 'default'...

It looks like all failures come from Python26/lib/site-packages/django/
contrib/auth/tests

Here are a few of the errors/failures

==
ERROR: test_no_remote_user
(django.contrib.auth.tests.remote_user.RemoteUserCust
omTest)
--
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\django\contrib\auth\tests
\remote_user.py",
 line 33, in test_no_remote_user
self.assert_(response.context['user'].is_anonymous())
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_no_remote_user
(django.contrib.auth.tests.remote_user.RemoteUserNoCr
eateTest)
--
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\django\contrib\auth\tests
\remote_user.py",
 line 33, in test_no_remote_user
self.assert_(response.context['user'].is_anonymous())
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_unknown_user
(django.contrib.auth.tests.remote_user.RemoteUserNoCrea
teTest)
--
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\django\contrib\auth\tests
\remote_user.py",
 line 118, in test_unknown_user
self.assert_(response.context['user'].is_anonymous())
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_no_remote_user
(django.contrib.auth.tests.remote_user.RemoteUserTest
)
--
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\django\contrib\auth\tests
\remote_user.py",
 line 33, in test_no_remote_user
self.assert_(response.context['user'].is_anonymous())
TypeError: 'NoneType' object is unsubscriptable

==
FAIL: test_password_change_fails_with_invalid_old_password
(django.contrib.auth.
tests.views.ChangePasswordTest)
--
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\django\contrib\auth\tests
\views.py", line
143, in test_password_change_fails_with_invalid_old_password
self.login()
  File "C:\Python26\lib\site-packages\django\contrib\auth\tests
\views.py", line
127, in login
self.assertEquals(response.status_code, 302)
AssertionError: 200 != 302

==
FAIL: test_password_change_fails_with_mismatched_passwords
(django.contrib.auth.
tests.views.ChangePasswordTest)
--
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\django\contrib\auth\tests
\views.py", line
154, in test_password_change_fails_with_mismatched_passwords
self.login()
  File "C:\Python26\lib\site-packages\django\contrib\auth\tests
\views.py", line
127, in login
self.assertEquals(response.status_code, 302)




Can i disable these or should all these be passing?



Thanks,
Zo

On Jul 28, 12:20 pm, Shawn Milochik  wrote:
> Did you run ./manage.py syncdb?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 doesn't load css

2010-07-28 Thread Antoni Aloy
the css should be {% MEDIA_URL %} but you have to be sure you pass the
RequestConext on your render_to_response method.
If you're are on the development server you have to add additional
urls to urls.py to serve static content.

Is explained in the docs, but I suppose some examples you'll be
better. I created some startup and example projects that I think they
would help you.

http://code.google.com/p/appfusedjango/

Check project and agenda, they are a good start. The examples are not
updated for 1.2.1 but they work.

2010/7/28 kostia :
> I use in settings.py:
>
> MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'main',
> 'templates', 'static').replace('\\', '/')
>
>
> MEDIA_URL = '/static/'
>
>
> And then simply in an html file:
>
> 
>
> Where the full folder path is the ../project_name/main/templates/
> static/styles/nav.css
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>



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

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

2010-07-28 Thread Dennis Kaarsemaker
On wo, 2010-07-28 at 00:18 -0700, shacker wrote:
> On Jul 27, 2:49 pm, Dennis Kaarsemaker  wrote:
> > Are the tracebacks all the same? Can you share a traceback?
> 
> Sure, here's one (search/replaced to make it generic):
> 
> http://dpaste.com/222645/
> 
> It's happening on various (and unrelated) pages, but the tracebacks
> are all equally uninformative.

Indeed, very uninformative. Which database engine do you use, innodb? If
so, do a 'show engine innodb status'. The mysql errorlog may also show
relevant errors.

You could also try rebuilding tables by using 'alter table table_name
engine=innodb' (or myisam if you use that).

-- 
Dennis K.

They've gone to plaid!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 storage chinese failed to mysql!!

2010-07-28 Thread Dennis Kaarsemaker
Those settings are not all. You need to check the table definition with
either describe or show create table.

On wo, 2010-07-28 at 19:40 +0800, pengbo xue wrote:
> I have checked mysql database, maybe have no issue, but still show the
> same error.detail as below: 
>  
> mysql> SHOW VARIABLES LIKE 'character%';
> +--+
> -+
> | Variable_name| Value
>  |
> +--+
> -+
> | character_set_client | utf8
>  |
> | character_set_connection | utf8
>  |
> | character_set_database   | utf8
>  |
> | character_set_filesystem | binary
>  |
> | character_set_results| utf8
>  |
> | character_set_server | utf8
>  |
> | character_set_system | utf8
>  |
> | character_sets_dir   | C:\Program Files\MySQL\MySQL Server 5.1
> \share\chars
> ets\ |
> +--+
> -+
> 
> 
> 2010/7/28 Dennis Kaarsemaker 
> 
> On wo, 2010-07-28 at 09:11 +0800, pengbo xue wrote:
> > hi all,
> >
> > I can register from my django web page in english,but it
> can't storage
> > chinese to django mysql database.
> >
> > please give me advice.  thx
> 
> 
> Check your table definition to see whether the field you try
> to store is
> a latin1 or utf8 field. If it is latin1, it will not support
> chinese
> characters.
> 
> --
> Dennis K.
> 
> They've gone to plaid!
> 
> --
> You received this message because you are subscribed to the
> Google Groups "Django users" group.
> To post to this group, send email to
> django-us...@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.
> 
> 
> 
> 
> -- 
> 
> 
> cowboy
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-us...@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.

-- 
Dennis K.

They've gone to plaid!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 doesn't load css

2010-07-28 Thread kostia
I use in settings.py:

MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'main',
'templates', 'static').replace('\\', '/')


MEDIA_URL = '/static/'


And then simply in an html file:



Where the full folder path is the ../project_name/main/templates/
static/styles/nav.css

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: HTTP POST sent from app to Django Server returns 403 Forbidden

2010-07-28 Thread Kieran Farr
Thanks, David -- you're right on, now I just return an HttpResponse
with result code 404.

Benedict, could you post the view for /management/statistics/top/user/
yearly/ that is causing the 403?

Kieran

On Jul 28, 6:47 am, steven314  wrote:
> @etone: has this discussion of CSRF enabled you to hunt down your
> problem?
>
> Steven.
>
> On Jul 26, 4:30 pm, etone  wrote:
>
>
>
> > Hi there,
>
> > I'm trying to sent a HTTP POST from a client application to my Django
> > app.  Django does indeed receive the HTTP POST as I do hit
> > _HandleRequest(),  however it returns a 403 Forbidden, instead of
> > hitting my handler function.  I experimented and sent a HTTP GET from
> > my client application and in this case I am able to hit my handler
> > function.  I would like to use HTTP POST as I want to upload some data
> > to my Django app.
>
> > What am I doing wrong/missing?
>
> > Here is my settings.py in my django app:
>
> >  try:
> >     from djangoappengine.settings_base import *
> >     has_djangoappengine = True
> > except ImportError:
> >     has_djangoappengine = False
> >     DEBUG = True
> >     TEMPLATE_DEBUG = DEBUG
>
> > import os
>
> > INSTALLED_APPS = (
> >     'djangotoolbox',
> > #    'django.contrib.auth',
> >     'django.contrib.contenttypes',
> >     'django.contrib.sessions',
> > )
>
> > if has_djangoappengine:
> >     INSTALLED_APPS = ('djangoappengine',) + INSTALLED_APPS
>
> > ADMIN_MEDIA_PREFIX = '/media/admin/'
> > MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'media')
> > TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__),
> > 'templates'),)
>
> > ROOT_URLCONF = 'urls'

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



Re: Using sqlite3 to test locally

2010-07-28 Thread Shawn Milochik
Did you run ./manage.py syncdb?

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



Using sqlite3 to test locally

2010-07-28 Thread Zo
Hello,

I am trying to configure my django project to use sqlite3. As of now I
do not have database creation permission for SQL, so i decided to try
and do my prototyping  locally. I set the following:

DATABASES = {
'default' : {
'NAME' : 'C:/python-dev/pythonproject/test/sqlite3.db'
,'ENGINE' : 'django.db.backends.sqlite3'
}
}

when i run ./manage.py test

> django.db.utils.ConnectionDoesNotExist: The connection ReportAdmin doesn't 
> exist

I also tried

DATABASES = {
'default' : {
'NAME' : 'C:/python-dev/pythonproject/test/sqlite3.db'
,'ENGINE' : 'django.db.backends.sqlite3'
}
,'ReportAdmin' : {
'NAME' : 'C:/python-dev/pythonproject/test/sqlite3.db'
,'ENGINE' : 'django.db.backends.sqlite3'
}
}

then i get

> django.db.utils.DatabaseError: no such table: django_content_type

I just want to do my testing locally; I must be missing something...
Any help would be appreciated. I am hoping to convince my company that
django is the way to go, but I can't do that without a nice
prototype.

Bonus question: Using PyDev in eclipse, how do you execute
doctests?!?!

Thank you in advance for your time,
Zo

System specs:
Python 2.6
Django 1.2.1
Windows XP
Eclipse 3.5.2

If you need extra information please let me know.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 doesn't load css

2010-07-28 Thread Andreas Pfrengle
Hi,

we've been trying for hours now to include a css-file in our project,
but it just doesn't work and we don't know why. We've already reduced
the project to the absolute minimum of necessary code:

#settings.py:
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
MEDIA_ROOT = os.path.normpath(os.path.join(PROJECT_PATH,
'site_media/'))
TEMPLATE_DIRS = ('templates', )


#site_media/css/test.css:
body {
background: #9ba49b url("../images/test.jpg"); }

#site_media/images/test.jpg:


#templates/base.html:
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;>





test



#testapp/views.py:
from django.shortcuts import render_to_response
from django.template import Context, RequestContext

def home(request):
data = {}
return render_to_response('base.html', RequestContext(request,
data))


When I drag base.html in the browser, the css is included, loading the
test.jpg image. When loading the page in the django-project, the css
isn't loaded (neither the background color, nor the image). When I
include the css code directly in base.html 

Re: Django INNER JOIN

2010-07-28 Thread kostia
Well, I used

projects = projects.filter(favourites__user = request.user)

And then I tired to order by 'date' field, which is in the Favourite
model like here:

projects = projects.filter(favourites__user =
request.user)#.order_by(filter_field)

And it throws me an error: "Cannot resolve keyword 'date' into field.
Choices are: author, benefit_description, category, creation_date,
description, favourites, id, published, resource_description, title,
video_link, votes"

favourites__date also did not help.

Any idea?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Best way to present N items in table row for list

2010-07-28 Thread Daniel Hilton
On 27 July 2010 17:51, Wadim  wrote:
> Hello.
> I have a list that i want to present in a table.
> Each row should have 5 items.
> For now i create the function that returns me new grouped list, that i
> use later in a template.
> def groupListByRow(list):
>        cnt=0
>        rows=[]
>        while cnt                row=[]
>                for x in range(5):
>                        if cnt                                row.append(list[cnt])
>                        else:
>                                row.append(None)
>                        cnt+=1
>                rows.append(row)
>        return rows;
> is there better way to do this? May be it is possible to do it inside
> template?
> Thanks
>

Hi Wadim

You could easily do this in the template with if tag:




{% for value in list  %}
{% if value.counter1|divisibleby:"5"  %}
 {{value}}


{% else %}
{{value}}
{% if  value == list|last%}

   {% endif %}

{% endif %}
{% endfor %}


I think that's right, it's off the top of my head so use with caution.
Cheers,
Dan







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



-- 
Dan Hilton

www.twitter.com/danhilton
www.DanHilton.co.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-us...@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: moving to django 1.2.1

2010-07-28 Thread dan levine
One issue that bit me that has also been mentioned here in other
threads: errors that were previously caught are now raised as errors.
So technically it was wrong previously but functionally it only breaks
on 1.2.  I haven't found a good explanation / summary of what/why/
which errors it now affects.  Mine was a circular import error that I
had to track down.  Important to note -- the error only showed up when
the app ran via wsgi or when I did an import main in the py shell, it
did not throw an error in the dev server!!  So do your upgrade testing
accordingly.

  Good luck!

D

On Jul 28, 10:03 am, Massimiliano Ravelli
 wrote:
> On 28 Lug, 15:44, knight  wrote:
>
> > Does anybody knows a good post or blog about the changes including
> > csrf?
>
> I forgot to suggest 
> readinghttp://docs.djangoproject.com/en/dev/releases/1.2/#backwards-incompat...

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

2010-07-28 Thread Roald de Vries

On Jul 28, 2010, at 5:19 PM, kostia wrote:

Thank you very much Roald,

What is faster:
   projects = Project.objects.filter(favourites__user = request.user)
or
   select_related('project')
?



I think it doesn't matter much, but if one is faster, it should be the  
first one. If you only use the Project object, I think you should use  
the first form for readability.


Cheers, Roald

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

2010-07-28 Thread Daniel Roseman
On Jul 28, 4:16 pm, backdoc  wrote:
> 
>
>
>
> >    fav_and_projs = ((f, f.project) for f in favourites)
>
> This may not be a Django question. But, I'm not familiar with this syntax.
> Is this returning a tuple for ever item in favourites?  So, fav_and_projs
> would be a tuple of tuples, like ((f1, f.project1), (f2, fproject2),
> .(fn, fprojectn))??

Actually, this is a generator that returns tuples. It doesn't really
make sense to think of it as a single datastructure - it's more like a
function that returns the next tuple each time you call .next() on it.

To be honest in this case I'd be more likely to use a simple list
expression:
[(f, f.project) for f in favourites]
which will return a list of tuples straight away, and doesn't need
separate evaluation. However this is inefficient if you have a large
list (of favourites) to begin with.
--
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-us...@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 INNER JOIN

2010-07-28 Thread kostia
Thank you very much Roald,

What is faster:
projects = Project.objects.filter(favourites__user = request.user)
or
select_related('project')
?

Kostia

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

2010-07-28 Thread backdoc


>
>fav_and_projs = ((f, f.project) for f in favourites)
>

This may not be a Django question. But, I'm not familiar with this syntax.
Is this returning a tuple for ever item in favourites?  So, fav_and_projs
would be a tuple of tuples, like ((f1, f.project1), (f2, fproject2),
.(fn, fprojectn))??

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

2010-07-28 Thread Roald de Vries

Dear Kostia

On Jul 28, 2010, at 2:29 PM, kostia wrote:

I have a model Favourite with fields User, Project, Date, what means
that some user put some project as favourite on some date. I take all
favourites filtered by this user and I want to INNER JOIN that info
with Project model. How can I do that?

Something like projects = Favourite.objects.filter(user =
request.user).inner_join(Project, project)


Try not to think to relational, Django's models are OO.

To get the projects, you can do:

projects = Project.objects.filter(favourites__user = request.user)

To get something more like the join:

favourites = Favourites.objects.filter(user = request.user)

And then, if you need a project for any favourite, do  
favourite.project. If you want, you can also do:


fav_and_projs = ((f, f.project) for f in favourites)

Note that you can use "select_related('project')" if performance is an  
issue for you.



Cheers, Roald

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

2010-07-28 Thread kostia
Still need your help

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: File sharing service on Django?

2010-07-28 Thread Christoph
Hi Artem,

I don't know about it specifically but I have one possible solution.
That may not be what you want and I'd like to hear critique on it:

Have a model with fields id (or url or slug), status and filename (and
more if you wish).
This could be filled with: id=42, status=no_downloads_yet,
filename="pictures.zip"
Create urls that point to a view. Like this: www.mypage.foo/download/42
A view would be called in which the status is tested and if
appropriate the file is returned. The status should then be changed.
(Shortcoming: I don't know off-hand how to test whether a download was
completed or dropped or the like.)

Comments welcome!

Best regards,
Christoph


On 27 Jul., 22:55, Artem  wrote:
> Is there any painless way to make Django able to serve files with one-
> time urls, like in RapidShare?
> First thought - use django.views.static.serve with some tweeks. But is
> there a way to track status of download (dropped\complited)?
>
> 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-us...@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: moving to django 1.2.1

2010-07-28 Thread Massimiliano Ravelli
On 28 Lug, 15:44, knight  wrote:
> Does anybody knows a good post or blog about the changes including
> csrf?

I forgot to suggest reading
http://docs.djangoproject.com/en/dev/releases/1.2/#backwards-incompatible-changes-in-1-2

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

2010-07-28 Thread Massimiliano Ravelli
On 28 Lug, 15:33, Maksymus007  wrote:
> The same all the sentences link '1.1 and 1.2 are compatible'.
> They are not.

You are right: that page doesn't mention csrf changes.
I upgraded few installations from 1.0 and from 1.1 to 1.2
and the only undocumented change I remember is exactly the csrf.
I just added {% csrf_token %} after form tag in every template.
as you can read in 
http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-to-use-it

> I have quite big application written in 1.1 - still can't fully run it on 1.2.
> As I discovered: forms fields set to be blank=True and null=True when
> left blank on 1.1 get null value as expected, on 1.2 the get empty
> string - which crashes if database has constraints.

Sorry but I didn't encounter this problem.
Besides the csrf, all my upgrades went smoothly.

Regards
Massimiliano

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: HTTP POST sent from app to Django Server returns 403 Forbidden

2010-07-28 Thread steven314
@etone: has this discussion of CSRF enabled you to hunt down your
problem?

Steven.

On Jul 26, 4:30 pm, etone  wrote:
> Hi there,
>
> I'm trying to sent a HTTP POST from a client application to my Django
> app.  Django does indeed receive the HTTP POST as I do hit
> _HandleRequest(),  however it returns a 403 Forbidden, instead of
> hitting my handler function.  I experimented and sent a HTTP GET from
> my client application and in this case I am able to hit my handler
> function.  I would like to use HTTP POST as I want to upload some data
> to my Django app.
>
> What am I doing wrong/missing?
>
> Here is my settings.py in my django app:
>
>  try:
>     from djangoappengine.settings_base import *
>     has_djangoappengine = True
> except ImportError:
>     has_djangoappengine = False
>     DEBUG = True
>     TEMPLATE_DEBUG = DEBUG
>
> import os
>
> INSTALLED_APPS = (
>     'djangotoolbox',
> #    'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
> )
>
> if has_djangoappengine:
>     INSTALLED_APPS = ('djangoappengine',) + INSTALLED_APPS
>
> ADMIN_MEDIA_PREFIX = '/media/admin/'
> MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'media')
> TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__),
> 'templates'),)
>
> ROOT_URLCONF = 'urls'

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

2010-07-28 Thread knight
Does anybody knows a good post or blog about the changes including
csrf?

On Jul 28, 4:33 pm, Maksymus007  wrote:
> On Wed, Jul 28, 2010 at 3:29 PM, Massimiliano Ravelli
>
>  wrote:
> > On Jul 28, 3:13 pm, knight  wrote:
> >> What are the minimal changes that I need to make in order to work with
> >> 1.2.1?
>
> > Did you have a look 
> > athttp://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
> > ?
>
> This link in worth nothing.
> The same all the sentences link '1.1 and 1.2 are compatible'.
> They are not.
>
> I have quite big application written in 1.1 - still can't fully run it on 1.2.
> As I discovered: forms fields set to be blank=True and null=True when
> left blank on 1.1 get null value as expected, on 1.2 the get empty
> string - which crashes if database has constraints.

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

2010-07-28 Thread knight
Is anybody knows a good post or blog about these thing including csrf
changes?

On Jul 28, 4:33 pm, Maksymus007  wrote:
> On Wed, Jul 28, 2010 at 3:29 PM, Massimiliano Ravelli
>
>  wrote:
> > On Jul 28, 3:13 pm, knight  wrote:
> >> What are the minimal changes that I need to make in order to work with
> >> 1.2.1?
>
> > Did you have a look 
> > athttp://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
> > ?
>
> This link in worth nothing.
> The same all the sentences link '1.1 and 1.2 are compatible'.
> They are not.
>
> I have quite big application written in 1.1 - still can't fully run it on 1.2.
> As I discovered: forms fields set to be blank=True and null=True when
> left blank on 1.1 get null value as expected, on 1.2 the get empty
> string - which crashes if database has constraints.

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

2010-07-28 Thread derek
On Jul 26, 6:52 pm, "Casey S. Greene"  wrote:
> Does anyone have a hint for this (or an idea of where to get started in
> the documentation)?  This seems relatively simple so my best guess is
> that there is something that I am just missing.
>
> Thanks!
> -- Casey
>
> On 07/22/2010 10:16 AM, Casey S. Greene wrote:
>
> > I am trying to figure out a reasonable way to filter using a queryset
> > within a ModelForm.
>
> > In a simple example, I have three models (A, B, and C).
> > C has many A and B
> > A and B have a many to many relationship.
>
> > Assume that some instances of C and instances of B already exist.
>
> > I am using the create_object generic view to allow users to create
> > instances of A but not to select associated Bs. I'm then using
> > update_object generic view to allow users to select the Bs associated
> > with A. I've created a class that inherits from forms.ModelForm that
> > defines the form. In that I have forms.ModelMultipleChoiceField() for
> > selecting associated Bs. What I want to do is use the queryset to filter
> > to only show those Bs that share C with this instance of A.
>
> > I am confused as to how to do this type of query while passing a
> > form_class from the update_object generic view.
>
> > I have tried doing this in __init__() but I get a TypeError that the
> > form is not callable when I try to pass arguments.
>
> > Thanks in advance for your help and time,
> > -- Casey

And another one:
http://code-blasphemies.blogspot.com/2009/04/dynamically-created-modelmultiplechoice.html

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

2010-07-28 Thread derek
On Jul 26, 6:52 pm, "Casey S. Greene"  wrote:
> Does anyone have a hint for this (or an idea of where to get started in
> the documentation)?  This seems relatively simple so my best guess is
> that there is something that I am just missing.
>
> Thanks!
> -- Casey
>
> On 07/22/2010 10:16 AM, Casey S. Greene wrote:
>
> > I am trying to figure out a reasonable way to filter using a queryset
> > within a ModelForm.
>
> > In a simple example, I have three models (A, B, and C).
> > C has many A and B
> > A and B have a many to many relationship.
>
> > Assume that some instances of C and instances of B already exist.
>
> > I am using the create_object generic view to allow users to create
> > instances of A but not to select associated Bs. I'm then using
> > update_object generic view to allow users to select the Bs associated
> > with A. I've created a class that inherits from forms.ModelForm that
> > defines the form. In that I have forms.ModelMultipleChoiceField() for
> > selecting associated Bs. What I want to do is use the queryset to filter
> > to only show those Bs that share C with this instance of A.
>
> > I am confused as to how to do this type of query while passing a
> > form_class from the update_object generic view.
>
> > I have tried doing this in __init__() but I get a TypeError that the
> > form is not callable when I try to pass arguments.
>
> > Thanks in advance for your help and time,
> > -- Casey

Well, I have never worked with "object generic view" items before, but
a similar (I think?) question was raised on stackoverflow:
http://stackoverflow.com/questions/738301/how-to-modify-choices-of-modelmultiplechoicefield

Maybe the discussion (and links) there can help as a starting point?

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

2010-07-28 Thread Maksymus007
On Wed, Jul 28, 2010 at 3:29 PM, Massimiliano Ravelli
 wrote:
> On Jul 28, 3:13 pm, knight  wrote:
>> What are the minimal changes that I need to make in order to work with
>> 1.2.1?
>
> Did you have a look at 
> http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
> ?

This link in worth nothing.
The same all the sentences link '1.1 and 1.2 are compatible'.
They are not.

I have quite big application written in 1.1 - still can't fully run it on 1.2.
As I discovered: forms fields set to be blank=True and null=True when
left blank on 1.1 get null value as expected, on 1.2 the get empty
string - which crashes if database has constraints.

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

2010-07-28 Thread Massimiliano Ravelli
On Jul 28, 3:13 pm, knight  wrote:
> What are the minimal changes that I need to make in order to work with
> 1.2.1?

Did you have a look at 
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
?

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



Calculate distance between 2 latitude/longitude Point

2010-07-28 Thread Alexandre González
Hi! I'm using the Django GEOS API [1] in my project to see the distance
between two users.

I get the coordinates from google maps in latitude/longitude mode and I need
to calculate the distance between them. I'm testing with .distance() method
at GEOSGeometry but I receive a strange value.

This is the result of one of my test:

*
In [45]: Point(40.96312364002175,
-5.661885738372803).distance(Point(40.96116097790996, -5.66283792257309))
Out[45]: 0.0021814438604553388

In Google Maps Distance Calculator [2] I can see that the result is: 0.145
miles = 0.233 km = 0.126 nautical miles = 233 meters = 764.436 feet*
*
*
*A friend told me on Google that perhaps I must calculate the distance in
UTMs and the results surely is a lat/long distance. To test it I need pygps
that is a project not maintained to import
LLtoUTMfrom from LatLongUTMconversion*
*
*
*Any idea about this?*
*
*
[1] http://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/
[2]
http://www.daftlogic.com/projects-google-maps-distance-calculator.htm

-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.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-us...@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 INNER JOIN

2010-07-28 Thread kostia
import datetime

from django.db import models

from django.utils.translation import ugettext_lazy as _

from django.contrib.auth.models import User





class Project(models.Model):

author = models.ForeignKey(User, verbose_name=_('Author'),
related_name='projects')

title = models.CharField(_('Title'), max_length=150)

creation_date = models.DateTimeField(_('Creation date'),
default=datetime.datetime.now)

published = models.BooleanField(_('Published'), default=False)


def __unicode__(self):

return '%s' % self.title



class Meta:

verbose_name = _('Project')

verbose_name_plural = _('Projects')



class Favourite(models.Model):

user = models.ForeignKey(User, verbose_name=_('User'),
related_name='favourites')

project = models.ForeignKey(Project, verbose_name=_('Project'),
related_name='favourites')

date = models.DateTimeField(_('Date'),
default=datetime.datetime.now)



def __unicode__(self):

return '%s ("%s")' % (self.user, self.project.title)



class Meta:

verbose_name = _('Favourite')

verbose_name_plural = _('Favourites')

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



moving to django 1.2.1

2010-07-28 Thread knight
Hi,

I have pretty big django app running on django 1.0.2 and I want to
move it to django 1.2.1 since I want to use multiple databases.
What are the minimal changes that I need to make in order to work with
1.2.1?
I mean, what should I do regarding csrf and so on...
Is there a good place to read other than django documentation?

Thanks, Arshavski Alexander.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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:How to post data to the admin form by urllib2 ?

2010-07-28 Thread Benedict Verheyen
On 27/07/2010 17:48, jerry wrote:
> Hi:
>   I build a website and want to login the admin form by python code. I
> have disabled the CSRF in my project  and use urllib2 to post data.
> here are my codes:
> 
> import urllib
> import urllib2
> import cookielib
> 
> cj = cookielib.CookieJar()
> url_login ='http://127.0.0.1:8000/admin/'
> body =
> {'csrfmiddlewaretoken':'f85a33be11bd85108a1030fcce96a5ea','username':'root','password':'mypass','this_is_the_login_form':'1'}
> opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
> opener.addheaders = [('User-agent','Mozilla/4.0 (compatible; MSIE 7.0;
> Windows NT 5.1)')]
> urllib2.install_opener(opener)
> req=urllib2.Request(url_login,urllib.urlencode(body))
> u=urllib2.urlopen(req)
> print u.read()
> print urllib2.urlopen("http://127.0.0.1:8000/admin/sites/
> site/").read()
> 
> 
> but the codes don't seem to work,here is some part of the response
> ---
> 
> Looks like your browser isnt configured to
> accept cookies. Please enable cookies, reload this page, and try
> again.
> 
> 
>  style='display:none'> value='678f0507075332a87211dff43d6f9ee4' />
>   
> Username:  name="username" id="id_username" />
>   
>   
> Password:  name="password" id="id_password" />
> 
>   
>   
> 
>   
> 
> 
> 
> Could anyone give some suggestion?
> 

This is how i login to my site.
If you change the url you can test it from a shell to see if
it works for the admin login.

import urllib2,urllib
o = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
urllib2.install_opener(o)
id='Admin'
pw='xyz'
p=urllib.urlencode({"username" : id, "password" : pw})
f=o.open("http://calltracking:8000/accounts/login/;, p)
data=f.read()
f.close()

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-us...@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: HTTP POST sent from app to Django Server returns 403 Forbidden

2010-07-28 Thread Benedict Verheyen
On 28/07/2010 3:54, Kieran Farr wrote:
> Further research shows that CSRF is enabled regardless of my
> settings.py if we use Django's built-in auth.
> 
> Obviously, we need to still use Django's auth, so we can't just
> disable CSRF site-wide like this hack:
> http://stackoverflow.com/questions/1650941/django-csrf-framework-cannot-be-disabled-and-is-breaking-my-site
> ...or this hack...
> http://djangosnippets.org/snippets/2069/
> 
> Obviously also, we have no control over the third-party server sending
> the POST request, so we can't resort to this hack:
> http://stackoverflow.com/questions/2405353/having-a-postable-api-and-djangos-csrf-middleware
> 
> The decorator @csrf_exempt does not work as described in the docs as
> our view always returns a 403 when any content is POSTed.
> 
> Very confusing!
> 
> Kieran



I'm not entirely sure but i think i've hit the same problem.
I tried to access a view with urllib & urllib that requires a logged
in user with the appropriate rights.
First i need to login in and post the username and password in order to use
a second call to access the protected function.

This is the test code i used to automatically login:
  import urllib2,urllib
  o = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
  urllib2.install_opener(o)
  id='Admin'
  pw='xyz'
  p=urllib.urlencode({"username" : id, "password" : pw})
  f=o.open("http://calltracking:8000/accounts/login/;, p)
  data=f.read()
  f.close()

The login view has the decorator @csrf_exempt and login works fine.
Next, i try the actual view that also has @csrf_exempt specified.

I get this back:

>>> f=o.open("http://calltracking:8000/management/statistics/top/user/yearly/;, 
>>> p)
Traceback (most recent call last):
  File "", line 1, in 
  File "c:\python26\lib\urllib2.py", line 397, in open
response = meth(req, response)
  File "c:\python26\lib\urllib2.py", line 510, in http_response
'http', request, response, code, msg, hdrs)
  File "c:\python26\lib\urllib2.py", line 435, in error
return self._call_chain(*args)
  File "c:\python26\lib\urllib2.py", line 369, in _call_chain
result = func(*args)
  File "c:\python26\lib\urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: FORBIDDEN

I'm not sure how to proceed as it seems that csrf is getting in the way.

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-us...@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 INNER JOIN

2010-07-28 Thread Sævar Öfjörð
It would help if you submitted your models
- Sævar

On Jul 28, 2:29 pm, kostia  wrote:
> I have a model Favourite with fields User, Project, Date, what means
> that some user put some project as favourite on some date. I take all
> favourites filtered by this user and I want to INNER JOIN that info
> with Project model. How can I do that?
>
> Something like projects = Favourite.objects.filter(user =
> request.user).inner_join(Project, project)

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



Simple Admin interface question - change header?

2010-07-28 Thread Derek
I'm sure this is simple... but,  how do I change the header text that
appears at the top of every change list?

i.e. instead of "Select XXX to change", I'd like to have "List of
XXX's" (where XXX's is the plural form of the object name)

Is this in an admin template and, if so, which one?

Thanks
Derek

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

2010-07-28 Thread Michael
On Wed, Jul 28, 2010 at 3:18 AM, shacker  wrote:

> On Jul 27, 2:49 pm, Dennis Kaarsemaker  wrote:
> > Are the tracebacks all the same? Can you share a traceback?
>
> Sure, here's one (search/replaced to make it generic):
>
> http://dpaste.com/222645/
>
> It's happening on various (and unrelated) pages, but the tracebacks
> are all equally uninformative.
>
> Thanks,
> Scot
>
> This is a strange error. Is there any mention in your mysql logs? Also,
have you tried destroying and recreating your database. It is looking like
something is corrupt or not installed properly.

Here is a link to someone else who might have gotten this error in the
past: http://forums.devshed.com/showthread.php?p=1259160#post1259160

Good Luck,

Michael

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

2010-07-28 Thread kostia
I have a model Favourite with fields User, Project, Date, what means
that some user put some project as favourite on some date. I take all
favourites filtered by this user and I want to INNER JOIN that info
with Project model. How can I do that?

Something like projects = Favourite.objects.filter(user =
request.user).inner_join(Project, project)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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:How to post data to the admin form by urllib2 ?

2010-07-28 Thread Rory Hart
On Wed, Jul 28, 2010 at 1:48 AM, jerry  wrote:

> Hi:
>  I build a website and want to login the admin form by python code. I
> have disabled the CSRF in my project  and use urllib2 to post data.
> here are my codes:
>
> 
> import urllib
> import urllib2
> import cookielib
>
> cj = cookielib.CookieJar()
> url_login ='http://127.0.0.1:8000/admin/'
> body =
>
> {'csrfmiddlewaretoken':'f85a33be11bd85108a1030fcce96a5ea','username':'root','password':'mypass','this_is_the_login_form':'1'}
> opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
> opener.addheaders = [('User-agent','Mozilla/4.0 (compatible; MSIE 7.0;
> Windows NT 5.1)')]
> urllib2.install_opener(opener)
> req=urllib2.Request(url_login,urllib.urlencode(body))
> u=urllib2.urlopen(req)
> print u.read()
> print urllib2.urlopen("http://127.0.0.1:8000/admin/sites/
> site/").read()
>
> 
>
> but the codes don't seem to work,here is some part of the response
>
> ---
> 
> Looks like your browser isnt configured to
> accept cookies. Please enable cookies, reload this page, and try
> again.
>
> 
>  style='display:none'> value='678f0507075332a87211dff43d6f9ee4' />
>  
>Username:  name="username" id="id_username" />
>  
>  
>Password:  name="password" id="id_password" />
>
>  
>  
>
>  
> 
> 
>
> Could anyone give some suggestion?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>
Hey Jerry

The issue is in how Django admin tests to see if you accept cookies. Taking
a quick look in django.contrib.admin.view.decorators the decorator
staff_member_required tests to see if the cookie "testcookie=worked" exists.
If you set that cookie your code should work.

Hope that helps.

-- 
Rory Hart
http://roryhart.net

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: implementing next and previous of the object

2010-07-28 Thread Sævar Öfjörð
It's probably best to do this in a custom Manager.
This code is based on this answer: http://markmail.org/message/kwwuskco4gilej2w

You get the idea

class GetPrevNextManager(models.Manager):
def get_next_by_id(self, object):
qs = self.filter(id__gt=object.id)
if qs.count() > 0:
return qs.order_by('id')[0]
# empty queryset
return qs

def get_prev_by_id(self, object):
qs = self.filter(id__lt=object.d)
if qs.count() > 0:
return qs.order_by('-id')[0]
# empty queryset
return qs

More information about managers: 
http://docs.djangoproject.com/en/dev/topics/db/managers/

- Sævar

On Jul 28, 6:41 am, haibin  wrote:
> Hi all,
>
> Need help, advice on how the have a next and previous link on a object
> detail page. For example fomr a object list page a user chose an
> object, and in the object page instead of going back to the list to
> view other object the user just click either next or previous.
>
> Any idea how to implement it?
>
> Thanks,
> James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 storage chinese failed to mysql!!

2010-07-28 Thread pengbo xue
I have checked mysql database, maybe have no issue, but still show the same
error.detail as below:

mysql> SHOW VARIABLES LIKE 'character%';
+--+
-+
| Variable_name| Value
 |
+--+
-+
| character_set_client | utf8
 |
| character_set_connection | utf8
 |
| character_set_database   | utf8
 |
| character_set_filesystem | binary
 |
| character_set_results| utf8
 |
| character_set_server | utf8
 |
| character_set_system | utf8
 |
| character_sets_dir   | C:\Program Files\MySQL\MySQL Server
5.1\share\chars
ets\ |
+--+
-+

2010/7/28 Dennis Kaarsemaker 

>  On wo, 2010-07-28 at 09:11 +0800, pengbo xue wrote:
> > hi all,
> >
> > I can register from my django web page in english,but it can't storage
> > chinese to django mysql database.
> >
> > please give me advice.  thx
>
> Check your table definition to see whether the field you try to store is
> a latin1 or utf8 field. If it is latin1, it will not support chinese
> characters.
>
> --
> Dennis K.
>
> They've gone to plaid!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>


-- 

cowboy

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: HTTP POST sent from app to Django Server returns 403 Forbidden

2010-07-28 Thread David De La Harpe Golden
On 28/07/10 03:45, Kieran Farr wrote:
> Finally figured out what's going on.
> 
> My hypothesis:
> An HTTP request with POST method sent to a Django view wrapped with
> @csrf_exempt will still raise a 403 CSRF error if the wrapped view
> raises an Http404 exception.
> 

Ah, but was your handler404 view csrf_exempt (the default django one
django.views.defaults.page_not_found isn't...) ;-)

http://code.djangoproject.com/browser/django/trunk/django/views/defaults.py#L4

(really, you'd probably better off _returning_ a
django.http.HttpResponseNotFound response than raising a Http404
exception from your exempted view in this case I guess).

IMO there's no reason to leak info even to the extent of "this object
doesn't exist" to scurrilous CSRFers by default.

> Is there a better way to provide debugging information for 403 errors
> raised from the built-in CSRF methods?
> 

Note also that django 1.2.1 allows specification of
settings.CSRF_FAILURE_VIEW.

http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#csrf-failure-view

You could even make that view immediately throw an exception to be
caught by something else ...I think.

There are quirks, or at least things to be aware of, with the order
things happen in django.core.handlers.base.BaseHandler.get_response()
[1]. Note an exception middleware /doesn't catch/ all exceptions,
some "escape" if they happen early, so e.g. it's best to still specify a
custom handler404/handler500 when using an exception middleware, because
they might still get called.

Even then the only way I've found to completely customize the behaviour
when settings.DEBUG is true (because I wanted ajax technical_response
debug pages to be specially formatted compared to standard whole-page
technical_response) is to subclass the Handler (WSGIHandler) to meddle
with get_response.

I hesitate to call the situation a "bug", because it's all stuff you
probably shouldn't be messing with much, making it too easy
to render your server insecure is probably a django non-goal...

[1]
http://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py#L66

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



generate cache by visiting protected links

2010-07-28 Thread Benedict Verheyen
Hi,


i have cache enabled on a few heavy statistical views.
I would like to generate the pages before a user goes to that page and maybe 
even
regenerate the pages every hour to avoid the initial delay.
However, i can't seem to automate the caching as my site's authentication gets 
in the way
of automating this.

I've tried code that i googled that performs a cookie based login
using urllib and urllib2 but that didn't work.

Basically, i would need a view that is started when the server starts and gets 
called
every hour to generate or visit the url of the stats page.
And this would have to be via a logged in user as otherwise access to the stats 
is forbidden.

Any ideas?

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-us...@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: HTTP POST sent from app to Django Server returns 403 Forbidden

2010-07-28 Thread steven314
If it is a CSRF issue, then perhaps using this setting will help you
get to the bottom of what's going on:
http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#rejected-requests

As it says there, a 403 may be due to a lack of the {% csrf_token %}
in the form that is being posted.
Steven.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Can't figure out how to leverage a complex session object in a template?!?

2010-07-28 Thread Daniel Roseman
On Jul 28, 6:24 am, iJames  wrote:
> HI,
>
> I've got a session object which is a dict.  I'm using it to track the
> state of screen elements (an expanding tree).
>
> request.session['mystate'] = {'1':'true', '2','false'}
>
> In my template I'm looping through the branches:
>
> object.id is 1
> object.id is 2
>
> So:
>
> I want to test:
>
> request.session['mystate'][object.id]=='true':
>
> But how can get that multidimensional dynamic ref into a template with
> only dot notation?
>
> I don't see how I can even do it in the view without stuffing the
> information into the model object.
>
> Any ideas?  Thanks much!
>
> James

You need a very simple custom filter.

@register.filter
def get_item(obj, key):
return obj[key]

Now in the template:

{% if request.session.mystate|get_item:object.id %}

--
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-us...@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: MySQL error -1

2010-07-28 Thread shacker
On Jul 27, 2:49 pm, Dennis Kaarsemaker  wrote:
> Are the tracebacks all the same? Can you share a traceback?

Sure, here's one (search/replaced to make it generic):

http://dpaste.com/222645/

It's happening on various (and unrelated) pages, but the tracebacks
are all equally uninformative.

Thanks,
Scot

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



Can't figure out how to leverage a complex session object in a template?!?

2010-07-28 Thread iJames
HI,

I've got a session object which is a dict.  I'm using it to track the
state of screen elements (an expanding tree).

request.session['mystate'] = {'1':'true', '2','false'}

In my template I'm looping through the branches:

object.id is 1
object.id is 2

So:

I want to test:

request.session['mystate'][object.id]=='true':

But how can get that multidimensional dynamic ref into a template with
only dot notation?

I don't see how I can even do it in the view without stuffing the
information into the model object.

Any ideas?  Thanks much!

James

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

2010-07-28 Thread gnarmis

Thanks for that link up there, David, solved my (similar, but not
really similar) problem.
Although this has me concerned about deployment issues...
-gnarmis
On Jun 1, 8:46 am, izi  wrote:
> Hi,
>
> As I said in my previous mail, you should bring this to the django-
> admin-tools mailing list:http://groups.google.com/group/django-admin-tools/
>
> > My guess is documentation is wrong.I think admin_tools media folder
> > should be inside django.contrib.admin.
>
> No, the documentation is ok, please re-read this section 
> carefully:http://packages.python.org/django-admin-tools/0.2.0/configuration.htm...
>
> What you need is to symlink or copy the "admin_tools" media directory
> in your MEDIA_ROOT and setup your MEDIA_URL accordingly.
>
> Regards,
>
> --
> David

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

2010-07-28 Thread gnarmis
nevermind my last mail, solved.

Helpful link: 
http://docs.djangoproject.com/en/1.1/howto/static-files/#howto-static-files

On Jun 1, 8:46 am, izi  wrote:
> Hi,
>
> As I said in my previous mail, you should bring this to the django-
> admin-tools mailing list:http://groups.google.com/group/django-admin-tools/
>
> > My guess is documentation is wrong.I think admin_tools media folder
> > should be inside django.contrib.admin.
>
> No, the documentation is ok, please re-read this section 
> carefully:http://packages.python.org/django-admin-tools/0.2.0/configuration.htm...
>
> What you need is to symlink or copy the "admin_tools" media directory
> in your MEDIA_ROOT and setup your MEDIA_URL accordingly.
>
> Regards,
>
> --
> David

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

2010-07-28 Thread gnarmis
Hi, I had a somewhat similar question. I've followed the setup and
when the dashboard, etc, are uncommented in installedapps, i merely
get a stripped down version of the admin page without the default
styling. Mine is a local development server. The command prompt is
posting this:

[TIMESTAMP] "GET /site_media/admin_tools/css/dashboard.css/ HTTP1.1"
404 2148
[TIMESTAMP] "GET /site_media/admin_tools/css/theming.css/ HTTP1.1" 404
2142
[TIMESTAMP] "GET /site_media/admin_tools/js/utils.js/ HTTP1.1" 404
2130

I guess this means it's 404'ing on the files needed to style the admin
page.
These are some of the settings:
settings.py:
...
MEDIA_ROOT = '/site_media/'
...
ADMIN_TOOLS_MEDIA_URL = '/site_media/'
...
TEMPLATE_CONTEXT_PROCESSORS = (
# default template context processors
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',

# django 1.2 only
'django.contrib.messages.context_processors.messages',

# required by django-admin-tools
'django.core.context_processors.request',
)

INSTALLED_APPS = (
'admin_tools.theming',
#'admin_tools.menu',
'admin_tools.dashboard',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.admindocs',
'gnarmis.blog',
)

...

urls.py:
...
url(r'^admin_tools/', include('admin_tools.urls')),
...
(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/site_media/'}),
...


Any ideas, or links/resources where I can learn more about how
media_root, media_url etc in detail?

Thanks,
-gnarmis
On Jun 1, 8:46 am, izi  wrote:
> Hi,
>
> As I said in my previous mail, you should bring this to the django-
> admin-tools mailing list:http://groups.google.com/group/django-admin-tools/
>
> > My guess is documentation is wrong.I think admin_tools media folder
> > should be inside django.contrib.admin.
>
> No, the documentation is ok, please re-read this section 
> carefully:http://packages.python.org/django-admin-tools/0.2.0/configuration.htm...
>
> What you need is to symlink or copy the "admin_tools" media directory
> in your MEDIA_ROOT and setup your MEDIA_URL accordingly.
>
> Regards,
>
> --
> David

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