"View on Site" for instance with Many-To-Many relation to the Site model

2010-06-29 Thread Sam
Hello,

I'm using a model with a many to many relationship to Site. I noticed
that the redirect from the admin site (the link "View on Site") is to
a domain that is not associated with the current SITE_ID. in other
words I have two sites, "devel.domain.com" and "www.domain.com." When
I select "View on Site" when using the admin on the www.domain.com
site, it sends me to the resource on the devel.domain.com instead.

Inspecting the admin code, I see the url conf for redirects on line
227 in
django/contrib/admin/sites.py

Tracing the code backwards I eventually get to
django.contrib.contenttypes.views.shortcut, the view that performs the
redirect. I see in that view, the model instance we are trying to
"View on Site" is inspected to determine if it has a relation (Many-to-
Many or Many-To-One) to the Site model.

starting on line 32 in django/contrib/contenttypes/views.py we see
this chunk of code dealing with the Many To Many:
*snip*

# First, look for an many-to-many relationship to Site.
for field in opts.many_to_many:
if field.rel.to is Site:
try:
# Caveat: In the case of multiple related Sites, this
just
# selects the *first* one, which is arbitrary.
object_domain = getattr(obj, field.name).all()
[0].domain
except IndexError:
pass
if object_domain is not None:
break

*endsnip*

What this code is doing is attempting to find a domain to concatenate
with the result of `get_absolute_url()`

My question is, why do we a arbitrarily select the first Site instance
in the many to many relationship? Wouldn't it make sense to pick the
Site instance associated with the running SITE_ID? The reason I ask
this is that it is confusing for the admin to redirect away from the
running site, to another site.

I believe this to be a question of correctness. Rather than choosing,
arbitrarily, a random site to redirect to, why not redirect, again
arbitrarily, to the current site? Anyways, I would appreciate any
feedback on this, it has come up and I am at a loss to explain this
behavior in the admin. Am I missing something?

Thanks much,
Sam

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Load Different Views at same 'browser view'

2010-06-29 Thread Venkatraman S
On Wed, Jun 30, 2010 at 6:32 AM, Desproposito  wrote:

> I've been thinking about how to do an application I have in mind, a
> kind of social network, and it's obvious you have to load different
> 'modules' like Friends, Messages, Posts, etc. The problem is that I
> have no idea about how to do it with Django because I have not found
> any function for it, it seems to me like I have to develop views with
> all the information I need instead of saying, well, I need the 'friend
> module' there on the right, the Messages one up there, etc..
>
>
Try the Pinax project. (http://pinaxproject.com/). Probably you can learn
more by customizing the project or going through the code.

-V
http://twitter.com/venkasub

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



Disabling the use of certain template tags

2010-06-29 Thread Tom Eastman

Hey guys,

I'm planning on writing a django app that will serve as a tool for 
writing mail-merge type form letters.  Well, not actually letters, but 
documents which will have variable substitution in them, to either 
rendered either as HTML or LaTeX documents or some other markup language.


Of course, I would love to be able to take advantage of the Django 
template system.  I imagine users being able to create their own 
templates which are then rendered with contexts to produce the output 
documents.


That part is pretty easy -- I've done something similar before, and 
there's also the django-dbtemplates app which appears to do something 
similar.


But I want to ensure that my users can't access anything in the template 
*loader*, to prevent them including system templates or other 
potentially sensitive things into their own templates.


To that end, is there a way I can load and render templates, but disable 
any occurrences of the '{% include %} or {% extends %} tags or things of 
that nature?


Cheers,

Tom

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-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: Load Different Views at same 'browser view'

2010-06-29 Thread Kenneth Gonsalves
On Wednesday 30 June 2010 06:32:03 Desproposito wrote:
> I've been thinking about how to do an application I have in mind, a
> kind of social network, and it's obvious you have to load different
> 'modules' like Friends, Messages, Posts, etc. The problem is that I
> have no idea about how to do it with Django because I have not found
> any function for it, it seems to me like I have to develop views with
> all the information I need instead of saying, well, I need the 'friend
> module' there on the right, the Messages one up there, etc..
> 

check out templatetags - that is one way of implementing this
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

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



Load Different Views at same 'browser view'

2010-06-29 Thread Desproposito
[I'm sorry I posted this question in the Developers Group, it won't
happen again :)]

Hi all,

First of all i'd like to say that I'm new in Python and Django and
maybe my question is stupid, sorry in case it is. Anyway I'm learning
fast I think. I'm boring of working with PHP and Java, and I'm very
excited about Python and Django.

I've been thinking about how to do an application I have in mind, a
kind of social network, and it's obvious you have to load different
'modules' like Friends, Messages, Posts, etc. The problem is that I
have no idea about how to do it with Django because I have not found
any function for it, it seems to me like I have to develop views with
all the information I need instead of saying, well, I need the 'friend
module' there on the right, the Messages one up there, etc..

I have thought different ways of getting this but I prefer not to tell
yet because it's better not to appear an idiot in my first post in
this group :P

I suppose, in fact I'm almost sure, there is a way to do this, but I
don't know it and I can't find the way.

Sorry I'm spanish and don't know if explained well, but if I did,
could you please help me?

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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-Admin - radio_fields with add/change pages, but not list_display page?

2010-06-29 Thread Victor Hooi
Hi,

I have a Django application with an "Article" model. I'm using the
radio_fields in django-admin with two of the ForeignKey fields that
are linked to Article.

Currently the related tables have five and twenty entries each, so
this UI works quite well on the Add/Change pages.

However, I'm also using list_display with this model - and in the
list_display, it also displays radio boxes, which look quite ugly -
the HTML select box worked much better on list_display. In fact, I
can't really think of many cases, unless the number of possible
entries was quite small, where a radio_box would work well with
list_display.

Anyhow, is there any way to use radio_fields on the Add/Change field,
but not with the list_display page?

Cheers,
Victor

-- 
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: /i18n/setlang/ broken?

2010-06-29 Thread tsmets
To make your code more portable, I would suggest to have settings.py
file as follow : see below.
It is still unclear to me what needs to be done to catch up the
language in my profile.
Another issue I have is that all the languages are shown ...
How to limit the number of languages to a sub-set (in my case :
English / French / German / Dutch / Spanish (Catalan)).

\T,



ps : No way to add this to the group post through the interface...
hence my mail directly to you (+ a cc to django-us...@googlegroup).




On Apr 8, 12:51 pm, chr  wrote:
> btw, here's the minimal-app:http://github.com/statesofpop/i18ntest

***
# Django settings for i18ntest project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@domain.com'),
)


import os

BASE = os.path.dirname(os.path.abspath('.'))
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))


MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'i18ntest',  # Or path to database
file if using sqlite3.
'USER': '',  # Not used with sqlite3.
'PASSWORD': '',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for
default. Not used with sqlite3.
}
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'de'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com;, "http://example.com/media/;
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/;, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '^(fw6#nt7852dz830#2=5-eu3*...@k3bt3d1rc8d(8oobp75d'

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
#'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
#'django.contrib.auth.middleware.AuthenticationMiddleware',
#'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'i18ntest.urls'

TEMPLATE_DIRS = (
PROJECT_DIR + '/templates',
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
)



import logging
import logging.config
logging.config.fileConfig("logging.conf")

import sys, os

BASE = os.path.dirname(os.path.abspath('.'))
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
PRJ_NAME = 'i18ntest'

logger = logging.getLogger('settings')
logger.debug('Test debug message')
if (DEBUG):

  border=1


  logger.debug( "Base : %s" % BASE)
  logger.debug( "Project name : %s" % PRJ_NAME)
  logger.debug( "Root directory : %s" % PROJECT_DIR)
  logger.debug( "DB-file : %s" %  PROJECT_DIR + '/db/' + PRJ_NAME +
'.dbf')
#  logger.debug( "Template dirs : %s" %  show_tuple(TEMPLATE_DIRS,
SECRET_KEY))
#  logger.debug( "Modules are : %s" %  show_tuple(INSTALLED_APPS,
'django'))

  logger.debug( "__name__ =%s" %  __name__)
  logger.debug( "__file__ =%s" %  __file__)
#  logger.debug( "DEFAULT_FROM_EMAIL 

Re: Admin with only inlines, no fields

2010-06-29 Thread felix

well yes, its adding all the fields in again.   the errors thrown are
about missing required fields.

obviously this isn't a good approach since I'm not really editing the
model object, I'm just trying to fool the admin into letting me use
the inlines interface.

so I've opted to avoid using the admin in this case

and in any case I have bug issues with the inlines throwing errors
("management form has been tampered with")



On Jun 29, 5:49 pm, Vinicius Mendes  wrote:
> Try to debug this using PDB. You can insert some breakpoints where the form
> is not validated and see what are the errors.
>
> Atenciosamente,
> Vinicius Mendes
> Solucione Sistemas
> vinic...@solucione.info
>
>
>
> On Tue, Jun 29, 2010 at 12:14 PM, felix  wrote:
>
> > I need to present an admin form that has no fields from the model and
> > only offers admin inlines.
>
> > class AptTranslationForm(DefaultModelForm):
>
> >    class Meta:
> >        model = AptTranslation
>
> > class AptTranslationsAdmin(models.Admin):
>
> >    inlines = [AptTranslation_Inline,]
>
> >    fields = []
>
> > the empty fields list is ignored and the admin delivers all fields
> > from the model
>
> > class AptTranslationsAdmin(models.Admin):
>
> >    inlines = [AptTranslation_Inline,]
>
> >    fieldsets = []
>
> > same thing, all fields are shown
>
> > class AptTranslationsAdmin(models.Admin):
>
> >    inlines = [AptTranslation_Inline,]
>
> >    fieldsets = ( ("",{'fields':[]}), )
>
> > this displays as wished (with a barely visible grouping at the top),
> > but always returns an error on save:
>
> > Please correct the errors below.
>
> > but no errors are listed.
>
> > class AptTranslationsAdmin(models.Admin):
>
> >    inlines = [AptTranslation_Inline,]
>
> >    fields = ['headline']
> >    readonly_fields = ['headline']
>
> > same as above: Please correct the errors below,
> > but no errors are shown
>
> > I also tried using a dummy form class, but an empty field list is not
> > respected there either
>
> > thanks for any 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 > groups.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: Proper approach to updating model object with 100 attributes.

2010-06-29 Thread Lora

On 6/29/10 4:20 PM, Ray Cote wrote:

Hi Tim:

Thanks for the pointers.
I think the setattr is probably safest way to deal with the Django models.

--Ray

- Original Message -
From: "Tim Chase"
To: django-users@googlegroups.com
Cc: "Ray Cote"
Sent: Tuesday, June 29, 2010 2:03:05 PM GMT -05:00 US/Canada Eastern
Subject: Re: Proper approach to updating model object with 100 attributes.

On 06/29/2010 12:01 PM, Ray Cote wrote:
   

Hi List:

I have a Django model with over 100 fields in it that is loaded from a data 
feed.
Each row in the model has a unique field, let's call it item_id.
When loading new data, I'm first checking to see if item_id is in the table,
if it is, I want to update it with the new data from the new 100 fields.

To date, I've done things like:

obj = Model.objects.get(item_id = item_id_from_field)

and then.
obj.field1 = new_field1
etc.

However, for 100 fields, I'd like to find something a bit cleaner than listing 
100 fieldnames.
The data for the new 100 fields is in a nice dictionary.

When I create a new item, I'm able to do this:
obj = MyModel(**dictionary_of_field_values)

Is there something similar I can do with my obj once the data is retrieved?
 

Well, you could do something like

for name, value in dictionary_of_field_values.items():
  setattr(obj, name, value)

or possibly even just

obj.__dict__.update(dictionary_of_field_values)

(I'm not sure how this interacts with Django's meta-class
yumminess, but it works for regular Python classes)

-tkc




   
Perhaps you could use  django.forms.models.model_to_dict() method?  that 
is if you have existing object already and you need to retrieve  it's 
attributes into a nice dict.
PS. If I misunderstood your question, disregard everything i wrote and 
do accept my apologies :)



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



ManyToMany container with templating

2010-06-29 Thread Rishtastic
Hi all,

I'm trying to do

foo is a User auth object
comments.readers is a ManyToMany field that links back to the User

I can iterate just fine by using
{% for foo in comments.readers.all %}

{% endfor %}


But I want to do this:

{% if foo in comments.readers.all %}
do stuff here
{% endif %}


is this possible?

-- 
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: Proper approach to updating model object with 100 attributes.

2010-06-29 Thread Ray Cote
Hi Tim: 

Thanks for the pointers. 
I think the setattr is probably safest way to deal with the Django models. 

--Ray

- Original Message -
From: "Tim Chase" 
To: django-users@googlegroups.com
Cc: "Ray Cote" 
Sent: Tuesday, June 29, 2010 2:03:05 PM GMT -05:00 US/Canada Eastern
Subject: Re: Proper approach to updating model object with 100 attributes.

On 06/29/2010 12:01 PM, Ray Cote wrote:
> Hi List:
>
> I have a Django model with over 100 fields in it that is loaded from a data 
> feed.
> Each row in the model has a unique field, let's call it item_id.
> When loading new data, I'm first checking to see if item_id is in the table,
> if it is, I want to update it with the new data from the new 100 fields.
>
> To date, I've done things like:
>
> obj = Model.objects.get(item_id = item_id_from_field)
>
> and then.
> obj.field1 = new_field1
> etc.
>
> However, for 100 fields, I'd like to find something a bit cleaner than 
> listing 100 fieldnames.
> The data for the new 100 fields is in a nice dictionary.
>
> When I create a new item, I'm able to do this:
>obj = MyModel(**dictionary_of_field_values)
>
> Is there something similar I can do with my obj once the data is retrieved?

Well, you could do something like

   for name, value in dictionary_of_field_values.items():
 setattr(obj, name, value)

or possibly even just

   obj.__dict__.update(dictionary_of_field_values)

(I'm not sure how this interacts with Django's meta-class 
yumminess, but it works for regular Python classes)

-tkc




-- 
Ray Cote, President
Appropriate Solutions, Inc.
We Build Software
603.924.6079

-- 
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: Signal emitted after successful login?

2010-06-29 Thread Daniel Hilton
On 29 June 2010 20:07, Andy McKay  wrote:
> On 2010-06-29, at 10:48 AM, tiemonster wrote:
>
>> Is a signal emitted after a successful login? I need to hook a
>> particular piece of code into that point in the application.
>
One easy way is to wrap the login view function and execute your code
once a user has successfully been authorised. If you look at the
account app included in
Pinax, there is an example of how this could work.

HTH,
Dan


>
> Not specifically, if you are using django.contrib.auth last_login is set by 
> some scripts, eg the login django.contrib.auth.login. So you can listen to 
> the save signals on that model.
> --
>  Andy McKay, @andymckay
>  Django Consulting, Training and Support
>
> --
> 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: Signal emitted after successful login?

2010-06-29 Thread Andy McKay
On 2010-06-29, at 10:48 AM, tiemonster wrote:

> Is a signal emitted after a successful login? I need to hook a
> particular piece of code into that point in the application.


Not specifically, if you are using django.contrib.auth last_login is set by 
some scripts, eg the login django.contrib.auth.login. So you can listen to the 
save signals on that model.
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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: How can I access attributes in intermediate class

2010-06-29 Thread Alexandre González
I was intrigued so I did it, I get this solution:

from models import User, Group, Membership

def example(request):
example_group_id = 1 #I create only one group to test, this is his id

group = Group.objects.get(pk=example_group_id)
for user in group.members.iterator(): #Get all user in the group
throught the membership
membership = Membership.objects.get(person=user, group=group) #Get
the membership object using the user and the group as keys
membership.date_joined # Now you can read your date_joined

Perhaps it isn't the best way to do it, but it works :p

I hope this helps you,
Álex González

On Tue, Jun 29, 2010 at 19:45, cat in a tub  wrote:

> class User(models.Model):
>name = models.CharField(max_length=128)
>
> class Group(models.Model):
>name = models.CharField(max_length=128)
>members = models.ManyToManyField(User, through='Membership')
>
> class Membership(models.Model):
>person = models.ForeignKey(User)
>group = models.ForeignKey(Group)
>date_joined = models.DateField()
>
>
> What if I want to access Membership.data_joined in Group class?
>
> 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.
>
>


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



Efficient reverse ForeignKey/ManyToMany data field access

2010-06-29 Thread chadc
Hi there,

I am trying to customize the django changelist and I have been having
trouble displaying data across reverse ForeignKey relationships.
Despite searching at length I have been unable to find a better method
to display this data than using _set.all(). My issue with this
solution is that it requires O(n) database queries. Is there any way
to access the data more efficiently?

Example:

Host
name = CharField
Account
name = CharField
host = ForeignKey(Host, related_name='accounts')

What I want to do is list the associated account names for every host
on the changelist. The problem with adding

def get_accounts(self, host):
return host.accounts.all()

to the list_display of the host admin model is that it will then hit
the database O(n) times where n is the number of rows in the list.

My first solution was performing a raw query with ' ...
GROUP_CONCAT(account.id) ... ORDER BY host.id' and then matching the
account id against a cache of account id -> account name. I have since
refined this by creating a custom aggregate to perform the aggregate.
Once the data has been found it, again, uses a cache of account id ->
account name.

So, my questions are as follows:

1. How should I be going about this?
2. Is support for this type of function ever going to be build into
django? (I have noticed that the docs state that doing this  from
list_display in admin would require O(n) database queries, and no
mention is made of methods other than _set.all() to retrieve the data,
at least that I was able to find).

Thanks,

Chad




PS: In case anyone else runs into the same problem in the future, here
is the code that I am currently using:

~~~aggregates.py~~~
from django.db.models import Aggregate
from django.db.models.sql.aggregates import Aggregate as SQLAggregate,
AggregateField as SQLAggregateField

string_aggregate_field = SQLAggregateField('TextField')

class GroupConcat(Aggregate):
name = 'GroupConcat'

def add_to_query(self, query, alias, col, source, is_summary):
# Manually override the aggregate class
klass = SQLGroupConcat # getattr(query.aggregates_module,
self.name)
aggregate = klass(col, source=source, is_summary=is_summary,
**self.extra)
query.aggregates[alias] = aggregate

class SQLGroupConcat(SQLAggregate):
sql_function = 'GROUP_CONCAT'

def __init__(self, col, **extra):
super(SQLGroupConcat, self).__init__(col, **extra)
tmp = string_aggregate_field
self.field = tmp

~~~admin.py
...
from aggregates import GroupConcat
...
class HostAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'account_names')
def queryset(self, request):
self.account_cache = {}
return super(HostAdmin,
self).queryset(request).annote(GroupConcat('accounts'))
def account_names(self, host):
# Cache the related objects to avoid O(n) queries
if not self.account_cache:
queryset = Account.objects.all()
for obj in queryset:
self.account_cache[obj.id] = obj.name
# Parse the account list and output formatted links
accounts = host.accounts__groupconcat
if not accounts:
return 'none'
accounts = accounts.split(',')
result = ''
num_accounts = len(accounts)
for i in range(0, num_accounts):
account = int(accounts[i])
name = self.account_cache[account]
url =
urlresolvers.reverse('admin:accounts_account_change', args=(account,))
result += '%s' % (url, name)
if i < num_accounts:
result += ''
return result
account_names.allow_tags = True

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: How does buildout determine paths needed? (for django-page-cms)

2010-06-29 Thread John Griessen

Bill Freeman wrote:

Not buildout specific, but, if I recall correctly, the pages egg
(among others) is not
built in such a way that the media files get included (in setup.py the
function that
goes and discovers the .py files to install only does .py files, other
files must be
added more painfully, and a lot of package maintainers don't do it, and may not
know, because they typically do a VCS checkout or install from a tar,
rather than
from the egg).  Last time I installed pages, after using pip install,
I had to get the
tar and unpack it to get the media files.  I don't recall if that
involved templates, or
just css, images, and js, but I wouldn't be surprised.  The pages templates are
examples, IIRC, and you make your own to stick in
project_root/templates/pages/ .


Hmmm  the developer of django-page-cms does not use buildout, so I tried
a buildout with django-page-cms as source and it behaved differently.
I still needed project_root/media/ and subdirs, but it started finding
templates.

Thanks for the hints.

John

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-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: Proper approach to updating model object with 100 attributes.

2010-06-29 Thread Tim Chase

On 06/29/2010 12:01 PM, Ray Cote wrote:

Hi List:

I have a Django model with over 100 fields in it that is loaded from a data 
feed.
Each row in the model has a unique field, let's call it item_id.
When loading new data, I'm first checking to see if item_id is in the table,
if it is, I want to update it with the new data from the new 100 fields.

To date, I've done things like:

obj = Model.objects.get(item_id = item_id_from_field)

and then.
obj.field1 = new_field1
etc.

However, for 100 fields, I'd like to find something a bit cleaner than listing 
100 fieldnames.
The data for the new 100 fields is in a nice dictionary.

When I create a new item, I'm able to do this:
   obj = MyModel(**dictionary_of_field_values)

Is there something similar I can do with my obj once the data is retrieved?


Well, you could do something like

  for name, value in dictionary_of_field_values.items():
setattr(obj, name, value)

or possibly even just

  obj.__dict__.update(dictionary_of_field_values)

(I'm not sure how this interacts with Django's meta-class 
yumminess, but it works for regular Python classes)


-tkc



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



Signal emitted after successful login?

2010-06-29 Thread tiemonster
Is a signal emitted after a successful login? I need to hook a
particular piece of code into that point in the application.

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



Admin.py: Creating double ended ManyToMany relationship

2010-06-29 Thread glacasse

Hi everyone, considering these two classes.

class Foo(models.Model):
bar = models.ManyToManyField(Bar, blank=True, null=True, default=None)

class Bar(models.Model):
pass

I have a many to many relationship in my admin page so I can select multiple
Bar objects on Foo, which is good, but I would also like to select multiple
Foo objects from Bar in the admin page. Is that possible? How can I do that?

Thank you!
-- 
View this message in context: 
http://old.nabble.com/Admin.py%3A-Creating-double-ended-ManyToMany-relationship-tp29024100p29024100.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: More than one primary key for a model

2010-06-29 Thread ringemup
No, it doesn't use unique_together to do the joins, but
unique_together will enforce the uniqueness constraint of the compound
key, and allow you to do a lookup of an object based on the compound
key.

As Bruno explained, you'll have to use for surrogate primary keys the
auto-generated integer primary keys that Django creates if you don't
declare a primary key for the model, and let Django do its joins on
that.  The only other option (i.e. if you're working with a database
that already exists and you can't change) would be to do all your
queries in raw SQL and write the joins yourself.

On Jun 28, 1:27 pm, thusjanthan  wrote:
> Yes you are correct I am looking to implement the compounded primary
> keys. Well the problem is I would like to have a many to many(m2m)
> with two models that share a compounded primary key. However when I do
> the m2m join it randomly pics one of the compounded keys and tries to
> join them? :| Does the unique_together parameter fix that problem? as
> in does it use the unique_together to do the joins?
>
> On Jun 28, 10:20 am, ringemup  wrote:
>
> > By definition a database table can have only one primary key.  I
> > believe what you're looking to implement are compound primary keys.
> > Depending on the database backend you're using, the unique_together
> > Meta attribute may accomplish most of what you're looking to do.
>
> > On Jun 28, 12:49 pm, thusjanthan  wrote:
>
> > > Can anyone tell me why django refuses to follow the rules and lesson
> > > we learn in our database courses?
>
> > > I have a table that I do not have control over. Suppose its called the
> > > phone table and it contains the number and the username as the primary
> > > key. But for some reason when I have more than one primary key in
> > > django it complains. Especially when I run the test suite it just
> > > craps out saying more than one primary key detected for a model. Does
> > > django really expect all tables to only contain one primary key? How
> > > can I override this feature and have it take more than one primary key
> > > without using things suggested by django about the unique attr in the
> > > meta info of the model.
>
> > > Thanks.
> > > Nathan.
>
>

-- 
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 can I access attributes in intermediate class

2010-06-29 Thread cat in a tub
class User(models.Model):
name = models.CharField(max_length=128)

class Group(models.Model):
name = models.CharField(max_length=128)
members = models.ManyToManyField(User, through='Membership')

class Membership(models.Model):
person = models.ForeignKey(User)
group = models.ForeignKey(Group)
date_joined = models.DateField()


What if I want to access Membership.data_joined in Group class?

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: change displayed name of users object

2010-06-29 Thread Jacob Fenwick
Thanks for the link Derek.

I don't think it quite does what I want.

I guess I should have been more specific.

I want to change how the Users object is displayed in the Django admin.

This is a one line change in the Django code, but I would rather not change
Django if I can avoid it.

Is there a way to do something like subclassing the Django Users object and
use that for authentication instead of the original Users object?

Jacob

On Tue, Jun 29, 2010 at 10:01 AM, derek  wrote:

> On Jun 28, 7:54 pm, Jacob Fenwick  wrote:
> > Is there a simple way to change the displayed name of the users object in
> > the auth package?
> >
> > I don't care about what it's called under the hood. I just want to change
> > what the user sees.
> >
> > I'd like to avoid changing the code directly in the Django library as
> that
> > will make upgrades difficult.
> >
> > I came across this article but it's quite old and I'm hoping there's a
> > better way:
> >
> > http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m...
> >
> > Jacob
>
> Have a look at:
>
> http://bradmontgomery.blogspot.com/2010/04/pretty-options-for-djangos-authuser.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.
>
>

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



Proper approach to updating model object with 100 attributes.

2010-06-29 Thread Ray Cote
Hi List:

I have a Django model with over 100 fields in it that is loaded from a data 
feed. 
Each row in the model has a unique field, let's call it item_id.
When loading new data, I'm first checking to see if item_id is in the table, 
if it is, I want to update it with the new data from the new 100 fields. 

To date, I've done things like:

obj = Model.objects.get(item_id = item_id_from_field)

and then.
obj.field1 = new_field1
etc. 

However, for 100 fields, I'd like to find something a bit cleaner than listing 
100 fieldnames. 
The data for the new 100 fields is in a nice dictionary. 

When I create a new item, I'm able to do this:
  obj = MyModel(**dictionary_of_field_values)

Is there something similar I can do with my obj once the data is retrieved? 

Thanks
--Ray

-- 
Ray Cote, President
Appropriate Solutions, Inc.
We Build Software
603.924.6079

-- 
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: Admin Search Engline

2010-06-29 Thread euan.godd...@googlemail.com
Erm. I'm not sure as I've never done it. Have a read of the source for
contrib.admin. If you can't find what you're looking for let me know.

Euan

On Jun 28, 10:41 am, Massimiliano della Rovere
 wrote:
> Yes that's my idea.
> Can you tell me which class/method in the admin files is responsible
> for the search engine so that I can extend it?
>
> On Mon, Jun 28, 2010 at 10:27, euan.godd...@googlemail.com
>
>  wrote:
> > I think that would be quite an undertaking as you would need to write
> > an expression parser and monkey around with the search code in admin.
>
> > If you succeed, I'd be interested to see the result.
>
> > Euan
>
> > On Jun 28, 8:36 am, Massimiliano della Rovere
> >  wrote:
> >> I'd like to modify the default search engine in the django admin
> >> interface so that is can search metadata too like values depending on
> >> sql COUNT() using google style prefixes in these cases.
> >> Can somebody help me telling which class/method in the admin files is
> >> responsible for the search engine so that I can extend it?
>
> >> thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: None field : Admin save setting it to empty value instead of NULL during save

2010-06-29 Thread euan.godd...@googlemail.com
Django admin can't differentiate between empty string and None and
picks empty string which makes sense in most cases.

If you don't like the idea of empty string override the save method
and coerce empty string to None before calling the super classes save,
e.g.

class YourModel(models.Model):
...

   def save(self, *args, **kwargs):
if self.naughty_field == '':
self.naughty_field = None
super(YourModel, self).save(*args, **kwargs)

Euan

On Jun 29, 4:15 pm, rahul jain  wrote:
> Hi there !
>
> One of my model fields attribute is set to null="true" to allow None
> values. But if I use admin to save those model objects and leave it
> blank, it saves blank value instead of None.
> How to fix this ?
>
> And Blank value is not None. Blank is "" (empty) but None is NULL in 
> databases.
>
> -RJ

-- 
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: Admin with only inlines, no fields

2010-06-29 Thread Vinicius Mendes
Try to debug this using PDB. You can insert some breakpoints where the form
is not validated and see what are the errors.

Atenciosamente,
Vinicius Mendes
Solucione Sistemas
vinic...@solucione.info


On Tue, Jun 29, 2010 at 12:14 PM, felix  wrote:

>
> I need to present an admin form that has no fields from the model and
> only offers admin inlines.
>
>
> class AptTranslationForm(DefaultModelForm):
>
>class Meta:
>model = AptTranslation
>
> class AptTranslationsAdmin(models.Admin):
>
>inlines = [AptTranslation_Inline,]
>
>fields = []
>
>
> the empty fields list is ignored and the admin delivers all fields
> from the model
>
>
> class AptTranslationsAdmin(models.Admin):
>
>inlines = [AptTranslation_Inline,]
>
>fieldsets = []
>
>
> same thing, all fields are shown
>
>
> class AptTranslationsAdmin(models.Admin):
>
>inlines = [AptTranslation_Inline,]
>
>fieldsets = ( ("",{'fields':[]}), )
>
>
> this displays as wished (with a barely visible grouping at the top),
> but always returns an error on save:
>
> Please correct the errors below.
>
> but no errors are listed.
>
>
> class AptTranslationsAdmin(models.Admin):
>
>inlines = [AptTranslation_Inline,]
>
>fields = ['headline']
>readonly_fields = ['headline']
>
> same as above: Please correct the errors below,
> but no errors are shown
>
>
> I also tried using a dummy form class, but an empty field list is not
> respected there either
>
> thanks for any 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.
>
>

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



None field : Admin save setting it to empty value instead of NULL during save

2010-06-29 Thread rahul jain
Hi there !

One of my model fields attribute is set to null="true" to allow None
values. But if I use admin to save those model objects and leave it
blank, it saves blank value instead of None.
How to fix this ?

And Blank value is not None. Blank is "" (empty) but None is NULL in databases.

-RJ

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



Admin with only inlines, no fields

2010-06-29 Thread felix

I need to present an admin form that has no fields from the model and
only offers admin inlines.


class AptTranslationForm(DefaultModelForm):

class Meta:
model = AptTranslation

class AptTranslationsAdmin(models.Admin):

inlines = [AptTranslation_Inline,]

fields = []


the empty fields list is ignored and the admin delivers all fields
from the model


class AptTranslationsAdmin(models.Admin):

inlines = [AptTranslation_Inline,]

fieldsets = []


same thing, all fields are shown


class AptTranslationsAdmin(models.Admin):

inlines = [AptTranslation_Inline,]

fieldsets = ( ("",{'fields':[]}), )


this displays as wished (with a barely visible grouping at the top),
but always returns an error on save:

Please correct the errors below.

but no errors are listed.


class AptTranslationsAdmin(models.Admin):

inlines = [AptTranslation_Inline,]

fields = ['headline']
readonly_fields = ['headline']

same as above: Please correct the errors below,
but no errors are shown


I also tried using a dummy form class, but an empty field list is not
respected there either

thanks for any 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: Creating and binding more than one model to a from

2010-06-29 Thread Daniel Roseman
On Jun 28, 5:47 pm, thusjanthan  wrote:
> Hi,
>
> I have a Topic class I would like to create a form based on. BUT, I
> want many of these objects so Topics. How do I obtain such a feature.
>
> Suppose my form object is as follows:
>
> class TopicForms(ModelForm):
>     class meta:
>         model = Topic
>         fields = ('topic_id','topic')
>
> I want to display more than one of the topics that is associated to a
> particular object. Suppose its a topic about obama and there are 10
> topics. I want to display all 10 of these. and If they make a change
> to one of them I would like to save that change on submission. I would
> also like to provide additional blank topic fields for end users to
> enter new topics about obama. Any help would be appreciated. I am a
> little confused on the forms area of django.
>
> Nathan.

You need formsets. A general introduction is here:
http://docs.djangoproject.com/en/1.2/topics/forms/formsets/
and a guide to building formsets based on models is here:
http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#id1
--
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: How To Create POST data without an actual POST?

2010-06-29 Thread Margie Roginski
Hi everyone,

Thanks for your responses.  After some research on this, it looks like
urllib2 is the way to go.  With this I can write a python program that
runs on any of our linux machines, and can do a GET to get info that
is similar to what the user sees in the forms (ie, defaults for
various fields).  Then it will fill in the data supplied by the user,
then POST it back.   This allows me to get all the same defaults that
people see in their forms, and also leverage all of the form
validation.  So I think this will work well, thanks for all the input!

Margie


On Jun 28, 1:22 pm, Margie Roginski  wrote:
> I'd like to find a way to let my users submit form data without
> submitting
> it via an actual web form. For example, I have users that would like
> to
> send their data via email, or perhaps provide it in an excel spread
> sheet,
>
> I'm trying to figure out how to do this and still leverage all the
> error
> checking associated with my forms (ie, via is_valid).
>
> I'm thinking that on the server side I could create a form with
> initial data,
> and then instead of rendering that form, I'd like to just convert it
> directly
> to a POST data dict, as if the user submitted the form without making
> any changes. Then I'd take that POST data, add a bit of additinal
> data
> that I've gotten from some other source (ie from email or excel), then
> run
> is_valid(), then do my standard save to my db object.
>
> Can anyone comment on if this seems like a good approach for doing
> this,
> and if so, if there is any django support for turning a form directly
> into a data dict?
>
> Thanks!
> Margie

-- 
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: Creating and binding more than one model to a from

2010-06-29 Thread derek
On Jun 28, 6:47 pm, thusjanthan  wrote:
> Hi,
>
> I have a Topic class I would like to create a form based on. BUT, I
> want many of these objects so Topics. How do I obtain such a feature.
>
> Suppose my form object is as follows:
>
> class TopicForms(ModelForm):
>     class meta:
>         model = Topic
>         fields = ('topic_id','topic')
>
> I want to display more than one of the topics that is associated to a
> particular object. Suppose its a topic about obama and there are 10
> topics. I want to display all 10 of these. and If they make a change
> to one of them I would like to save that change on submission. I would
> also like to provide additional blank topic fields for end users to
> enter new topics about obama. Any help would be appreciated. I am a
> little confused on the forms area of django.
>
> Nathan.

Sounds a lot like "tagging".  Have a look at this:
http://showmedo.com/videotutorials/video?name=1100020=110

Even if its not exactly what you want, it may give you some ideas...

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

2010-06-29 Thread Alex Robbins
Eduan,

This might be a little technical for a beginner, but you'll have to
learn sometime :)

Python looks for modules according to the python path. If your module
isn't available on the path, then you'll get an error like you are
seeing. I believe that manage.py adds the directory it is in to the
python path. However, it is looking inside the mysite folder for a
module called mysite, with a folder inside it called polls. (mysite/
mysite/polls). You either need to add the folder above the manage.py
file to the python path or rename the installed app to just "polls".

You can see your python path from the shell by typing:
import sys
print sys.path

Also, make sure anything that python should be looking at has an
__init__.py file in it. The __init__.py file is what makes a directory
a python module. Without that __init__.py file python will mostly
ignore it.

Hope that helps!
Alex

On Jun 29, 7:00 am, Eduan  wrote:
> Okay thanks that you all are so helpful.
> I went through the whole tutorial allot of times and can't even
> complete part 1.
> I thought that it was my setup that i was using.
> I am using Windows 7 and Eclipse SDK Version: 3.5.2 for my programming
> environment. I am using a MySQL 5.5 database.
>
> It all goes fluently till I get to the part where you add
> 'mysite.polls' under installed apps.
> After adding that in there I can't run any command(like
> syncdb,runserver) without getting back an error stating:
> Error: No module named mysite.polls.
> I tried renaming it and I still get that error.
>
> I have downloaded an full Django app called friends here 
> :http://github.com/jtauber/django-friends/
> If I syncdb or runserver I get the similar error:
> Error: No module named friends
>
> Now please any help. This could be a simple beginners mistake that I
> am making. Thanks allot
> Eduan

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



Admin.py: Creating double ended ManyToMany relationship

2010-06-29 Thread glacasse
Hi everyone, considering these two classes.

class Foo(models.Model):
bar = models.ManyToManyField(Bar, blank=True, null=True,
default=None)

class Bar(models.Model):
pass

I have a many to many relationship in my admin page so I can select
multiple Bar objects on Foo, which is good, but I would also like to
select multiple Foo objects from Bar in the admin page. Is that
possible? How can I do that?

Thank you!

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

2010-06-29 Thread Alex Robbins
You can also use ./manage.py validate to get django to check over your
models. Sometimes syncdb or others will fail because of a model
validation issue.

Alex

On Jun 28, 3:20 pm, Jonathan Hayward
 wrote:
> P.S. This problem did not resurface after I made other changes discussed
> elsewhere in the thread; it seems to be secondary damage.
>
> On Mon, Jun 28, 2010 at 2:46 PM, Jonathan Hayward <
>
>
>
> christos.jonathan.hayw...@gmail.com> wrote:
> > Thanks for pointing me to South. I've glanced over it, but I did have one
> > question:
>
> > My understanding is that Django will introduce tables for models that have
> > been added on a syncdb, but not alter tables for models that have been
> > changed. And from a glance at the documentation, it looks like South would
> > provide more granularity.
>
> > However, it is my understanding that this should have the consequence that
> > if you start with a fresh database and run syncdb, then that should result
> > in appropriate tables. This might not be a first choice way to update the
> > database as normally wiping the database when you implement a schema update
> > is not desirable if you have any real data, but my understanding from the
> > documentation is that this forceful solution should work. If I'm mistaken,
> > I'd like to know both how I presently misunderstand, and what an appropriate
> > way is to generate a fresh database with tables matching your models.
>
> > On Fri, Jun 25, 2010 at 5:25 PM, Mark Linsey  wrote:
>
> >> I don't quite understand what changes you made before producing this
> >> error, and I'm totally unfamiliar with sqllite.
>
> >> But I do know that for many (really, most) different model changes, just
> >> running syncdb will not make the appropriate changes to your tables.  You
> >> probably need to look into south migrations.
>
> >> On Fri, Jun 25, 2010 at 2:09 PM, Jonathan Hayward <
> >> christos.jonathan.hayw...@gmail.com> wrote:
>
> >>> P.S. Renaming the (SQLite) database file and running syncdb again
> >>> produces (basically) the same behavior. I had to do some initialization
> >>> things again, but outside of that I got equivalent behavior to what I 
> >>> pasted
> >>> below.
>
> >>> What I am trying to do is create a few instances of the Entity model
> >>> defined in my [directory/]models.py. So far I have managed to get them to
> >>> show up as an option to manage in the admin interface, but not yet to save
> >>> one.
>
> >>> Should it be looking for directory_models_entity instead of
> >>> directory_entity? "entity" seems not to be populated; from the command 
> >>> line
> >>> sqlite3:
>
> >>> sqlite> .tables
> >>> auth_group                  auth_user_user_permissions
> >>> auth_group_permissions      django_admin_log
> >>> auth_message                django_content_type
> >>> auth_permission             django_session
> >>> auth_user                   django_site
> >>> auth_user_groups
>
> >>> On Fri, Jun 25, 2010 at 3:00 PM, Jonathan Hayward <
> >>> christos.jonathan.hayw...@gmail.com> wrote:
>
>  I received the error below from the admin interface; I thought it was
>  because I needed to run a syncdb, but stopping the server, running a 
>  syncdb,
>  and restarting has generated the same error:
>
>  OperationalError at /admin/directory/entity/
>
>  no such table: directory_entity
>
>   Request Method:GET Request URL:
> http://linux:8000/admin/directory/entity/Exception Type:
>  OperationalError Exception Value:
>
>  no such table: directory_entity
>
>  Exception 
>  Location:/usr/lib/pymodules/python2.6/django/db/backends/sqlite3/base.py
>  in execute, line 193 Python Executable:/usr/bin/python Python Version:
>  2.6.5 Python Path:['/home/jonathan/directory',
>  '/usr/local/lib/python2.6/dist-packages/pip-0.6.3-py2.6.egg',
>  '/home/jonathan/store/src/satchmo/satchmo/apps',
>  '/usr/local/lib/python2.6/dist-packages/django_threaded_multihost-1.3_3-py2.6.egg',
>  '/usr/local/lib/python2.6/dist-packages/django_signals_ahoy-0.1_1-py2.6.egg',
>  '/usr/local/lib/python2.6/dist-packages/django_tagging-0.3.1-py2.6.egg',
>  '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2',
>  '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old',
>  '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages',
>  '/usr/lib/python2.6/dist-packages/PIL',
>  '/usr/lib/python2.6/dist-packages/gst-0.10', 
>  '/usr/lib/pymodules/python2.6',
>  '/usr/lib/python2.6/dist-packages/gtk-2.0',
>  '/usr/lib/pymodules/python2.6/gtk-2.0',
>  '/usr/local/lib/python2.6/dist-packages'] Server time:Fri, 25 Jun 2010
>  14:56:26 -0500
>
>  I have an Entity class/model defined in my models.py and want to
>  manually create some dummy data in the table. Any suggestions?
>
>  --
>  → Jonathan Hayward, christos.jonathan.hayw...@gmail.com
>  → An Orthodox 

Re: How does buildout determine paths needed? (for django-page-cms)

2010-06-29 Thread Bill Freeman
Not buildout specific, but, if I recall correctly, the pages egg
(among others) is not
built in such a way that the media files get included (in setup.py the
function that
goes and discovers the .py files to install only does .py files, other
files must be
added more painfully, and a lot of package maintainers don't do it, and may not
know, because they typically do a VCS checkout or install from a tar,
rather than
from the egg).  Last time I installed pages, after using pip install,
I had to get the
tar and unpack it to get the media files.  I don't recall if that
involved templates, or
just css, images, and js, but I wouldn't be surprised.  The pages templates are
examples, IIRC, and you make your own to stick in
project_root/templates/pages/ .

Bill

On Tue, Jun 29, 2010 at 8:56 AM, John Griessen  wrote:
> I made a buildout with the config below that didn't work right and
> found it needed to have some extra paths added.
>
> Here is the extra path I needed:
>
>  '/home/john/buildout/eggs/django_page_cms-1.1.3-py2.6.egg',
>  '/home/john/buildout/eggs/django_page_cms-1.1.3-py2.6.egg/pages/templates/pages',
>
> pages was being found to not have the contents wanted.  Is having a dir
> pages
> and pages/templates/pages a naming problem for buildout?  If a search
> is being done for * in pages, it might stop short when the top level pages
> is found.
>
> Hints, suggestions how to resolve this appreciated.
> Meanwhile, every time I run buildout, I'll need to copy an paste that extra
> path...
>
> John
> -buildout.cfg
> [buildout]
> eggs-directory = /home/john/buildout/eggs
> extensions = mr.developer
>
> parts =
>    django
>
> eggs =
>    mock
>    django-notification
>    django-page-cms
>    django-haystack
>    django-staticfiles
>    django-messages
>    django-mptt-2
>    whoosh
>
> [django]
> recipe = djangorecipe
> version = 1.2.1
> settings = development
> wsgi = true
> eggs = ${buildout:eggs}
> project = industromatic_com
> buildout.cfg--
>
> ___
> Distutils-SIG maillist  -  distutils-...@python.org
> http://mail.python.org/mailman/listinfo/distutils-sig
>
> --
> 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: change displayed name of users object

2010-06-29 Thread derek
On Jun 28, 7:54 pm, Jacob Fenwick  wrote:
> Is there a simple way to change the displayed name of the users object in
> the auth package?
>
> I don't care about what it's called under the hood. I just want to change
> what the user sees.
>
> I'd like to avoid changing the code directly in the Django library as that
> will make upgrades difficult.
>
> I came across this article but it's quite old and I'm hoping there's a
> better way:
>
> http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m...
>
> Jacob

Have a look at:
http://bradmontgomery.blogspot.com/2010/04/pretty-options-for-djangos-authuser.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.



No module named site - error deploying a django-jython war in tomcat

2010-06-29 Thread tobycatlin
Hello everybody,

I have followed the install instructions for the latest versions of
the following: jython (version: jython-2.5.2b1), django (1.2.1) and
jython-django (version 1.1.1) and have built a war of my very simple
test application.

Oh i built the war on my linux box and have tested in tomcat on both
windows and linux machines. When i went to the url i got a 500
exception:

javax.servlet.ServletException: Exception creating modjy servlet:
ImportError: No module named site

com.xhaus.modjy.ModjyJServlet.init(ModjyJServlet.java:124)
javax.servlet.GenericServlet.init(GenericServlet.java:211)

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
105)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
541)

org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
869)
org.apache.coyote.http11.Http11BaseProtocol
$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:
664)

org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:
527)

org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:
80)
org.apache.tomcat.util.threads.ThreadPool
$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:619)

I have managed to find a fair amount of documentation on building the
war but all the docs say "just deploy the war normally" so i guess i
have missed something in building the war itself. I set a JYTHONPATH
env var, is there anything else i should have done?

I can supply the war file, but it is 30mb so if it helps i'll post a
link to it for folk to download

Thanks for any and all help

toby

-- 
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: How To Create POST data without an actual POST?

2010-06-29 Thread Jani Tiainen
> I'd like to find a way to let my users submit form data without
> submitting
> it via an actual web form. For example, I have users that would like
> to
> send their data via email, or perhaps provide it in an excel spread
> sheet,
> 
> I'm trying to figure out how to do this and still leverage all the
> error
> checking associated with my forms (ie, via is_valid).
> 
> I'm thinking that on the server side I could create a form with
> initial data,
> and then instead of rendering that form, I'd like to just convert it
> directly
> to a POST data dict, as if the user submitted the form without making
> any changes. Then I'd take that POST data, add a bit of additinal
> data
> that I've gotten from some other source (ie from email or excel), then
> run
> is_valid(), then do my standard save to my db object.
> 
> Can anyone comment on if this seems like a good approach for doing
> this,
> and if so, if there is any django support for turning a form directly
> into a data dict?
> 
> Thanks!
> Margie

Well it depends how you want to integrate your system.

In simplest form you can pass data as a plain python dictionary (which it 
pretty much is) to form and validate. 

my_data = { 'field1' : 1, 'field2' : 'some data', }

form = MyForm(data=my_data)  

Works pretty well, there is no problems with that.

Or like someone already suggested you can do various middle formats (like 
json) or send even "real" request from parser.

You could do even custom command that accepts "post data" as json and pushes 
it to database through the form you've created.

Even forms normally take in request.POST using them is not limited to plain 
HTTP POST requests but you can do it with plain dicts as well.

-- 

Jani Tiainen

-- 
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: QuerySet Behaviour Question (Django 1.1)

2010-06-29 Thread Matthias Kestenholz
Hi

On Mon, Jun 28, 2010 at 4:37 PM, Jeff  wrote:
> Hi,
>
> I have a question concerning some queryset behaviour in Django 1.1.
>
> In this example, I have an article model that can contain 1 or more
> authors who are users registered through Django's auth system.
>
> I get the following output when playing around with an article in a
> shell where I have three authors:
>
 article.authors.all()
> [, , ]
 article.authors.all()[0]
> 
 article.authors.all()[1]
> 
 article.authors.all()[2]
> 
 article.authors.all()[0:1]
> []
 article.authors.all()[1:2]
> []
 article.authors.all()[2:3]
> []
>
> I'm curious why article.authors.all()[0] does not return 
> and instead returns . I'm also curious as to why  jeff> appears twice when slicing queries and it doesn't when
> requesting all results.
>
> Thank you in advance for your time!
>

Simple... User does not have a default ordering, therefore the
database is free to return the results in random order (the order may
even be different for subsequent queries as you have seen)

You should add an .order_by() clause if you need a stable ordering of
Users, f.e. User.objects.order_by('username')

-- 
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 - Edit parent model and related models on the same page

2010-06-29 Thread derek
On Jun 28, 1:48 am, DoubleD  wrote:
> I want to be able to edit all data on one page. How can i achieve
> this ? Should i modify my models? If so, then how should i modify
> them?
>
> class TextStyle(models.Model):
>     color = models.CharField(_("color"), max_length=7)
>     style = models.CharField(_("style"), max_length=30)
>     typeface = models.CharField(_("typeface"), max_length=100)
>
> class GenericText(models.Model):
>     text = models.TextField(_("text"))
>     lines = models.IntegerField(_("number of lines"))
>     style = models.ForeignKey(TextStyle, verbose_name=_('text style'),
> blank=False)
>
> class ExpirationDate(models.Model):
>     date = models.DateField(_("date"))
>     style = models.ForeignKey(TextStyle, verbose_name=_('text style'),
> blank=False)
>
> class Coupon(models.Model):
>     name = models.CharField(_("name"), max_length=100)
>     slug = AutoSlugField(populate_from="title")
>     background = models.ImageField(upload_to="userbackgrounds")
>     layout = models.ForeignKey(Layout, verbose_name=("layout"),
> blank=False)
>     logo = models.ImageField(upload_to="logos")
>     title = models.OneToOneField(GenericText, verbose_name=("title"),
> blank=False, related_name="coupon_by_title")
>     body = models.OneToOneField(GenericText, verbose_name=("body"),
> blank=False, related_name="coupon_by_body")
>     disclaimer = models.OneToOneField(GenericText,
> verbose_name=("disclaimer"), blank=False,
> related_name="coupon_by_disclaimer")
>     promo_code = models.OneToOneField(GenericText,
> verbose_name=("promo code"), blank=False,
> related_name="coupon_by_promo")
>     bar_code = models.OneToOneField(BarCode, verbose_name=("barcode"),
> blank=False, related_name="coupon_by_barcode")
>     expiration = models.OneToOneField(ExpirationDate,
> verbose_name=("expiration date"), blank=False,
> related_name="coupon_by_expiration")
>     is_template = models.BooleanField( verbose_name=("is a
> template"), )
>     category = models.ForeignKey(Category, verbose_name=("category"),
> blank=True,null=True, related_name="coupons")
>     user = models.ForeignKey(User, verbose_name=("user"), blank=False)

Its not entirely clear what you want to achieve... have you looked at
using inline model editing?
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects

-- 
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: how to develop cms on django

2010-06-29 Thread derek
On Jun 29, 12:29 pm, samie  wrote:
> sir i am a beginner in python and django..
>
> i want develop a content management system using django..
>
> plz help me wht shld i do from where shld i start..
>
> i am learning python from google videos and develop a application
> which is available on django home website..
>
> m using python 2.6 and django 1.2

If you don't want to build everything from scratch, you may want to
look at:
http://pinaxproject.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.



Creating a many-to-many link for a UserProfile?

2010-06-29 Thread derek
Django 1.2.1, with Python 2.6

I am trying to establish a many-to-many for a userprofile (working
with a legacy database so some of the field names are a little
strange...).

The models I have are:

class UserGrouping(models.Model):
#many-to-many
id = models.AutoField(primary_key=True, db_column='id')
grouping = models.ForeignKey(Grouping, db_column='grouping_id')
user = models.ForeignKey(User, db_column='user_id')
class Meta:
db_table = 'usergrouping'
unique_together = (('grouping', 'user'), )

class UserProfile(models.Model):
user = models.ForeignKey(User, db_column='user_id', unique=True,
primary_key=True, blank=True, null=True, default=None)
userid = models.CharField(verbose_name=_('ID'), unique=True,
editable=False, max_length=6, blank=True, null=True)
records = models.IntegerField(db_column='records', default=20,
blank=True, null=True)
groupings = models.ManyToManyField(UserGrouping,
db_table="usergrouping")
class Meta:
db_table = 'user'

The table structures are as follows:

CREATE TABLE  `usergrouping` (
  `grouping_id` int(11) NOT NULL DEFAULT '0',
  `user_id` int(11) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`),
  UNIQUE KEY `usergrouping_combo` (`grouping_id`,`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

CREATE TABLE  `user` (
  `user_id` int(11) DEFAULT NULL,
  `userid` varchar(6) DEFAULT '',
  `records` int(11) NOT NULL DEFAULT '10',
  `LastChanged` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=utf8


The error I get is:

OperationalError at /admin/auth/user/895/
(1054, "Unknown column 'T2.userprofile_id' in 'where clause'")

I am not sure why Django is looking for a "userprofile_id", and
therefore how to go about creating the relationship?  (If I remove the
'groupings' link, then the profile works as expected.)

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: Beginner nead help

2010-06-29 Thread Adnan Sadzak
Can You describe your folders structure and show us settings.py file?
If You followed tutorial correctly everything should work fine.



On Tue, Jun 29, 2010 at 2:00 PM, Eduan  wrote:

> Okay thanks that you all are so helpful.
> I went through the whole tutorial allot of times and can't even
> complete part 1.
> I thought that it was my setup that i was using.
> I am using Windows 7 and Eclipse SDK Version: 3.5.2 for my programming
> environment. I am using a MySQL 5.5 database.
>
> It all goes fluently till I get to the part where you add
> 'mysite.polls' under installed apps.
> After adding that in there I can't run any command(like
> syncdb,runserver) without getting back an error stating:
> Error: No module named mysite.polls.
> I tried renaming it and I still get that error.
>
> I have downloaded an full Django app called friends here :
> http://github.com/jtauber/django-friends/
> If I syncdb or runserver I get the similar error:
> Error: No module named friends
>
> Now please any help. This could be a simple beginners mistake that I
> am making. Thanks allot
> Eduan
>
> --
> 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.



How does buildout determine paths needed? (for django-page-cms)

2010-06-29 Thread John Griessen

I made a buildout with the config below that didn't work right and
found it needed to have some extra paths added.

Here is the extra path I needed:

  '/home/john/buildout/eggs/django_page_cms-1.1.3-py2.6.egg',
  
'/home/john/buildout/eggs/django_page_cms-1.1.3-py2.6.egg/pages/templates/pages',

pages was being found to not have the contents wanted.  Is having a dir pages
and pages/templates/pages a naming problem for buildout?  If a search
is being done for * in pages, it might stop short when the top level pages is 
found.

Hints, suggestions how to resolve this appreciated.
Meanwhile, every time I run buildout, I'll need to copy an paste that extra 
path...

John
-buildout.cfg
[buildout]
eggs-directory = /home/john/buildout/eggs
extensions = mr.developer

parts =
django

eggs =
mock
django-notification
django-page-cms
django-haystack
django-staticfiles
django-messages
django-mptt-2
whoosh

[django]
recipe = djangorecipe
version = 1.2.1
settings = development
wsgi = true
eggs = ${buildout:eggs}
project = industromatic_com
buildout.cfg--

___
Distutils-SIG maillist  -  distutils-...@python.org
http://mail.python.org/mailman/listinfo/distutils-sig

--
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: context porcessors request.context media_url breaks admin

2010-06-29 Thread Daniel Roseman
On Jun 29, 1:41 pm, justin jools  wrote:
> Hi Tom if you read my original post you will realise that the error is
> being caused by setting of context processors to media_url (see
> original post).
> When context processors are active the {media_url} tag works
> perfectly, but breaks the admin.
>
> If I comment out :
> settings.py
> #TEMPLATE_CONTEXT_PROCESSORS =
> ('portfolio.context_processors.media_url',)
> and
> urls.py
> #from django.template import RequestContext
>
> the admin then works.

You have completely overridden the default template context
processors. All the functionality that the admin depends on -
authentication, csrf protection, internationalisation, messages - has
all now gone thanks to this setting.

You should just *add* your processor to the existing list. However, I
don't understand why you want to do this at all, given that the
default list already includes the
"django.core.context_processors.media" processor which does exactly
the same as your version.
--
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: context porcessors request.context media_url breaks admin

2010-06-29 Thread justin jools
Hi Tom if you read my original post you will realise that the error is
being caused by setting of context processors to media_url (see
original post).
When context processors are active the {media_url} tag works
perfectly, but breaks the admin.

If I comment out :
settings.py
#TEMPLATE_CONTEXT_PROCESSORS =
('portfolio.context_processors.media_url',)
and
urls.py
#from django.template import RequestContext

the admin then works.

I believe this has nothing to do with a template error, but some kind
of conflict. To satisfy mystic meg, I have included error with
traceback:

TemplateSyntaxError at /admin/
Caught an exception while rendering: userRequest Method: GET
Request URL: http://127.0.0.1:8000/admin/
Exception Type: TemplateSyntaxError
Exception Value: Caught an exception while rendering: user
Exception Location: C:\Python26\lib\site-packages\django\template
\debug.py in render_node, line 81
Python Executable: C:\Python26\python.exe
Python Version: 2.6.4
Python Path: ['c:\\django\\portfolio_root', 'C:\\Python26\\lib\\site-
packages\\html5lib-0.90-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_page_cms-1.1.1-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_cms-2.0.2-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_admin_tools-0.2.0-py2.6.egg', 'C:\\Python26\\lib\\site-packages
\\django_friends-0.1.5-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_schedule-0.1.0-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\python_dateutil-1.5-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_forum-r53-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_notification-0.1.4-py2.6.egg', 'C:\\Python26\\lib\\site-
packages\\django_pagination-1.0.5-py2.6.egg', 'C:\\Python26\\lib\\site-
packages\\sphinx-0.6.5-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\docutils-0.6-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\jinja2-2.4.1-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\pygments-1.3.1-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_avatar-1.0.4-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_locations-0.1.0-py2.6.egg', 'C:\\Windows\\system32\
\python26.zip', 'C:\\Python26\\DLLs', 'C:\\Python26\\lib', 'C:\
\Python26\\lib\\plat-win', 'C:\\Python26\\lib\\lib-tk', 'C:\
\Python26', 'C:\\Python26\\lib\\site-packages', 'C:\\Python26\\lib\
\site-packages\\PIL', 'c:\\python26\\lib\\site-packages']
Server time: Tue, 29 Jun 2010 13:36:03 +0100

Template error
In template c:\python26\lib\site-packages\django\contrib\admin
\templates\admin\index.html, error at line 56

Caught an exception while rendering: user
46 {% endif %}

47 

48 {% endblock %}

49
50 {% block sidebar %}

51 

52 

53 {% trans 'Recent Actions' %}

54 {% trans 'My Actions' %}

55 {% load log %}

56 {% get_admin_log 10 as admin_log for_user user %}

57 {% if not admin_log %}

58 {% trans 'None available' %}

59 {% else %}

60 

61 {% for entry in admin_log %}

62 

63 {% if entry.is_deletion %}

64 {{ entry.object_repr }}

65 {% else %}

66 {{ entry.object_repr }}

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.1.1
Python Version: 2.6.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.markup',
 'portfolio']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Template error:
In template c:\python26\lib\site-packages\django\contrib\admin
\templates\admin\index.html, error at line 56
   Caught an exception while rendering: user
   46 : {% endif %}


   47 : 


   48 : {% endblock %}


   49 :


   50 : {% block sidebar %}


   51 : 


   52 : 


   53 : {% trans 'Recent Actions' %}


   54 : {% trans 'My Actions' %}


   55 : {% load log %}


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


   57 : {% if not admin_log %}


   58 : {% trans 'None available' %}


   59 : {% else %}


   60 : 


   61 : {% for entry in admin_log %}


   62 : 


   63 : {% if entry.is_deletion %}


   64 : {{ entry.object_repr }}


   65 : {% else %}


   66 : {{ entry.object_repr }}


Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
wrapper
  196. return self.admin_view(view, cacheable)(*args,
**kwargs)
File 

Parameters

2010-06-29 Thread Waleria
Hi all,

I have the following code below and i need receive the parameters of
the index view: Sfase=[ ], Sserie=[ ], Sba=[ ], St=[ ] and f  to my
view draws_graph but i don't know.

Because if I pass the parameters as I am passing on draws_graph
view(line 68,69 and 70 - view draws_graph), it works by drawing the
image in the template but if I comment these lines does not work

look my code..how can I get these parameters index view?

http://paste.pocoo.org/show/231295/

-- 
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: Beginner nead help

2010-06-29 Thread Eduan
Okay thanks that you all are so helpful.
I went through the whole tutorial allot of times and can't even
complete part 1.
I thought that it was my setup that i was using.
I am using Windows 7 and Eclipse SDK Version: 3.5.2 for my programming
environment. I am using a MySQL 5.5 database.

It all goes fluently till I get to the part where you add
'mysite.polls' under installed apps.
After adding that in there I can't run any command(like
syncdb,runserver) without getting back an error stating:
Error: No module named mysite.polls.
I tried renaming it and I still get that error.

I have downloaded an full Django app called friends here :
http://github.com/jtauber/django-friends/
If I syncdb or runserver I get the similar error:
Error: No module named friends

Now please any help. This could be a simple beginners mistake that I
am making. Thanks allot
Eduan

-- 
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 Tagging: no module named tagging, locally win7

2010-06-29 Thread justin jools
Yes, great ;) that worked. I put it in my root Apps folder...
seems very strange that it doesnt work in site-packages.

Anyway this will do fine :)

On Jun 29, 12:19 pm, Venkatraman S  wrote:
> On Tue, Jun 29, 2010 at 4:35 PM, justin jools  wrote:
> > I've installed Django Tagging SVN checkout, 0.3.1 zip, 0.3 exe and
> > 0.2.1 versions
> > and I keep getting 'no module named tagging' when I try to run python
> > manage.py syncdb.
>
> > I've checked my Python path and added extra links:
> > C:\Python26\Lib\site-packages\tagging;
> > C:\Python26\Lib\site-packages;
> > C:\Python26;
> > C:\Python26\Scripts;
> > C:\Python26\Lib\site-packages\django\bin;
>
> > and other modules are woking no problem, so it leads me to believe
> > there is something wrong with the module?
>
> Have you installed tagging module? If not, just place that module parallel
> to your apps, check INSTALLED_APPS and try once more?
>
> -V-http://twitter.com/venkasub- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 Tagging: no module named tagging, locally win7

2010-06-29 Thread Venkatraman S
On Tue, Jun 29, 2010 at 5:08 PM, justin jools  wrote:

> I tried installing by python setup.py install: SVN checkout,  0.3.1
> zip and also tried installing binary 0.3 exe.
> They all installed fine everytime, I also just tried moving 'tagging'
> to python/Lib/site-packages
>
> It seems that Python isnt finding it.
>

Go into Project folder and from the 'shell'  try importing tagging.
Also, did you try by moving tagging inside your project folder?

-- 
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: context porcessors request.context media_url breaks admin

2010-06-29 Thread Tom Evans
On Tue, Jun 29, 2010 at 12:33 PM, justin jools  wrote:
> I corrected my settings.py links:
>
> TEMPLATE_DIRS = 'C:/django/portfolio_root/templates/'
> MEDIA_ROOT = 'C:/django/portfolio_root/site-media/'
> MEDIA_URL = '/site-media/'
> ADMIN_MEDIA_PREFIX = '/media/'
>
> but I still get this error:
>
> TemplateSyntaxError at /admin/
> Caught an exception while rendering: userRequest Method: GET
> Request URL: http://127.0.0.1:8000/admin/
> Exception Type: TemplateSyntaxError
> Exception Value: Caught an exception while rendering: user
> Exception Location: C:\Python26\lib\site-packages\django\template
> \debug.py in render_node, line 81
> Python Executable: C:\Python26\python.exe
> Python Version: 2.6.4
>

All that says is that your template has an error. Mystic Meg is out to
lunch, you will have to supply better information.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 Tagging: no module named tagging, locally win7

2010-06-29 Thread justin jools
I tried installing by python setup.py install: SVN checkout,  0.3.1
zip and also tried installing binary 0.3 exe.
They all installed fine everytime, I also just tried moving 'tagging'
to python/Lib/site-packages

It seems that Python isnt finding it.

On Jun 29, 12:19 pm, Venkatraman S  wrote:
> On Tue, Jun 29, 2010 at 4:35 PM, justin jools  wrote:
> > I've installed Django Tagging SVN checkout, 0.3.1 zip, 0.3 exe and
> > 0.2.1 versions
> > and I keep getting 'no module named tagging' when I try to run python
> > manage.py syncdb.
>
> > I've checked my Python path and added extra links:
> > C:\Python26\Lib\site-packages\tagging;
> > C:\Python26\Lib\site-packages;
> > C:\Python26;
> > C:\Python26\Scripts;
> > C:\Python26\Lib\site-packages\django\bin;
>
> > and other modules are woking no problem, so it leads me to believe
> > there is something wrong with the module?
>
> Have you installed tagging module? If not, just place that module parallel
> to your apps, check INSTALLED_APPS and try once more?
>
> -V-http://twitter.com/venkasub- Hide quoted text -
>
> - Show quoted text -

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

2010-06-29 Thread justin jools
I corrected my settings.py links:

TEMPLATE_DIRS = 'C:/django/portfolio_root/templates/'
MEDIA_ROOT = 'C:/django/portfolio_root/site-media/'
MEDIA_URL = '/site-media/'
ADMIN_MEDIA_PREFIX = '/media/'

but I still get this error:

TemplateSyntaxError at /admin/
Caught an exception while rendering: userRequest Method: GET
Request URL: http://127.0.0.1:8000/admin/
Exception Type: TemplateSyntaxError
Exception Value: Caught an exception while rendering: user
Exception Location: C:\Python26\lib\site-packages\django\template
\debug.py in render_node, line 81
Python Executable: C:\Python26\python.exe
Python Version: 2.6.4

-- 
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 Tagging: no module named tagging, locally win7

2010-06-29 Thread Venkatraman S
On Tue, Jun 29, 2010 at 4:35 PM, justin jools  wrote:

> I've installed Django Tagging SVN checkout, 0.3.1 zip, 0.3 exe and
> 0.2.1 versions
> and I keep getting 'no module named tagging' when I try to run python
> manage.py syncdb.
>
> I've checked my Python path and added extra links:
> C:\Python26\Lib\site-packages\tagging;
> C:\Python26\Lib\site-packages;
> C:\Python26;
> C:\Python26\Scripts;
> C:\Python26\Lib\site-packages\django\bin;
>
> and other modules are woking no problem, so it leads me to believe
> there is something wrong with the module?
>

Have you installed tagging module? If not, just place that module parallel
to your apps, check INSTALLED_APPS and try once more?

-V-
http://twitter.com/venkasub

-- 
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 Tagging: no module named tagging, locally win7

2010-06-29 Thread justin jools
I've installed Django Tagging SVN checkout, 0.3.1 zip, 0.3 exe and
0.2.1 versions
and I keep getting 'no module named tagging' when I try to run python
manage.py syncdb.

I've checked my Python path and added extra links:
C:\Python26\Lib\site-packages\tagging;
C:\Python26\Lib\site-packages;
C:\Python26;
C:\Python26\Scripts;
C:\Python26\Lib\site-packages\django\bin;

and other modules are woking no problem, so it leads me to believe
there is something wrong with the module?

Any help please.

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

2010-06-29 Thread justin jools
Yes I did accidentally set my

ADMIN_MEDIA_PREFIX = '/site-media/' instead of media

I'll try this

On Jun 29, 8:57 am, bruno desthuilliers
 wrote:
> On 29 juin, 00:44, justin jools  wrote:
>
>
>
>
>
> > I am trying to use media_url with generic views:
> > When I set context processors to media_url, with generic views it
> > breaks Admin:
>
> > Caught an exception while rendering: user
>
> > settings.py
> > TEMPLATE_CONTEXT_PROCESSORS =
> > ('portfolio.context_processors.media_url',)
>
> > context_processors.py
> > def media_url(request):
> >     from django.conf import settings
> >     return {'media_url': settings.MEDIA_URL}
>
> > urls.py
> > from django.template import RequestContext
>
> > urlpatterns = patterns('',
> >     (r'^admin/', include(admin.site.urls)),
> >     (r'^work/$', 'django.views.generic.list_detail.object_list',
> > dict(info_dict, template_name="portfolio/projects_list.html")),
> > )
>
> > and when I remove it the admin works, but I have no media_url
> > reference
>
> > Any suggestions please?
>
> Check your MEDIA_URL and ADMIN_MEDIA_PREFIX settings, collisions can
> happen - like if your MEDIA_URL is '/medias/' and your
> ADMIN_MEDIA_PREFIX is '/medias/ too - that have this exact result.
> FWIW, you can set the ADMIN_MEDIA_PREFIX to whatever you want (I
> usually use '/admins-medias/' to avoid the above problem).
>
> HTH- Hide quoted text -
>
> - Show quoted text -

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

2010-06-29 Thread Adnan Sadzak
You can learn from http://www.django-cms.org/ project.
It have all You need to start Your own project and to learn.


On Tue, Jun 29, 2010 at 12:41 PM, samie  wrote:

> 1 more query..
>
> what are important that i shld. learn in python and in django to
> develop my cms..
>
> --
> 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: how to develop cms on django

2010-06-29 Thread samie
1 more query..

what are important that i shld. learn in python and in django to
develop my cms..

-- 
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 develop cms on django

2010-06-29 Thread samie
sir i am a beginner in python and django..

i want develop a content management system using django..

plz help me wht shld i do from where shld i start..

i am learning python from google videos and develop a application
which is available on django home website..

m using python 2.6 and django 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: Beginner nead help

2010-06-29 Thread bruno desthuilliers
On 29 juin, 10:54, Eduan  wrote:
> Hi all. I am a old Delphi programmer and started to use Django.

Hi Eduan

Just for a quick clarification : Django is a framework, based on the
Python programming language, and you'll need a good knowledge of
Python itself to make the besr use of Django. Sorry if you were
already well aware of this distinction but some newcomers tend to
overlook that point so...

Anyway: welcome onboard.


> I started at Djangoprojects's tutorial and get stuck at places.

Do not hesitate to post about your problems here.

-- 
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: Beginner nead help

2010-06-29 Thread Massimiliano della Rovere
I do not know whether there is or not the complete tutorial, but you
can write the errors you receive or the doubts you have.
They could be useful for other beginners too :)


On Tue, Jun 29, 2010 at 10:54, Eduan  wrote:
> Hi all. I am a old Delphi programmer and started to use Django. I
> believe that it is the future of programming. I started at
> Djangoprojects's tutorial and get stuck at places. Is there some
> place
> that I can download the full finished tutorial? or if anyone of you
> have the complete tutorial that you can send me.
>
> Thanks allot
> Eduan

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



Beginner nead help

2010-06-29 Thread Eduan
Hi all. I am a old Delphi programmer and started to use Django. I
believe that it is the future of programming. I started at
Djangoprojects's tutorial and get stuck at places. Is there some
place
that I can download the full finished tutorial? or if anyone of you
have the complete tutorial that you can send me.

Thanks allot
Eduan

-- 
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: More than one primary key for a model

2010-06-29 Thread bruno desthuilliers
On 28 juin, 19:27, thusjanthan  wrote:
> Yes you are correct I am looking to implement the compounded primary
> keys.

It's a fact that Django's ORM doesn't support compound primary keys so
far. It's a bit of a shortcoming, but the good news is that it's a
FOSS project so YOU can contribute !-)

OTHO - and while I tend to dislike them - having surrogate keys all of
the same type sometimes help with genericity and reusability. Things
like the ContentType framework just couldn't work without.

> Well the problem is I would like to have a many to many(m2m)
> with two models that share a compounded primary key. However when I do
> the m2m join it randomly pics one of the compounded keys and tries to
> join them? :|

> Does the unique_together parameter fix that problem?
> as
> in does it use the unique_together to do the joins?

unique_together creates compound indexes with a unicity contraint.
That's all. IOW, it won't be used to "do the joins". Now nothing
prevents you to do the join by yourself, but since you'll still need a
surrogate primary key chances are this will just be a waste of time.

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



Djangoprojects tutorial

2010-06-29 Thread Eduan
Hi all. I am a old Delphi programmer and started to use Django. I
believe that it is the future of programming. I started at
Djangoprojects's tutorial and get stuck at places. Is there some place
that I can download the full finished tutorial? or if anyone of you
have the complete tutorial that you can send me.

Thanks allot
Eduan

-- 
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: context porcessors request.context media_url breaks admin

2010-06-29 Thread bruno desthuilliers
On 29 juin, 00:44, justin jools  wrote:
> I am trying to use media_url with generic views:
> When I set context processors to media_url, with generic views it
> breaks Admin:
>
> Caught an exception while rendering: user
>
> settings.py
> TEMPLATE_CONTEXT_PROCESSORS =
> ('portfolio.context_processors.media_url',)
>
> context_processors.py
> def media_url(request):
>     from django.conf import settings
>     return {'media_url': settings.MEDIA_URL}
>
> urls.py
> from django.template import RequestContext
>
> urlpatterns = patterns('',
>     (r'^admin/', include(admin.site.urls)),
>     (r'^work/$', 'django.views.generic.list_detail.object_list',
> dict(info_dict, template_name="portfolio/projects_list.html")),
> )
>
> and when I remove it the admin works, but I have no media_url
> reference
>
> Any suggestions please?

Check your MEDIA_URL and ADMIN_MEDIA_PREFIX settings, collisions can
happen - like if your MEDIA_URL is '/medias/' and your
ADMIN_MEDIA_PREFIX is '/medias/ too - that have this exact result.
FWIW, you can set the ADMIN_MEDIA_PREFIX to whatever you want (I
usually use '/admins-medias/' to avoid the above problem).

HTH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: How To Create POST data without an actual POST?

2010-06-29 Thread Torsten Bronger
Hallöchen!

Margie Roginski writes:

> I'd like to find a way to let my users submit form data without
> submitting it via an actual web form. For example, I have users
> that would like to send their data via email, or perhaps provide
> it in an excel spread sheet,

Maybe you can fool the view functions by providing a request object
which simulates a call from the browser.  But if performance is not
an issue, I would create an intermediate program that takes all the
emails and spreadsheets and makes (possibly local) HTTP POST
requests on your server.

This is the way we do it here: A cronjob scans a shared directory
for new data regulary, and when it finds some, it sends an HTTP POST
to the web server, which runs on the same machine.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.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: How To Create POST data without an actual POST?

2010-06-29 Thread Massimiliano della Rovere
or you can use python urllib2: http://docs.python.org/library/urllib2.html

On Tue, Jun 29, 2010 at 02:15, Gabriel Gayan  wrote:
> Maybe trying with ajax?
> jquery has some nice functions to deal with ajax post requests.
> You can even send files via ajax.
> From the server side, you could return JSON objects and parse them on the
> client (for validation).
> Cheers
>
> On Mon, Jun 28, 2010 at 4:22 PM, Margie Roginski 
> wrote:
>>
>> I'd like to find a way to let my users submit form data without
>> submitting
>> it via an actual web form. For example, I have users that would like
>> to
>> send their data via email, or perhaps provide it in an excel spread
>> sheet,
>>
>> I'm trying to figure out how to do this and still leverage all the
>> error
>> checking associated with my forms (ie, via is_valid).
>>
>> I'm thinking that on the server side I could create a form with
>> initial data,
>> and then instead of rendering that form, I'd like to just convert it
>> directly
>> to a POST data dict, as if the user submitted the form without making
>> any changes. Then I'd take that POST data, add a bit of additinal
>> data
>> that I've gotten from some other source (ie from email or excel), then
>> run
>> is_valid(), then do my standard save to my db object.
>>
>> Can anyone comment on if this seems like a good approach for doing
>> this,
>> and if so, if there is any django support for turning a form directly
>> into a data dict?
>>
>> Thanks!
>> Margie
>>
>> --
>> 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.
>>
>
>
>
> --
> Gabriel Gayan
>
> --
> 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.