Re: Inline validation

2010-02-08 Thread chefsmart
You could take a look at 
http://wadofstuff.blogspot.com/2009/08/requiring-at-least-one-inline-formset.html

On Feb 8, 6:46 pm, Gabriel Reis  wrote:
> Hello guys,
>
> I have the following situation:
>
> class FooInline(TabularInline):
>     model = Foo
>     extra = 1
>     max_num = 1
>
> class MyAdmin(admin.ModelAdmin):
>     inlines = [FooInline,]
>
> Is there any way to perform a validation in which the user must have filled
> the fields of the inline formset?
> I mean, if the user does not change anything in the inline form, raise a
> form error validation?
>
> Thanks!
>
> Cheers,
>
> Gabriel Reis

-- 
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: 'ValidationError' object has no attribute 'message_dict'

2010-02-08 Thread Kenneth Gonsalves
On Tuesday 09 Feb 2010 12:29:48 pm Karen Tracey wrote:
> > simplest validation possible is giving me an error - if the data is
> > valid, no
> > error, but on invalid data I get the traceback appended below. Am I doing
> > something wrong or is it bug no
> > http://code.djangoproject.com/ticket/12698 ?
> 
> Looks like that bug to me.
> 

so it means sticking to form validation for the time being?
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

-- 
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: 'ValidationError' object has no attribute 'message_dict'

2010-02-08 Thread Karen Tracey
On Tue, Feb 9, 2010 at 1:47 AM, Kenneth Gonsalves  wrote:

> hi,
>
> I am using the latest revision 12398. I am trying model validation - but
> the
> simplest validation possible is giving me an error - if the data is valid,
> no
> error, but on invalid data I get the traceback appended below. Am I doing
> something wrong or is it bug no http://code.djangoproject.com/ticket/12698
> ?
>

Looks like that bug to me.

Karen

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



Customized filter for Django Admin

2010-02-08 Thread Derek
Given a model such as:

class Country(models.Model):
code = models.CharField(max_length=2, primary_key=True)
name = models.CharField()

class Region(models.Model):
name = models.CharField()
country = models.ForeignKey(Country)

with an admin option:

class RegionAdmin(admin.ModelAdmin):
list_filter = ('country', )

Can the filter list for the Region (as shown above in the RegionAdmin class)
be altered in some way such that it only shows those countries that have
regions? i.e. it will not show the complete list of all Countrys, but only
that subset which are already linked to Regions.

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.



'ValidationError' object has no attribute 'message_dict'

2010-02-08 Thread Kenneth Gonsalves
hi,

I am using the latest revision 12398. I am trying model validation - but the 
simplest validation possible is giving me an error - if the data is valid, no 
error, but on invalid data I get the traceback appended below. Am I doing 
something wrong or is it bug no http://code.djangoproject.com/ticket/12698? 
The validation is:

def clean(self):
# valfrom should be less than valto
if self.valfrom >= self.valto:
raise ValidationError(_("Valid from should be earlier than valid 
to"))

and the traceback is:

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/addhandicap/
Django Version: 1.2 beta 1 SVN-12398
Python Version: 2.6.0
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'djangogolf.web']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/lib/python2.6/django/core/handlers/base.py" in get_response
  101. response = callback(request, *callback_args, 
**callback_kwargs)
File "/usr/lib/python2.6/django/utils/decorators.py" in __call__
  36. return self.decorator(self.func)(*args, **kwargs)
File "/usr/lib/python2.6/django/contrib/auth/decorators.py" in _wrapped_view
  24. return view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/django/forms/forms.py" in is_valid
  120. return self.is_bound and not bool(self.errors)
File "/usr/lib/python2.6/django/forms/forms.py" in _get_errors
  111. self.full_clean()
File "/usr/lib/python2.6/django/forms/forms.py" in full_clean
  267. self._clean_form()
File "/usr/lib/python2.6/django/forms/models.py" in _clean_form
  320. self._update_errors(e.message_dict)

Exception Type: AttributeError at /addhandicap/
Exception Value: 'ValidationError' object has no attribute 'message_dict'


-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

-- 
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: want to convert object to json data.

2010-02-08 Thread Wayne Koorts
> I want to convert a given regular object to json object. i.e. I want
> to create a function which takes the class object as parameter and it
> should return the json object.

Have a look at the built-in Django "serializers" module:

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

Regards,
Wayne

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



want to convert object to json data.

2010-02-08 Thread chiranjeevi.muttoju
Hi all,
I want to convert a given regular object to json object. i.e. I want
to create a function which takes the class object as parameter and it
should return the json object.
If anybody know please help me how to approach to get this.

Thanks and regards,
--chiranjeevi

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



What do you think of pycharm?

2010-02-08 Thread Joshua Partogi
Hi all,

I just found a new Python IDE that supports django, named pycharm
(http://www.jetbrains.com/pycharm). I was wondering whether anyone
else has used it? If so, what do you think about the django support in
it? Do you think it's good or useless?

Kind regards,

-- 
http://twitter.com/scrum8

-- 
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.py startproject xyz" opens text editor

2010-02-08 Thread Karen Tracey
On Tue, Feb 9, 2010 at 1:32 AM, gvkalra  wrote:

> "django-admin.py startproject xyz" opens my default text editor viz.
> Notepad++ and opens the file django-admin.py in it for editing...What
> could be the reason? I am not able to create a project
>

I guess you are on Windows?  Apparently the .py extension has been
associated with your editor executable instead of python.exe.

Karen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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.py startproject xyz" opens text editor

2010-02-08 Thread gvkalra
"django-admin.py startproject xyz" opens my default text editor viz.
Notepad++ and opens the file django-admin.py in it for editing...What
could be the reason? I am not able to create a project

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



Re: How can _meta.local_fields not match the table schema in the database?

2010-02-08 Thread Russell Keith-Magee
On Mon, Feb 8, 2010 at 1:10 AM, br...@instantdirectmarketing.com
 wrote:
> I'm completely confused about why _meta.local_fields returns more
> fields than the database table contains. The User model inherits from
> contrib.auth.models.User.
...
> I wonder if the User.add_to_class would be interpreted twice. This is
> an open source project, CNPROG @ Github. I did not create it.

It's certainly possible. It depends on how the models.py file is
imported. If you have two independent import paths (e.g., from forum
import models and from cnprog.forum import models) the add_to_class
methods could be called twice.

> It does seem it would have been better to use UserProfile or to
> subclass User. I'll have to refactor this now. The project has no
> tests, so I might have to create those first. I did hear there was an
> issue with MySQLdb and MySQL interface a while back, but I don't know
> the version.

The approach used by cnprog may work under certain circumstances, but
it certainly isn't documented best practice. If you want to attach
data to a User, UserProfile is the recommended approach.

Yours,
Russ Magee %-)

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



Tutorial 4 - generic views - No polls are available

2010-02-08 Thread galien
Yet Another Noob here...

I've searched f the prblem I have. I found some but no post helped.

I followed the tutorial step by step. I had no problem until generic
views.

(Windows XP - Django 1.1.1 - python 2.6.4.8 )

Here's the directory hierarchy

E:\djanggoHttpDoc\mysite - settings.py, manage.py, urls.py,
__init__.py

E:\djanggoHttpDoc\mysite\polls - admin.py, models.py, tests.py,
urls.py, views.py, __init__.py

E:\djanggoHttpDoc\mysite\db - sqlite3.db

E:\djanggoHttpDoc\mytemplates\admin\base_site.html

E:\djanggoHttpDoc\mytemplates\polls - detail.html, index.html,
poll_list.html, results.html

I know I didn't renamed detail to poll_detail.html etc.

However, I only wanted to check http://127.0.0.1:8000/polls/ first.
but it showed

No polls are available

I DO have poll and choice data in db, and it worked with the
templates.

What could be the problem?

polls/urls.py
===
from django.conf.urls.defaults import *
from mysite.polls.models import Poll

info_dict = {
'queryset': Poll.objects.all(),
}

urlpatterns = patterns('',
(r'^$', 'django.views.generic.list_detail.object_list',
info_dict),
#(r'^(?P\d+)/$',
'django.views.generic.list_detail.object_detail', info_dict),
#url(r'^(?P\d+)/results/$',
'django.views.generic.list_detail.object_detail', dict(info_dict,
template_name='polls/results.html'), 'poll_results'),
#(r'^(?P\d+)/vote/$', 'mysite.polls.views.vote'),
)

==
polls/views.py
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from mysite.polls.models import Choice, Poll




def detail(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('polls/detail.html', {'poll': p})

def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the poll voting form.
return render_to_response('polls/detail.html', {
'poll': p,
'error_message': "You didn't select a choice.",
})
else:
selected_choice.votes += 1
selected_choice.save()
# Always return an HttpResponseRedirect after successfully
dealing
# with POST data. This prevents data from being posted twice
if a
# user hits the Back button.
return
HttpResponseRedirect(reverse('mysite.polls.views.results',
args=(p.id,)))

def results(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('polls/results.html', {'poll': p})



If you need to see other files, please let me know.

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.



Sorting by a GenericRelation Causes Result Oddities

2010-02-08 Thread Bryan Veloso
Alright, let's see if I can explain this:

I have an Artist model and artists get positionally ranked. It has a
GenericRelation to another model that stores scores from that ranking.
I wanted to be able to sort Artists by their score using that
GenericRelation. Here's an example (ran this in the interpreter) of a
list of artists ranked by a specific user.

>>> items
[, , ,
, , , , , ,
, , ,
, , ]
>>> items.order_by('overall_child__score')
[, , ,
, , , , , , , , , , , , , ]
>>> items.order_by('overall_child__score').distinct()
[, , ,
, , , , , , , , , , ,
, , ]
>>> items.count()
15
>>> items.order_by('overall_child__score').count()
15

As you can see,  and  are
duplicated, but the .count() doesn't reflect that. Here's the kicker,
in the table that the GenericRelation is linked to, those two records
occur twice. I had some friends test my application last night the
number of duplicates was equal to the number of people that included
that specific artist in their ranking.

It's an OUTER JOIN, but I don't know if that has anything to do with
it, but it seems to ignore any type of filtering that I'm trying to do
to it. Hopefully that makes some kind of sense. I don't know if
there's a way around it, or if it's a bug that needs to be fixed. But
any insight would be great. :)

Cheers,
Bryan

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



images in admin/change_list.html

2010-02-08 Thread django_jedi
I feel like I'm missing something obvious.  Another set of eyes would
be greatly appreciated.

I'm trying to add an image to the change_list form in the admin.
Doesn't seem to work.

Here's a snippet I found that gets me most of the way there:

 (from models.py) 

def image_img(self):
if self.image:
return u'' % 
self.image.url_125x125
else:
return '(test)'
image_img.short_description = 'Image'
image_img.allow_tags = True


--- (from admin.py) 

class LibraryAdmin(admin.ModelAdmin):
list_display = ['image_img', 'image', 'name', 'pub_date']
form = LibraryForm
position_field = 'position'
order_with_respect_to = 'category'

Here is my full models.py:
http://dpaste.com/156429/


TIA.





-- 
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: specifying the pk for an insert

2010-02-08 Thread felix

well I'll be damned, it worked

usage:

apt = Apt()
# old is coming via multi-db connection to mysql
# apt is saved in postgres
apt.id = old.id

# the seq name is {app}_{model}_id_seq

legacy_save(apt,'nsproperties_apt_id_seq')

# after all apts are imported then set the seq correctly:
set_max_seq(Apt,'nsproperties_apt_id_seq')


def legacy_save(self, seqname):
"""
 forces an insert on a model 'self' even though the pk is set.
 for one-time insertion of objects while preserving the pk from a
legacy schema
"""
from django.db import connections, transaction
raw = False
using = 'default'
connection = connections[using]
cls = self.__class__
meta = cls._meta

# If we are in a raw save, save the object exactly as presented.
# That means that we don't try to be smart about saving attributes
# that might have come from the parent class - we just save the
# attributes we have been given to the class we have been given.
# We also go through this process to defer the save of proxy
objects
# to their actual underlying model.
if not raw or meta.proxy:
if meta.proxy:
org = cls
else:
org = None
for parent, field in meta.parents.items():
# At this point, parent's primary key field may be unknown
# (for example, from administration form which doesn't
fill
# this field). If so, fill it.
if field and getattr(self, parent._meta.pk.attname) is
None and getattr(self, field.attname) is not None:
setattr(self, parent._meta.pk.attname, getattr(self,
field.attname))

self.save_base(cls=parent, origin=org, using=using)

if field:
setattr(self, field.attname,
self._get_pk_val(parent._meta))
if meta.proxy:
return

if not meta.proxy:
manager = cls._base_manager
values = [(f, f.get_db_prep_save(raw and getattr(self,
f.attname) or f.pre_save(self, True), connection=connection))
for f in meta.local_fields]

update_pk = True

cursor = connection.cursor() #...@undefinedvariable

# somewhat of a hack, to keep postgres quiet about the seq not
being selected for this session
# its actually saying "the last object saved had this id"
# although it will really be the one we are about to save
cursor.execute("SELECT setval('%s'::regclass, %s);" %
(seqname,self.pk))
# Create a new record.
result = manager._insert(values, return_id=update_pk,
using=using)

assert self.pk == result,Exception("saved pk is not self pk")

transaction.commit_unless_managed(using=using)

# Store the database on which the object was saved
self._state.db = using


def set_max_seq(model,seqname):
max = model.objects.order_by('-id')[0]
max_id = max.pk + 1
cursor = connection.cursor() #...@undefinedvariable
cursor.execute("SELECT setval('%s'::regclass, %s);" %
(seqname,max_id))
return max_id

-- 
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 an external url in the django admin section

2010-02-08 Thread Vasil Vangelovski
You can override the template for a specific app by first copying it
to a template folder respectful to that app
See this:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates



On Mon, Feb 8, 2010 at 8:16 AM, djangonoob  wrote:
> Hi all.
>
> If someone could please help me as I am very new to django and getting
> desperate for help.
>
> The issue is as follows:
>
> For one of my apps in 'INSTALLED APPS' I need to add a link in the
> admin section that will cause the stats to be downloaded. The URL for
> this link is /questionnaire/export_csv. How can I define such a link
> please?
>
> Thank you for your help.
>
> This is the template but as you will see this creates the link for the
> questionnaire/export_csv, but it does create the link for every single
> app instead of just for the Questionnaire app.
>
> admin_index.py
> {% extends "admin/base_site.html" %}
> {% load i18n %}
>
> {% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/
> base.css{% endblock %}
>
> {% block coltype %}colMS{% endblock %}
>
> {% block bodyclass %}{% endblock %}
>
> {% block breadcrumbs %}{% endblock %}
>
> {% block content %}
> 
>
> {% if app_list %}
>    {% for app in app_list %}
>        
>        
>        {%
> blocktrans with app.name as name %}{{ name }}{% endblocktrans %} caption>
>        {% for model in app.models %}
>            
>            {% if model.perms.change %}
>                 href="{{ model.admin_url }}">{{ model.name }}
>            {% else %}
>                {{ model.name }}
>            {% endif %}
>
>            {% if model.perms.add %}
>                 class="addlink">{% trans 'Add' %}
>            {% else %}
>                
>            {% endif %}
>
>            {% if model.perms.change %}
>                 class="changelink">{% trans 'Change' %}
>            {% else %}
>                
>            {% endif %}
>            
>        {% endfor %}
>        Export-to-
> CSV
>                
>        
>    {% endfor %}
> {% else %}
>    {% trans "You don't have permission to edit anything." %}
> {% endif %}
> 
> {% endblock %}
>
> {% block sidebar %}
> 
>    
>        {% trans 'Recent Actions' %}
>        {% trans 'My Actions' %}
>            {% load log %}
>            {% get_admin_log 10 as admin_log for_user user %}
>            {% if not admin_log %}
>            {% trans 'None available' %}
>            {% else %}
>            
>            {% for entry in admin_log %}
>            {% if not entry.is_deletion %} href="{{ entry.get_admin_url }}">{% endif %}{{ entry.object_repr|
> escape }}{% if not entry.is_deletion %}{% endif %} class="mini quiet">{% filter capfirst %}{% trans
> entry.content_type.name %}{% endfilter %}
>            {% endfor %}
>            
>            {% endif %}
>    
> 
> {% endblock %}
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Using ForeignKey with dJango and PyAMF

2010-02-08 Thread Vasil Vangelovski
There's a bug in PyAMF: http://dev.pyamf.org/ticket/694


On Mon, Feb 8, 2010 at 5:54 PM, WC  wrote:
> Hi Everyone,
>
> I have a ForeignKey field that is always null on the Flex client.  I
> have tried using select_related(), but it's still null.  Any idea what
> I am doing wrong?  In the following sample code, parentBlock is always
> null on the Flex client:
>
> File: BlockVO.py
> from django.db import models
>
> class Block(models.Model):
>    blockName = models.CharField(max_length=200)
>    blockLabel = models.CharField(max_length=200)
>    blockColor = models.PositiveIntegerField()
>    xBlockPos = models.IntegerField()
>    yBlockPos = models.IntegerField()
>    parentConnectionType = models.CharField(max_length=200,
> blank=True, null=True)
>    parentBlock = models.ForeignKey('self', blank=True, null=True)
>    def __unicode__(self):
>        return self.blockLabel
>
> File gateway.py
> # To get all Blocks
> def getBlocks():
>    return Block.objects.all().select_related()
>
> File page.as
>       private function onResult_blocks(data:Object):void {
>                var answer : Array = ArrayUtil.toArray(data);
>                trace("Server returned " + answer.length.toString() + "
> block(s)");
>                        for each (var item:BlockVO in answer) {
>                                if(null == item.parentBlock) {
>                                        trace("for bloc id=" + item.id + 
> "parentBlock is null");
>                                } else {
>                                        trace("for bloc id=" + item.id + 
> "parentBlock_id=" +
> item.parentBlock.id);
>                                }
>                        var newBlock : Block = new Block(workspace, false,
> item.blockLabel, 0x66FF66, BlockSpec.REPORTER, null, item);
>                                blocks.push(newBlock);
>                                addChild(newBlock);
>                        }
>        }
>
> --
> 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 to define DJANGO_SETTINGS_MODULE for multiple sites.

2010-02-08 Thread neridaj
I'm trying to setup my first cron job and I think the reason my script
is not running is because I don't have DJANGO_SETTINGS_MODULE defined
for my environment i.e., .profile script. I'm using mod_wsgi so my
DJANGO_SETTINGS_MODULE is defined in the respective wsgi file for each
site, so my question is how do I setup a crontab that imports the
correct settings module? I tried this but no luck:

* * * * * django-admin.py shell --settings=sitename.settings /home/
username/cron/syncr.py >> /home/username/croninfo.txt

Thanks,

Jason

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



specifying the pk for an insert

2010-02-08 Thread felix
Hello -

I'm migrating a large site (mysql/php to postgres/django) and would
like to keep the primary ID of one of the tables.  The id is public as
in people call other people on the phone and say "hey what about that
#9843 ?"  all the code already refers to the ID for URLs etc.

I'm thinking that I can write an alternate save / save_base for this
one-time import. It would allow me to set the pk, call this method and
still do an insert, passing the AutoField and pk to the values list of
fields to manager._insert(values, return_id=update_pk, using=using)

Q for any postgres Gods:  should I remove the default:
nextval('nsproperties_apt_id_seq'::regclass) and re-install it
afterwards ?

probably it won't get called anyway.  after the import I can probably
step it until its where it should be:

SELECT nextval('nsproperties_apt_id_seq') ;

any thoughts, experiences or hints much appreciated.

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Possible bug with django 1.2, postgresql and aggregates?

2010-02-08 Thread Russell Keith-Magee
On Tue, Feb 9, 2010 at 2:08 AM, Mathieu Pillard  wrote:
>> It may indeed be that the MAX clause is using "mat_foo" instead of the
>> assigned correlation U0. What happens if you paste the two SQLs into a
>> query window in PgAdmin 3 and execute them. If the 1.2 query fails
>> with the same error message, I'd report a bug.
>>
>> If it doesn't fail, it's still a Django issue, but I have no idea what
>> it could be. I'm very new to Django; not new to databases.
>
> Ah, I forgot to mention: it does fail when copy/pasting the query
> django 1.2 generated in psql/pgadmin.
>
> I'm not very familiar with postgres and complex queries like this (and
> I suspect there is a better way of doing what I'm doing) ; it's
> obvious the difference between the 2 queries is what's causing my
> problem, but I have no idea *why*, therefore I haven't reported the
> bug yet. An explanation from a django wizard or a psql ninja would be
> great :-)

>From a Django API perspective, I can't see anything obviously wrong
with your query. Looks like you've found a bug. The fact that the
query rolls out differently between 1.1 and 1.2 is cause for concern.

I have a vague recollection that I've seen something simliar to this
reported recently in Trac, but I can't put my finger on the ticket
number. Please have a quick search around Trac to see if you can find
anything (the ticket should be in the 11000+ range). If you can't,
please open a new ticket and mark it for Milestone 1.2, ORM component.

Thanks,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Grouping and returning latest of each group?

2010-02-08 Thread Streamweaver
I think really I'm better off redesigning my model structure for
this.  Even trying to do it in pure SQL or with the extra attribute
it's ungodly messy.  What I really need is a Ticket model and a
TicketHistory model.  Keep the most rescent ticket information in
Ticket and versions of tickets in TicketHistory as they change.

Sorry to have floated this here.

On Feb 8, 5:22 pm, Streamweaver  wrote:
> I have a model called 'Ticket' with several fields 'number',
> 'milestone', 'status', 'resolution', 'estimate', 'last_updated'
>
> These are just multiple entries for the same support ticket that I'm
> pulling from another system.  I keep multiple entries of a ticket so I
> can trac changes in estimation and so forth over time.
>
> functionally though what I'll want to do most often is bring by the
> more recent ticket (by last_updated) of each unique 'number'
>
> In SQL I'd normally do this by a sort and a group by but I can't seem
> to figure out how to do it in Django effectively.
>
> Has anyone done anything like this previously?

-- 
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 setup multiple django domains under Apache and Ubuntu server???

2010-02-08 Thread Graham Dumpleton
Do you have appropriate NameVirtualHost directive anywhere in your
Apache configuration? This must match pattern used by VirtualHost
definitions. You would also normally use '*:80' and not just '*'.
Thus:

  NameVirtualHost *:80

  
  ..
  

  
  ..
  

Graham

On Feb 9, 11:57 am, WeissBlitz  wrote:
> Hello all!
>
> I setup an Ubuntu Server 9.04 running Apache c2.2.11 and Django v1.2.
>
> I basically have two sites installed using WSGI.
> While under development I'm using the following domain names for the
> sites:
> articlehub.dnsalias.com and jobsbot.gotdns.com, both pointing to my
> home IP.
>
> So I created 2 Apache VirtualServers, one for each.
> The first site (articlehub.dnsalias.com) shows fine in the browser
> (Firefox).
> But then enter the jobsbot.dyndns.com, I get the first site
> (articlehub.dnsalias.com) instead.
> I suspect something on my Apache virtual server or my WSGI setup is
> not right and Apache
> only see the first website.
>
> The first site settings are as follows:
>
> Location: /usr/local/djangosites/articlehub
>
> Apache config file (etc/apache2/sites-available/dnsalias.com.conf):
> 
> ServerName articlehub.dnsalias.com
>
> WSGIScriptAlias / /usr/local/djangosites/articlehub/apache/django.wsgi
> WSGIProcessGroup articlehub
> WSGIDaemonProcess articlehub user=www-data group=www-data threads=25
>
> 
>     Order deny,allow
>     Allow from all
> 
>
> Alias /static/ "/usr/local/djangosites/articlehub/static/"
> 
>     SetHandler None
> 
>
> Alias /admin/media/ "/var/lib/python-support/python2.6/django/contrib/
> admin/media/"
> Alias /media/ "/var/lib/python-support/python2.6/django/contrib/admin/
> media/"
>
>  media">
>     Order allow,deny
>     Allow from all
> 
>
> LogLevel notice
> ErrorLog /usr/local/djangosites/articlehub/logs/error.log
> CustomLog /usr/local/djangosites/articlehub/logs/access.log "combined"
> 
>
> The /usr/local/djangosites/articlehub/apache/django.wsgi is as
> follows:
>
> import os
> import sys
>
> sys.path.insert(0, '/usr/local/djangosites')
> sys.path.insert(0, '/usr/local/djangosites/articlehub')
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'articlehub.settings'
>
> # redirect sys.stdout to sys.stderr for bad libraries like geopy that
> uses
> # print statements for optional import exceptions.
> sys.stdout = sys.stderr
>
> from django.core.handlers.wsgi import WSGIHandler
> application = WSGIHandler()
>
> =
>
> Now the second site Apache virtual host file is (etc/apache2/sites-
> available/gotdns.com.conf):
> 
> ServerName jobsbot.gotdns.com
>
> WSGIScriptAlias / /usr/local/djangosites/jobsbot/apache/django.wsgi
> WSGIProcessGroup jobsbot
> WSGIDaemonProcess jobsbot user=www-data group=www-data threads=25
>
> 
>     Order deny,allow
>     Allow from all
> 
>
> Alias /static/ "/usr/local/djangosites/jobsbot/static/"
> 
>     SetHandler None
> 
>
> Alias /admin/media/ "/var/lib/python-support/python2.6/django/contrib/
> admin/media/"
> Alias /media/ "/var/lib/python-support/python2.6/django/contrib/admin/
> media/"
>
>  media">
>     Order allow,deny
>     Allow from all
> 
>
> LogLevel notice
> ErrorLog /usr/local/djangosites/jobsbot/logs/error.log
> CustomLog /usr/local/djangosites/jobsbot/logs/access.log "combined"
> 
>
> And WSGI script reads (usr/local/djangosites/jobsbot/apache/
> django.wsgi):
>
> import os
> import sys
>
> sys.path.insert(0, '/usr/local/djangosites')
> sys.path.insert(0, '/usr/local/djangosites/jobsbot')
>
> #sys.path.insert(0, '/home/www/freearticlerepository.com')
> #sys.path.insert(0, '/home/www/freearticlerepository.com/articlehub')
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'jobsbot.settings'
>
> # redirect sys.stdout to sys.stderr for bad libraries like geopy that
> uses
> # print statements for optional import exceptions.
> sys.stdout = sys.stderr
>
> from django.core.handlers.wsgi import WSGIHandler
> application = WSGIHandler()
>
> Please let me know if you need any additional setup information.
> I would greatly appreciate if somebody could point me up to what the
> problem is.
>
> Thanks in advance,
> Carlos

-- 
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 setup multiple django domains under Apache and Ubuntu server???

2010-02-08 Thread WeissBlitz
Hello all!

I setup an Ubuntu Server 9.04 running Apache c2.2.11 and Django v1.2.

I basically have two sites installed using WSGI.
While under development I'm using the following domain names for the
sites:
articlehub.dnsalias.com and jobsbot.gotdns.com, both pointing to my
home IP.

So I created 2 Apache VirtualServers, one for each.
The first site (articlehub.dnsalias.com) shows fine in the browser
(Firefox).
But then enter the jobsbot.dyndns.com, I get the first site
(articlehub.dnsalias.com) instead.
I suspect something on my Apache virtual server or my WSGI setup is
not right and Apache
only see the first website.

The first site settings are as follows:

Location: /usr/local/djangosites/articlehub

Apache config file (etc/apache2/sites-available/dnsalias.com.conf):

ServerName articlehub.dnsalias.com

WSGIScriptAlias / /usr/local/djangosites/articlehub/apache/django.wsgi
WSGIProcessGroup articlehub
WSGIDaemonProcess articlehub user=www-data group=www-data threads=25


Order deny,allow
Allow from all


Alias /static/ "/usr/local/djangosites/articlehub/static/"

SetHandler None


Alias /admin/media/ "/var/lib/python-support/python2.6/django/contrib/
admin/media/"
Alias /media/ "/var/lib/python-support/python2.6/django/contrib/admin/
media/"


Order allow,deny
Allow from all


LogLevel notice
ErrorLog /usr/local/djangosites/articlehub/logs/error.log
CustomLog /usr/local/djangosites/articlehub/logs/access.log "combined"


The /usr/local/djangosites/articlehub/apache/django.wsgi is as
follows:

import os
import sys

sys.path.insert(0, '/usr/local/djangosites')
sys.path.insert(0, '/usr/local/djangosites/articlehub')

os.environ['DJANGO_SETTINGS_MODULE'] = 'articlehub.settings'

# redirect sys.stdout to sys.stderr for bad libraries like geopy that
uses
# print statements for optional import exceptions.
sys.stdout = sys.stderr

from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()

=

Now the second site Apache virtual host file is (etc/apache2/sites-
available/gotdns.com.conf):

ServerName jobsbot.gotdns.com

WSGIScriptAlias / /usr/local/djangosites/jobsbot/apache/django.wsgi
WSGIProcessGroup jobsbot
WSGIDaemonProcess jobsbot user=www-data group=www-data threads=25


Order deny,allow
Allow from all


Alias /static/ "/usr/local/djangosites/jobsbot/static/"

SetHandler None


Alias /admin/media/ "/var/lib/python-support/python2.6/django/contrib/
admin/media/"
Alias /media/ "/var/lib/python-support/python2.6/django/contrib/admin/
media/"


Order allow,deny
Allow from all


LogLevel notice
ErrorLog /usr/local/djangosites/jobsbot/logs/error.log
CustomLog /usr/local/djangosites/jobsbot/logs/access.log "combined"


And WSGI script reads (usr/local/djangosites/jobsbot/apache/
django.wsgi):

import os
import sys

sys.path.insert(0, '/usr/local/djangosites')
sys.path.insert(0, '/usr/local/djangosites/jobsbot')

#sys.path.insert(0, '/home/www/freearticlerepository.com')
#sys.path.insert(0, '/home/www/freearticlerepository.com/articlehub')

os.environ['DJANGO_SETTINGS_MODULE'] = 'jobsbot.settings'

# redirect sys.stdout to sys.stderr for bad libraries like geopy that
uses
# print statements for optional import exceptions.
sys.stdout = sys.stderr

from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()

Please let me know if you need any additional setup information.
I would greatly appreciate if somebody could point me up to what the
problem is.

Thanks in advance,
Carlos

-- 
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: sqlite3 gives "OperationalError: no such table: django_redirect"

2010-02-08 Thread Phlip
> It appears you have not run manage.py syncdb after adding
> 'django.contrib.redirects' to INSTALLED_APPS.
>
> Karen

Ah, I don't know if I have that in there yet (yes, it's hard to
check), but I DO have this...

   'django.contrib.redirects.middleware.RedirectFallbackMiddleware'

...in test_settings.py. (You see I'm always all about the test;)

So I'll comment it out and see if the rate of hitting that bug goes
down... 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: Page not found for password_reset_confirm

2010-02-08 Thread Sonal Breed
Thanks Shawn. I put the name of the production site instead of the
local test site, hence the page not found error. :(

Thanks again for your help,

Thanks,
Sincerely,
Sonal.

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



What's the latest on compound and nested forms?

2010-02-08 Thread Philip Zeyliger
Hi folks,

I'm curious how people are managing complex forms in their django
applications these days.  As an example, let's say we're editing an address
book entry, where someone can have multiple e-mail addresses and phone
numbers.  Ideally, I'd want to do something like:

class AddressBookEntry(Form):
  first_name = forms.CharField()
  last_name = forms.CharField()
  phone_numbers = forms.MultiField(forms.CharField())
  email_addresses = forms.MultiField(forms.EmailAddressField())
  addresses = forms.MultiField([forms.CharField(name="line1"),
forms.CharField(name="line2"), forms.CharField("city"), ...])

Of course, I'd need some JavaScript to manage adding and removing the actual
HTML  fields.

That's theoretical; how are people actually doing this?  Using multiple Form
objects and formsets (one formset each for phone numbers and addresses)?
 Processing the form manually?  Writing custom fields and widgets that
understand multi-valued entries?  Using a different forms package?
 Something else?

Cheers,

-- Philip

-- 
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: Named urls and urlconf includes are incompatible

2010-02-08 Thread adambossy
Bingo. The value should have been invitation_key and not
invitation_key.key. Good catch!


On Feb 8, 3:41 pm, Karen Tracey  wrote:
> On Mon, Feb 8, 2010 at 6:24 PM, adambossy  wrote:
> > I'm trying to install the django-invitation app on bitbucket, but I'm
> > running into an error I've been seeing repeatedly with urls. I've
> > googled this and various permutations have occurred to various people,
> > but not this one in particular. The general problem occurs when I try
> > to include a url configuration:
>
> > ...
> > urlpatterns += patterns('',
> >        (r'^accounts/',
>
> > include('invitation.urls')),
> > )
> > ...
>
> > This is the included urls file, located in /myproject/invitation:
>
> >http://dpaste.com/156349/
>
> > And the error I receive is a NoReverseMatch in my template:
>
> >http://dpaste.com/156350/
>
> This does not appear to have anything to do with including url patterns,
> it's a straightforward mismatch of the pattern and provided arguments.
>
> The {% url %} tag in the template is:
>
> {% url invitation_invited invitation_key=invitation_key.key %}
>
> The pattern for invitation_invited is:
>
> url(r'^invited/(?P\w+)/
>
> The NoReverseMatch exception states:
>
> NoReverseMatch: Reverse for 'djroot.invitation_invited' with arguments '()'
> and keyword arguments '{'invitation_key': ''}' not found.
>
> The invitation_key value is shown as an empty string. This is not allowed by
> the pattern, which requires one or more alphanumeric characters (\w is
> alphanumeric, + is one or more) in invitation_key. Therefore no reverse
> match is found.
>
> Are you sure invitation_key.key is the correct value for invitation_key in
> the {% url %} tag?
>
> Karen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: sqlite3 gives "OperationalError: no such table: django_redirect"

2010-02-08 Thread Karen Tracey
On Mon, Feb 8, 2010 at 6:56 PM, Phlip  wrote:

> > It appears you have not run manage.py syncdb after adding
> > 'django.contrib.redirects' to INSTALLED_APPS.
>
> Even when testing into sqlite3 :memory:? I thought that obviated all
> syncdb considerations...
>
>
No, for tests if the app is listed in INSTALLED_APPS then the table should
be getting created by the test setup automatically. You confused me by
mentioning "test " but then pointing to an actual live site to demonstrate
the error. So I figured you weren't really referring to Django TestCase type
tests but rather a development/test setup, and answered what appeared to be
the problem with the live site. I have no idea why the table would not be
getting created correctly during Django test setup.

Karen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: sqlite3 gives "OperationalError: no such table: django_redirect"

2010-02-08 Thread Phlip
> It appears you have not run manage.py syncdb after adding
> 'django.contrib.redirects' to INSTALLED_APPS.

Even when testing into sqlite3 :memory:? I thought that obviated all
syncdb considerations...

-- 
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: Named urls and urlconf includes are incompatible

2010-02-08 Thread Karen Tracey
On Mon, Feb 8, 2010 at 6:24 PM, adambossy  wrote:

> I'm trying to install the django-invitation app on bitbucket, but I'm
> running into an error I've been seeing repeatedly with urls. I've
> googled this and various permutations have occurred to various people,
> but not this one in particular. The general problem occurs when I try
> to include a url configuration:
>
> ...
> urlpatterns += patterns('',
>(r'^accounts/',
>
> include('invitation.urls')),
> )
> ...
>
> This is the included urls file, located in /myproject/invitation:
>
> http://dpaste.com/156349/
>
> And the error I receive is a NoReverseMatch in my template:
>
> http://dpaste.com/156350/
>
>
This does not appear to have anything to do with including url patterns,
it's a straightforward mismatch of the pattern and provided arguments.

The {% url %} tag in the template is:

{% url invitation_invited invitation_key=invitation_key.key %}

The pattern for invitation_invited is:

url(r'^invited/(?P\w+)/

The NoReverseMatch exception states:

NoReverseMatch: Reverse for 'djroot.invitation_invited' with arguments '()'
and keyword arguments '{'invitation_key': ''}' not found.

The invitation_key value is shown as an empty string. This is not allowed by
the pattern, which requires one or more alphanumeric characters (\w is
alphanumeric, + is one or more) in invitation_key. Therefore no reverse
match is found.

Are you sure invitation_key.key is the correct value for invitation_key in
the {% url %} tag?

Karen

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

2010-02-08 Thread Shawn Milochik
Check the actual URL you're receiving in your e-mail. See if it matches any of 
the patterns in your urls.py.

One thing that looks odd to me is that your pattern for forgot-password ends 
with '?$," which doesn't look right to me. But it seems like you're saying the 
problem is after that point. In any case, make sure the URL received in the 
e-mail matches a pattern -- it must not for you to be getting this error.

Shawn

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



Named urls and urlconf includes are incompatible

2010-02-08 Thread adambossy
I'm trying to install the django-invitation app on bitbucket, but I'm
running into an error I've been seeing repeatedly with urls. I've
googled this and various permutations have occurred to various people,
but not this one in particular. The general problem occurs when I try
to include a url configuration:

...
urlpatterns += patterns('',
(r'^accounts/',

include('invitation.urls')),
)
...

This is the included urls file, located in /myproject/invitation:

http://dpaste.com/156349/

And the error I receive is a NoReverseMatch in my template:

http://dpaste.com/156350/

If I open the shell and import django.core.urlresolvers.reverse, the
error still occurs. Since "invitation_invite" (one of the other
included urls) works, however, I don't believe it's due to stale pyc
files. Any ideas?

I'm running django v1.0.

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

2010-02-08 Thread Sonal Breed
Thanks Shawn!

After changing the domain name in admin, I could get the subject
right. however, the page not found problem still persists.
I have provided my urls.py earlier. And I have the following files in
the directory mentioned in TEMPLATE_DIRS setting.

registration/password_reset_complete.html
registration/password_reset_confirm.html
registration/password_reset_done.html
registration/password_reset_email.html
registration/password_reset_complete.html
registration/password_reset_form.html

password_reset_email has following:

{{ protocol }}://mygoplanner.com{% url
django.contrib.auth.views.password_reset_confirm uidb36=uid,
token=token %}

 

Am I missing anything?

Thanks,
Sincerely,
Sonal.

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

2010-02-08 Thread Shawn Milochik
Go into the admin and edit the entry in the Sites application for your site. 
It's using example.com as a placeholder.

Shawn

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



Page not found for password_reset_confirm

2010-02-08 Thread Sonal Breed
Hi all,

I am implementing "Forgot your password" feature using following
tutorial.

http://www.rkblog.rk.edu.pl/w/p/password-reset-django-10/

My email for password gets sent. but once I click the URL in the mail
get page not found error.

My urls.py is

urlpatterns += patterns('django.contrib.auth.views',
  (r'^forgot-password/?$', 'password_reset'),
  (r'^password_reset/done/$', 'password_reset_done'),
  (r'^reset/(?P[0-9A-Za-z]+)-(?P.+)/$',
'password_reset_confirm'),
  (r'^reset/done/$', 'password_reset_complete'),
)

Why cannot it find the generated URL.
Also, I want to know how one changes the subject of the generated
mail. I get "Password reset on example.com"  as my subject.

Thanks,
Sincerely,
Sonal.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: sqlite3 gives "OperationalError: no such table: django_redirect"

2010-02-08 Thread Karen Tracey
On Mon, Feb 8, 2010 at 4:51 PM, Phlip  wrote:

> Djangoids:
>
> I get this error message whenever I really need client.get() to run,
> in a test. Different apps and configurations show the problem in
> various situations.
>
> The only Google hit for the error message with sqlite3 is some lone
> webpage dumping the problem. Get the full trace there!
>
>  http://www.pylucid.de/root/index.html
>
>
It appears you have not run manage.py syncdb after adding
'django.contrib.redirects' to INSTALLED_APPS.

Karen

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

2010-02-08 Thread Karen Tracey
On Mon, Feb 8, 2010 at 4:06 PM, adambossy  wrote:

> Hey folks, thanks for the responses. Your questions alone helped me
> find the answer. Apparently, it was a problem with my apache2
> configuration. I basically copied the directives from the django
> website, with one small modification:
>
>
> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#basic-configuration
>
> I changed  to  so my Django project
> would be served at my site's root directory.
>
> I had to remove '/mysite' from the django.root option. My final output
> looks like this, with no value after django.root:"
>

Don't use an empty django.root, just remove it entirely.

(I'm curious why are you using mod_python instead of mod_wsgi?)

Karen

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



Grouping and returning latest of each group?

2010-02-08 Thread Streamweaver
I have a model called 'Ticket' with several fields 'number',
'milestone', 'status', 'resolution', 'estimate', 'last_updated'

These are just multiple entries for the same support ticket that I'm
pulling from another system.  I keep multiple entries of a ticket so I
can trac changes in estimation and so forth over time.

functionally though what I'll want to do most often is bring by the
more recent ticket (by last_updated) of each unique 'number'

In SQL I'd normally do this by a sort and a group by but I can't seem
to figure out how to do it in Django effectively.

Has anyone done anything like this previously?

-- 
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: Javascript Modal Window

2010-02-08 Thread Shawn Milochik
You can use a jQuery UI Dialog. It can be modal, and you can easily use some 
jQuery AJAX to submit your login view and receive the response.

Shawn

-- 
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: inputting a request.user into a model on the backend

2010-02-08 Thread goome


My previous mex got with wrong identation: the last 4 lines need to
start at the same level:

if request.method == 'POST':
 form = GoalForm(request.POST)
  if form.is_valid():
   goal=form.save(commit=False)
   goal.user=request.user
   goal.save()
   form.save_m2m()

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



sqlite3 gives "OperationalError: no such table: django_redirect"

2010-02-08 Thread Phlip
Djangoids:

I get this error message whenever I really need client.get() to run,
in a test. Different apps and configurations show the problem in
various situations.

The only Google hit for the error message with sqlite3 is some lone
webpage dumping the problem. Get the full trace there!

  http://www.pylucid.de/root/index.html

The versions are Python 2.6.4 and Django 1.0.4. Further details
available on request - I wouldn't know where to start describing our
packages & setup.

--
  Phlip
  http://penbird.tumblr.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: inputting a request.user into a model on the backend

2010-02-08 Thread goome


On 7 Feb, 22:26, kamilski81  wrote:
> I am trying to set a user on a model, on the back-end.
>
>         u = request.user
>         g = Goal()
>         g.user = u
>         form = GoalForm(request.POST, g)
>
> I am getting the following error:
> goal.user_id may not be NULL
hello
you can try with this:


if request.method == 'POST':
  form = GoalForm(request.POST)
if form.is_valid():
  goal=form.save(commit=False)
goal.user=request.user
goal.save()
#AND , if the model as #Many2Many Relationship
form.save_m2m()

I don't know why, but it seems that it is not possible to modify the
data from POST and pass them to a ModelForm constructor, but you need
first pass them to the constuctor, save it, and than modify the handle.
(and again save the m2m table is present).
i hope it 'll help
bye
marcello

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



moderation of djangosearch.com

2010-02-08 Thread Alrond
Hi all,

I am the developer of the search engine djangosearch.com. I am
supporting this project for several years. There are articles about
django for the last four years, the search is available in 10
languages.
I strictly supervise the quality of articles and news, I check all of
them myself for compliance with django subject, correction of url,
detection of language, and filtering of spam.

The list is automatically increased and also with addition of new
articles and blogs of users using the form. Today there are about 36K
links in 29 languages on the site, about 13K of which are opened and
recognized as unique.

Now I don’t have time to support the project because of the main
project WIPmania.com. Therefore, I would like to ask, if there are
people who can take over moderation of djangosearch (e.g.distributed
in different languages ??), otherwise I have to close the project.

Thanks,
Alex Aster

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



Javascript Modal Window

2010-02-08 Thread CrabbyPete
I want to use greybox to show a login form. My question is what is the
best way to do this?
Here is the line I am using in m template

Login

Should I directly link to the form, or use {% url xxx %}, or is there
something else I should do?
Also can I send it back up if I get errors? Any advice much
appreciated.

-- 
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 Mailing List Manager

2010-02-08 Thread Gonzalo Delgado
El 08/02/10 18:04, gregory.para...@gmail.com escribió:
> Does anyone know of any good email list managers in Django? Even just
> a simple app for a coming soon page that would take users email
> address and let you email them with updates would be great.
>   

You may want to take a look at Lamson[0] for building something like
that or Librelist[1] for something already built. They're not Django
apps, but they sure are Django friendly ;)

[0] http://lamsonproject.org/
[1] http://support.librelist.com/index

-- 
Gonzalo Delgado 

-- 
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: Reversed URLs problem

2010-02-08 Thread adambossy
Hey folks, thanks for the responses. Your questions alone helped me
find the answer. Apparently, it was a problem with my apache2
configuration. I basically copied the directives from the django
website, with one small modification:

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#basic-configuration

I changed  to  so my Django project
would be served at my site's root directory.

I had to remove '/mysite' from the django.root option. My final output
looks like this, with no value after django.root:"


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root
PythonDebug On


For the record, I am running:

Django 1.0
Apache 2.2
mod_python 3.3.1 (i think... :))
Ubuntu Hardy 8.04.4


On Feb 7, 5:55 am, Karen Tracey  wrote:
> On Sun, Feb 7, 2010 at 4:12 AM, Daniel Roseman wrote:
>
> > If all URLs work both with and without a prefix, it would seem that
> > you've somehow duplicated your URL definitions somewhere. Could you
> > post your entire urls.py? Preferably somewhere like dpaste.com.
>
> Also some information about deployment environment might be illuminating.
>  If not the dev server, what exactly, and what sort of config have you set
> up for it?
>
> Karen

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

2010-02-08 Thread gregory.para...@gmail.com
Does anyone know of any good email list managers in Django? Even just
a simple app for a coming soon page that would take users email
address and let you email them with updates would be great.

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



Re: MySQL-python 1.2.3 and OS X 10.5: 64- or 32-bit?

2010-02-08 Thread monchi
Dave,

Just wondering how you managed to get Django and MySQL to work on
Leopard 10.5.

I've spent 2 days on it and still stuck on the same error - described
here:
http://groups.google.com/group/django-users/browse_thread/thread/178bd307b9551e2b#

Which versions of Python, MySQL and MySQLdb do you have?
How can I check if I have the 32-bit or the 64-bit installs?

Hope you can share some of your experiences.
Thanks.

On Jan 24, 3:59 pm, Dave E  wrote:
> Update: removed 64-bit MySQL, installed 32-bit version from package,
> re-installed MySQL-python after removing with easy_install -m (which
> now also removes the line in easy-install.pth). >>>import MySQLbd is
> okay. Got warning so will see if okay.

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



creative commons london based django project - secretlondon - team needed

2010-02-08 Thread timjdavey
Hi there,

Fancy joining a great team on a django community project?
http://eu.techcrunch.com/2010/02/07/startup-to-launch-after-secret-london-facebook-group-amasses-18/

We'll be hosting a dev session this weekend - in a location somewhere
in london. We have some great designers, a few css/js people. However,
I'm struggling to find a host of django people (we're just such busy
folk).

I've started an app which is hosted on github, but don't really have a
huge amount of time spare for actual development.
http://github.com/timjdavey/secretapp

Anyone who wants in get in touch. Its better if you're in london,
because we have a serious ttl problem, however if you're a django king
and work well remotely then join in.

Cheers!
Tim

ps. sorry to spam this group with non django specific queries!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Possible bug with django 1.2, postgresql and aggregates?

2010-02-08 Thread Mathieu Pillard
> It may indeed be that the MAX clause is using "mat_foo" instead of the
> assigned correlation U0. What happens if you paste the two SQLs into a
> query window in PgAdmin 3 and execute them. If the 1.2 query fails
> with the same error message, I'd report a bug.
>
> If it doesn't fail, it's still a Django issue, but I have no idea what
> it could be. I'm very new to Django; not new to databases.

Ah, I forgot to mention: it does fail when copy/pasting the query
django 1.2 generated in psql/pgadmin.

I'm not very familiar with postgres and complex queries like this (and
I suspect there is a better way of doing what I'm doing) ; it's
obvious the difference between the 2 queries is what's causing my
problem, but I have no idea *why*, therefore I haven't reported the
bug yet. An explanation from a django wizard or a psql ninja would be
great :-)

-- 
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: Possible bug with django 1.2, postgresql and aggregates?

2010-02-08 Thread Brian
It may indeed be that the MAX clause is using "mat_foo" instead of the
assigned correlation U0. What happens if you paste the two SQLs into a
query window in PgAdmin 3 and execute them. If the 1.2 query fails
with the same error message, I'd report a bug.

If it doesn't fail, it's still a Django issue, but I have no idea what
it could be. I'm very new to Django; not new to databases.

Brian

On Feb 8, 9:32 am, Mathieu Pillard  wrote:
> Hi,
>
> I have been testing the 1.2 beta1 and think I found a bug, but since
> the query I'm using is a bit complicated I wanted to run it through
> the list first.
>
> The model I'm using:
>
> from django.db import models
> from django.contrib.auth.models import User
>
> class Foo(models.Model):
>     subject = models.CharField(max_length=120)
>     sender = models.ForeignKey(User, related_name='sent_foo')
>     recipient = models.ForeignKey(User, related_name='received_foo')
>     conversation = models.ForeignKey('self', null=True, blank=True)
>
> It's a basic messaging system, in which you can group messages by
> conversations : when saving a new Foo object, you can give it an
> existing Foo id to form a conversation. I want to display the "inbox"
> for a user, which should be a list with the last message from each
> conversation. The following code works in 1.1:
>
> from django.db.models import Max
>
> def conversations(self, user):
>     tmp = 
> Foo.objects.values('conversation').annotate(Max('id')).values_list('id__max',
> flat=True).order_by( 'conversation')
>     return Foo.objects.filter(id__in=tmp.filter(recipient=user))
>
> However, in 1.2 beta 1, with postgresql_psycopg2, it fails with:
> DatabaseError: aggregates not allowed in WHERE clause
> LINE 1: ...d" FROM "mat_foo" WHERE "mat_foo"."id" IN (SELECT MAX("mat_f...
>
> The generated SQL queries are a bit different. Here is django 1.2:
> SELECT "mat_foo"."id", "mat_foo"."subject", "mat_foo"."sender_id",
> "mat_foo"."recipient_id", "mat_foo"."conversation_id" FROM "mat_foo"
> WHERE "mat_foo"."id" IN (SELECT MAX("mat_foo"."id") AS "id__max" FROM
> "mat_foo" U0 WHERE U0."recipient_id" = 1  GROUP BY
> U0."conversation_id")
>
> And here is django 1.1:
> SELECT "mat_foo"."id", "mat_foo"."subject", "mat_foo"."sender_id",
> "mat_foo"."recipient_id", "mat_foo"."conversation_id" FROM "mat_foo"
> WHERE "mat_foo"."id" IN (SELECT MAX(U0."id") AS "id__max" FROM
> "mat_foo" U0 WHERE U0."recipient_id" = 1  GROUP BY
> U0."conversation_id")
>
> The only difference is in the MAX() clause. Anyone can enlighten me
> about what's happening ? Is that a (known?) django 1.2 bug or am I
> pushing the ORM a little too far? It looks like sqlite doesn't
> complain with the same code, but I didn't test if the results were
> right.
>
> 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: Using ForeignKey with dJango and PyAMF

2010-02-08 Thread WC
By the way, all I really need is the parentBlock_id.

On Feb 8, 11:54 am, WC  wrote:
> Hi Everyone,
>
> I have a ForeignKey field that is always null on the Flex client.  I
> have tried using select_related(), but it's still null.  Any idea what
> I am doing wrong?  In the following sample code, parentBlock is always
> null on the Flex client:
>
> File: BlockVO.py
> from django.db import models
>
> class Block(models.Model):
>     blockName = models.CharField(max_length=200)
>     blockLabel = models.CharField(max_length=200)
>     blockColor = models.PositiveIntegerField()
>     xBlockPos = models.IntegerField()
>     yBlockPos = models.IntegerField()
>     parentConnectionType = models.CharField(max_length=200,
> blank=True, null=True)
>     parentBlock = models.ForeignKey('self', blank=True, null=True)
>     def __unicode__(self):
>         return self.blockLabel
>
> File gateway.py
> # To get all Blocks
> def getBlocks():
>     return Block.objects.all().select_related()
>
> File page.as
>        private function onResult_blocks(data:Object):void {
>                 var answer : Array = ArrayUtil.toArray(data);
>                 trace("Server returned " + answer.length.toString() + "
> block(s)");
>                         for each (var item:BlockVO in answer) {
>                                 if(null == item.parentBlock) {
>                                         trace("for bloc id=" + item.id + 
> "parentBlock is null");
>                                 } else {
>                                         trace("for bloc id=" + item.id + 
> "parentBlock_id=" +
> item.parentBlock.id);
>                                 }
>                         var newBlock : Block = new Block(workspace, false,
> item.blockLabel, 0x66FF66, BlockSpec.REPORTER, null, item);
>                                 blocks.push(newBlock);
>                                 addChild(newBlock);
>                         }
>         }

-- 
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: No module named urls

2010-02-08 Thread Brian
Aaargh! I knew it had to be something like that!

Thanx Karen.

On Feb 7, 5:20 pm, Karen Tracey  wrote:
> On Sun, Feb 7, 2010 at 4:27 PM, Brian  wrote:
> > Hi all,
>
> > I'm putting together a Django application from scratch and have
> > created my models. I'm trying to activate the admin site now and am
> > getting the above error. I've tried everything I found on mailing
> > lists with no luck. This includes the old style settings.py (which is
> > commented out now) as well as the new. Note, the model has synced to
> > the database correctly.
>
> > Here is the contents of the admin.py file which resides in my app
> > directory (triagedb/triagedb_app):
>
> > [snip]
> > Here is my settings file:
> > [snip]
>
> > ROOT_URLCONF = 'triagedb_app.urls'
>
> > [snip]
>
> > INSTALLED_APPS = (
> >    #'django.contrib.auth',
> >    #'django.contrib.contenttypes',
> >    'django.contrib.sessions',
> >    'django.contrib.sites',
> >    'django.contrib.admin',
> >    'triagedb.triagedb_app',
> > )
>
> > Here is my urls..py file:
> > [snip]
>
> The urls.py file you show looks like it is a base project urls.py file,
> auto-created perhaps when you ran django-admin.py startproject triagedb.
> That file would have been place in triagedb/urls.py. Yet your ROOT_URLCONF
> settings is ''triagedb_app.urls", which will be looking to load
> triagedb_app/urls.py from somewhere in the Python path. Where exactly is
> this urls.py file located?  If it is really in triagedb/urls.py then the
> URLCONF setting should be 'triagedb.urls'.
>
> Karen

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



Django 1.1.1 + mod_python = base.css was swallowed in admin pages

2010-02-08 Thread Andrew Budarevsky
Hello All,

I am trying to get my admin pages work but failed. I have several
django apps on the same hosting. For the latest I dopped in the latest
brand new django 1.1.1 and mentioned it via PythonPath directive.
Everything works but admin pages - they miss link to base.css.
-- settings.py 
ADMIN_MEDIA_PREFIX = '/adminmedia/'
 link to fresh django admin ---
19:10 adminmedia -> /home/g/grifoncons/django_projects/django-latest/
django/contrib/admin/media/
-- .htaccess -
RewriteEngine on

RewriteRule ^/media/(.*)$ /media/$1 [QSA,L,PT]
RewriteRule ^/static/(.*)$ /static/$1 [QSA,L,PT]

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE shoeshop.settings
# PythonOption django.root backoffice/
PythonInterpreter bridgidda-cp
PythonPath "['/home/g/grifoncons/django_projects/django-latest/
django/','/home/g/grifoncons/django_projects/','/home/g/grifoncons/
django_projects/shoeshop','/home/g/grifoncons/django_projects/shoeshop/
backoffice']+sys.path"
PythonDebug On

Options +FollowSymLinks


- generated admin page --

http://www.w3.org/1999/xhtml; lang="ru-ru" xml:lang="ru-
ru" >

Администрирование сайта | Административный сайт Django

--

What I missed?  I am really stucked... I also tried the latest svn
version with the same result. My previous applications use django 1.0
placed at hosting and copied admin/media content into web root of the
application works well.

Andrew

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



Possible bug with django 1.2, postgresql and aggregates?

2010-02-08 Thread Mathieu Pillard
Hi,

I have been testing the 1.2 beta1 and think I found a bug, but since
the query I'm using is a bit complicated I wanted to run it through
the list first.

The model I'm using:

from django.db import models
from django.contrib.auth.models import User

class Foo(models.Model):
subject = models.CharField(max_length=120)
sender = models.ForeignKey(User, related_name='sent_foo')
recipient = models.ForeignKey(User, related_name='received_foo')
conversation = models.ForeignKey('self', null=True, blank=True)

It's a basic messaging system, in which you can group messages by
conversations : when saving a new Foo object, you can give it an
existing Foo id to form a conversation. I want to display the "inbox"
for a user, which should be a list with the last message from each
conversation. The following code works in 1.1:

from django.db.models import Max

def conversations(self, user):
tmp = 
Foo.objects.values('conversation').annotate(Max('id')).values_list('id__max',
flat=True).order_by( 'conversation')
return Foo.objects.filter(id__in=tmp.filter(recipient=user))

However, in 1.2 beta 1, with postgresql_psycopg2, it fails with:
DatabaseError: aggregates not allowed in WHERE clause
LINE 1: ...d" FROM "mat_foo" WHERE "mat_foo"."id" IN (SELECT MAX("mat_f...

The generated SQL queries are a bit different. Here is django 1.2:
SELECT "mat_foo"."id", "mat_foo"."subject", "mat_foo"."sender_id",
"mat_foo"."recipient_id", "mat_foo"."conversation_id" FROM "mat_foo"
WHERE "mat_foo"."id" IN (SELECT MAX("mat_foo"."id") AS "id__max" FROM
"mat_foo" U0 WHERE U0."recipient_id" = 1  GROUP BY
U0."conversation_id")

And here is django 1.1:
SELECT "mat_foo"."id", "mat_foo"."subject", "mat_foo"."sender_id",
"mat_foo"."recipient_id", "mat_foo"."conversation_id" FROM "mat_foo"
WHERE "mat_foo"."id" IN (SELECT MAX(U0."id") AS "id__max" FROM
"mat_foo" U0 WHERE U0."recipient_id" = 1  GROUP BY
U0."conversation_id")

The only difference is in the MAX() clause. Anyone can enlighten me
about what's happening ? Is that a (known?) django 1.2 bug or am I
pushing the ORM a little too far? It looks like sqlite doesn't
complain with the same code, but I didn't test if the results were
right.


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: satchmo customization experiences? customizing existing e-com vs. roll-your-own

2010-02-08 Thread snfctech
Thanks for your reply, Chris.  And thanks for the links.

However, the Stack Overflow example seems to be talking about cloning
and a tendency of developers to exaggerate their ability to understand
the complexity of a piece of software and how long it would take them
to do it.  My point is not about cloning Satchmo - but trying to
understand how easily extensible it is and at what point I may as well
build my own solution, because the gap between what I need and what
Satchmo does is too great.  And, for that, you're right - I need to be
more specific.  So here a couple things I think I may need to do to
modify Satchmo:

1. Pull out a lot of e-commerce specific clutter.  I'm building
(primarily) an internal order entry and tracking system.  I don't need
shipping addresses or postal rates or a payment gateway.

2. Add a bunch of business specific stuff:
- bizarre discount rules that apply on certain days, that customers
can only use once a month or once a quarter, that can only be stacked
in strange ways, etc.
- adding lots of additional attributes/relations to products and
customers such as: upc_unit, upc_case, plu_unit, plu_case,
quantity_case, is_organic, has_redemption, measure, size, require_id,
category_id, location_id, producer_id, etc.
- product holding time/ notifications (e.g. how long we can keep
perishables vs. dry-goods before someone needs to be notified/
business process initiated)
- customer/member/product lookup by contact info, past purchases,
member number, producer order number, PLU, etc.
- a producer/mfg. schema for tracking store->producer orders, status,
modifying lead-times
- printing invoices with UPCs that can be brought to POS registers

Btw, http://djwarehouse.org gave me "Oops…Trac detected an internal
error:"  I've looked into LFS but their motto "The online shop for for
search engines, which appreciate speed" threw me off.  Plus I had to
dig into the FAQ to find the source and it broke on some dependencies
when I tried to install.

On Feb 6, 1:50 pm, Chris Moffitt  wrote:
> You may get some more answers on the Satchmo list but I assume all those
> folks are on this list too. I'll attempt to provide some answers here
> because it's probably of interest to the broader community.
>
> Whenever I hear people talking about writing something from scratch, I think
> about these two articles 
> -http://www.codinghorror.com/blog/archives/001284.htmlhttp://blog.bitquabit.com/2009/07/01/one-which-i-call-out-hacker-news/
>
> First off, I realize Satchmo is nowhere near the same as stack overflow but
> the principal is the same. Satchmo has been under active development for
> almost 3 years and it's by no means complete and nowhere near perfect. That
> being said, it does do a lot & has a lot of thought put into how to balance
> ease of use and functionality with the ability to customize. There could be
> a lot of debate about how well we've managed to do it & reasonable people
> could disagree about our approach; but there is a fairly significant amount
> of work to start from scratch. In fact, if Satchmo seems too much overkill
> for your needs, then you might want to look at some of the alternatives
> (which I have no personal experience with) 
> like:http://djwarehouse.org/wikihttp://www.getlfs.com/
>
> Or if you feel you need to write one from scratch, this is probably as good
> a place as any to start:http://django-ecommerce.blogspot.com/
>
> Now, to answer your earlier question about how to customize Satchmo, a lot
> depends on what you actually need to do. Writing a custom shipping module or
> modifying the templates is trivial. If you need to yank out the entire
> product model and use something new then it might be more of a challenge. If
> you can discuss a bit more about the changes you would need to make, we can
> probably provide some more guidance on the relative difficulty of getting
> them done.
>
> -Chris
>
> On Sat, Feb 6, 2010 at 12:57 PM, snfctech  wrote:
> > I'm building an order entry and tracking system for a Food Co-op for
> > their case and special orders.  We don't need the system to be on-line
> > (at the moment), but many of the system requirements are already
> > present in many existing e-commerce solutions (product catalog/search,
> > order entry screens, order tracking/history, etc.)
>
> > Initially, I was thinking of building the system from scratch using
> > web2py or Django.  (The RoR Spree project looks pretty interesting,
> > too - but I'm already writing a product/customer ETL in Jython and
> > don't want to balance the two languages - both Python and Ruby are new
> > to me.)  Web2py doesn't have any existing e-commerce project, so that
> > lead me to look at Django/Satchmo.  I'm guessing the Satchmo
> > customization necessary is probably on the order of 20-30%.
>
> > The question is whether that 20-30% customization is going to be more
> > of a headache than rolling my own clean order-entry and tracking

Re: Callback method on session timeout

2010-02-08 Thread Andy McKay

On 2010-02-06, at 4:08 PM, adamjamesdrew wrote:

> Does django have the ability to do a callback when a session time out
> occurs?

No, there is no session time out. Its just that a session isn't valid anymore.
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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: Slow admin performance with specific inline

2010-02-08 Thread Andy McKay
Try using the django-debug-toolbar and see if that tells you anything useful.
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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: Callback method on session timeout

2010-02-08 Thread theiklabs
I would also like a way to monitor if there are any active connections to a 
certain web page ie domain.com/h.view
Sent from my Verizon Wireless BlackBerry

-Original Message-
From: cootetom 
Date: Sun, 7 Feb 2010 15:21:58 
To: Django users
Subject: Re: Callback method on session timeout

What is the problem you are trying to solve with this?




On Feb 7, 12:08 am, adamjamesdrew  wrote:
> Does django have the ability to do a callback when a session time out
> occurs?

-- 
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 do object lookup using hour ,minute

2010-02-08 Thread Bill Freeman
As far as I can see, there are two approaches to take.  One is to filter the
results of the query in python (Note: I'm not talking about the filter method
of querysets).  The downside to this is that the database still returns all
objects, and you are discarding those that having the wrong minute value.
This may be acceptable if the table is small or the request is infrequent,
but could be a performance pig otherwise.  You can probably do this on a
queryset with a generator expression to avoid pulling everything into memory
at once.  Where qs is a queryset with any other filters you need (or
all) already
applied::

  for i in (for x in qs if x.datetimeField.minute == desired_minute):
do something with i

Or, you can add an additional where clause using the extra() method of
querysets.  This is more efficient, but you have to know how to specify the
test in SQL, which may not be portable to other databases, and I can't
promise that whatever database you are using knows how to take apart
a timestamp object.  It can take a while to get this stuff right, especially if
there is a join involved, since you will have to figure out what django selected
the appropriate table "AS".

Bill

On Sat, Feb 6, 2010 at 6:21 AM, jimgardener  wrote:
> hi
>
> I am a beginner with python and django  and am writing my first
> application.I need to retrieve some objects of my model class created
> at different minutes in an hour.The class stores a datetime value in a
> 'creationtime'  ( DateTimeField )and have an associated 'subject'
> string which can get repeated in many objects(ie  object has one to
> many relation with subject).Only the 'creationtime' is unique for an
> object.
> How can I get a unique object using MyModel.objects. get()? When I
> checked the lookup docs ,it says it cannot do lookup on hour or
> minute ,but only on year,month,day..
> Also I want to display the details of a single object.Do I need to
> create a unique slug? Is it possible to create a slug from
> DateTimeField 's value? (The prepopulated_fields in ModelAdmin doesn't
> accept DateTimeField and ForeignKey ..so I am not sure if I can use it
> in slug field).
> Also, how should I create the get_absolute_url for the class? If
> someone can give any pointers
>
> --
> 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: I can't get urls with explicit keyword arguments to reverse correctly.

2010-02-08 Thread rebus_
On 8 February 2010 17:33, Luke Sneeringer  wrote:
> Good morning, Django e-mail list! Happy Monday! I have a problem. :) I 
> checked the Django documentation and Stack Overflow with no success, so you 
> guys are my next line of defense. This is an issue I've encountered several 
> times; this is just the first time working around it has bothered me enough 
> to send an email.
>
> So I have a couple URLs. The idea here is to use the same view but get 
> slightly different results. In particular, I have a registration page. We 
> have our regular packages, and then special nonprofit pricing. So, my 
> database stuff to power this is all set up.
>
> I have my basic url:
> ('^register/$', 'mysite.myapp.views.register', name = 'register')
>
> I want another one for nonprofits...same thing, and almost identical 
> functionality, so I changed the above and added a line:
> (r'^register/$', 'mysite.myapp.views.register', { 'nonprofit': False }, name 
> = 'register')
> (r'^register/nonprofit/$', 'mysite.myapp.views.register', { 'nonprofit': True 
> }, name = 'register')
>
> In the view, I am passing the value of the "nonprofit" variable to the 
> template under the same name. Simple enough.
>
> Now, the problem: In the template, the reverse URL matching totally barfs. I 
> want...
> {% url register nonprofit=nonprofit %}
> ...to work.
>
> But I get a NoReverseMatch error:
> Reverse for 'register' with arguments '()' and keyword arguments 
> '{'nonprofit': False}' not found.
>
> The Django documentation (as well as an answer on Stack Overflow) suggest 
> that I really ought to be using named URL patterns to solve this 
> problem...so, instead of naming my non-profit registration page "register", I 
> name it "register-nonprofit".
>
> I really do not want to do this if I can avoid it. That would require me to 
> have something to the effect of...
> {% if nonprofit %}
>        {% url register-nonprofit %}
> {% else %}
>        {% url register %}
> {% endif %}
> ...on the relevant pages. That's substantially less clean.
>
> I also am hoping to avoid a /register/forprofit/ type of URL. My boss would 
> kill me. :)
>
> Any thoughts?
>
> Regards,
> Luke
>
> --
> 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.
>
>


And those suggestions are quite good.

For example:

(r'^register/$', 'mysite.myapp.views.register', { 'nonprofit': False
}, name = 'register_nonprofit')
(r'^register/$', 'mysite.myapp.views.register', { 'nonprofit': True },
name = 'register_profit')

and in your form action field something along the line of:

{% if nonprofit %}
   {% url register_nonprofit %}
{% else %}
   {% url register_profit %}
{% endif %}

With correctly handled template inheritance [1] and include [2] you
should be able to have this if statement block only in one place in
your templates, and that is where the html for your form is located.

[1] http://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance
[2] http://docs.djangoproject.com/en/dev/ref/templates/builtins/#include

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



Slow admin performance with specific inline

2010-02-08 Thread Frank W. Samuelson
When I inline a particular model the admin interface slows 
down enormously.  Inlining other models does not have this 
effect.  This is with the python server (runserver).

Any help would be great.

When I use the following in my admin file, displaying a
household object is very snappy, ~ 1 sec.  All three inlines 
appear just fine, look as expected.


###
...
class IndividualsInline(admin.StackedInline):
model=Individual
extra=1

class purchaseInline(admin.TabularInline):
model=Purchase
# This makes it a single line rather than a select box
#raw_id_fields = ("individuals",)
extra=1

class paymentInline(admin.TabularInline):
model=Payment
extra=1

class Household_admin(admin.ModelAdmin):
inlines=[IndividualsInline,purchaseInline,paymentInline]
search_fields = ['name','address','email','phone']
list_display = ('__unicode__','address','zipcode')

admin.site.register(Household, Household_admin)
...


But then I change things, adding another inline:

###
...
class OwnershipInline(admin.TabularInline):
model=Ownership
extra=1

class Household_admin(admin.ModelAdmin):
inlines=[IndividualsInline,OwnershipInline,purchaseInline,paymentInline]
search_fields = ['name','address','email','phone']
list_display = ('__unicode__','address','zipcode')
...
#

And displaying a Household object takes ~15 seconds.  During 
this time python chews about ~40% of my CPU and the I/O runs 
constantly.  The display is correct, but too slow.


The Ownership model is pretty simple:
##
class Ownership(models.Model):
# The relationship between certificates and Households
certificate=models.ForeignKey(Certificate)
household=models.ForeignKey(Household)
date=models.DateField("Date obtained",null=True,
 blank=True, help_text="Date certificate was transferred to household")
purchase=models.ForeignKey("Purchase", null=True,blank=True,
  help_text="Which purchase transferred ownership?")
nullified=models.DateField("Date nullified", null=True, blank=True,
   help_text="Date ownership was nullified")
current=models.BooleanField("In good standing?", default=False,
blank=True, editable=False)

def __unicode__(self):
return self.household.__unicode__()+" / "+self.certificate.__unicode__(\
)
###

When I started the Ownership model was an intermediate model 
for the Certificate model:


###
class Certificate(models.Model):
households=models.ManyToManyField(Household,blank=True, null=True,
   through="Ownership")
def __unicode__(self):
return "C"+str(self.id) 
###


But whether I have the "households" ManytoMany in the 
the Certificate model or not, the interface is very slow.


The number of objects is not large.  The number of 
Households, Individuals, Certificates, Ownerships, purchases

range from 100-1000.

The API interface in the shell seems is snappy, e.g.

Household.objects.get(name="Samuelson").ownership_set.all()[0].certificate


returns instantly.

I tried profiling the web server with and without the 
Ownership model inlined,

python -m cProfile manage.py runserver
But that gave me no useful info.

Any help would be appreciated greatly.  Thanks in advance.

-Frank


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



Using ForeignKey with dJango and PyAMF

2010-02-08 Thread WC
Hi Everyone,

I have a ForeignKey field that is always null on the Flex client.  I
have tried using select_related(), but it's still null.  Any idea what
I am doing wrong?  In the following sample code, parentBlock is always
null on the Flex client:

File: BlockVO.py
from django.db import models

class Block(models.Model):
blockName = models.CharField(max_length=200)
blockLabel = models.CharField(max_length=200)
blockColor = models.PositiveIntegerField()
xBlockPos = models.IntegerField()
yBlockPos = models.IntegerField()
parentConnectionType = models.CharField(max_length=200,
blank=True, null=True)
parentBlock = models.ForeignKey('self', blank=True, null=True)
def __unicode__(self):
return self.blockLabel

File gateway.py
# To get all Blocks
def getBlocks():
return Block.objects.all().select_related()

File page.as
   private function onResult_blocks(data:Object):void {
var answer : Array = ArrayUtil.toArray(data);
trace("Server returned " + answer.length.toString() + "
block(s)");
for each (var item:BlockVO in answer) {
if(null == item.parentBlock) {
trace("for bloc id=" + item.id + 
"parentBlock is null");
} else {
trace("for bloc id=" + item.id + 
"parentBlock_id=" +
item.parentBlock.id);
}
var newBlock : Block = new Block(workspace, false,
item.blockLabel, 0x66FF66, BlockSpec.REPORTER, null, item);
blocks.push(newBlock);
addChild(newBlock);
}
}

-- 
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: Sub-classing users something else

2010-02-08 Thread Astley Le Jasper
Hi Shawn,

Thanks for pointing me in the right direction. Really appreciated.
I'll check it out.

ALJ

On Feb 8, 4:42 pm, Shawn Milochik  wrote:
> ALJ,
>
> I think you'd greatly benefit from just using this:
>
> http://docs.djangoproject.com/en/1.1/topics/auth/#storing-additional-...
>
> You can create a model to store all your info, and use the built-in 
> settings.py option AUTH_PROFILE_MODULE.
> Essentially you're adding fields to the User model without having to subclass 
> it.
>
> This way, you can take full advantage of contrib.auth.models.User, while at 
> the same time doing any customizations. The nice thing is that
> you can easily do userobject.get_profile() to pull the instance of your 
> custom class.
>
> Shawn

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



I can't get urls with explicit keyword arguments to reverse correctly.

2010-02-08 Thread Luke Sneeringer
Good morning, Django e-mail list! Happy Monday! I have a problem. :) I checked 
the Django documentation and Stack Overflow with no success, so you guys are my 
next line of defense. This is an issue I've encountered several times; this is 
just the first time working around it has bothered me enough to send an email.

So I have a couple URLs. The idea here is to use the same view but get slightly 
different results. In particular, I have a registration page. We have our 
regular packages, and then special nonprofit pricing. So, my database stuff to 
power this is all set up.

I have my basic url:
('^register/$', 'mysite.myapp.views.register', name = 'register')

I want another one for nonprofits...same thing, and almost identical 
functionality, so I changed the above and added a line:
(r'^register/$', 'mysite.myapp.views.register', { 'nonprofit': False }, name = 
'register')
(r'^register/nonprofit/$', 'mysite.myapp.views.register', { 'nonprofit': True 
}, name = 'register')

In the view, I am passing the value of the "nonprofit" variable to the template 
under the same name. Simple enough.

Now, the problem: In the template, the reverse URL matching totally barfs. I 
want...
{% url register nonprofit=nonprofit %}
...to work.

But I get a NoReverseMatch error:
Reverse for 'register' with arguments '()' and keyword arguments '{'nonprofit': 
False}' not found.

The Django documentation (as well as an answer on Stack Overflow) suggest that 
I really ought to be using named URL patterns to solve this problem...so, 
instead of naming my non-profit registration page "register", I name it 
"register-nonprofit".

I really do not want to do this if I can avoid it. That would require me to 
have something to the effect of...
{% if nonprofit %}
{% url register-nonprofit %}
{% else %}
{% url register %}
{% endif %}
...on the relevant pages. That's substantially less clean.

I also am hoping to avoid a /register/forprofit/ type of URL. My boss would 
kill me. :)

Any thoughts?

Regards,
Luke

-- 
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: editing an entry ,how to call the form action

2010-02-08 Thread jimgardener
thanks rebus
-jim
>
> 
> {{entryform.as_ul }}
> 
>  

-- 
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: editing an entry ,how to call the form action

2010-02-08 Thread rebus_
Opps, for you view context it should be "entryform" not "form":


{{entryform.as_ul }}

 

-- 
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: editing an entry ,how to call the form action

2010-02-08 Thread rebus_
On 8 February 2010 16:52, jimgardener  wrote:
> hi
> I created a view function to edit an entry.
> def edit_entry(request,id):
>        entry=get_object_or_404(MyEntry,id=id)
>        if request.method=='POST':
>                form=MyEntryForm(request.POST,instance=entry)
>                if form.is_valid():
>                        form.save()
>                        redirect('myapp_entry_archive_index')
>        else:
>                form=MyEntryForm(instance=entry) #for GET method and invalid 
> forms
>
>        return render_to_response('myapp/myentry_edit_entry.html',
> {'entryform':form})
>
> then I created the urls like
> url(r'^editentry/(?P\d+)/
> $','myapp.views.edit_entry',name='myapp_edit_entry'),
>
> My problem here is how I should give the action in form in the
> template.
> I tried
> 
> {{entryform.as_ul }}
> 
> 
>
> But since the /myapp/editentry/ doesn't match any urls ,it gives a
> 404. How should I pass the id  of entry(which is to be edited) to
> action?
>
> I know this is a silly doubt..But I am a newbie to web programming..If
> anyone can help please do
>
> jim
>
> --
> 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.
>
>

Depends on the way you included your app url.py in projects urls.py.

If in your project's urls.py you have included your apps urls like
url(r'^myapp/$', include('myapp.urls')), then your URL would look like
/myapp/editentry/1/

And instead of hard-coding action url in the template try using
built-in url template tag:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url

For example:


{{entryform.as_ul }}



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



editing an entry ,how to call the form action

2010-02-08 Thread jimgardener
hi
I created a view function to edit an entry.
def edit_entry(request,id):
entry=get_object_or_404(MyEntry,id=id)
if request.method=='POST':
form=MyEntryForm(request.POST,instance=entry)
if form.is_valid():
form.save()
redirect('myapp_entry_archive_index')
else:
form=MyEntryForm(instance=entry) #for GET method and invalid 
forms

return render_to_response('myapp/myentry_edit_entry.html',
{'entryform':form})

then I created the urls like
url(r'^editentry/(?P\d+)/
$','myapp.views.edit_entry',name='myapp_edit_entry'),

My problem here is how I should give the action in form in the
template.
I tried

{{entryform.as_ul }}



But since the /myapp/editentry/ doesn't match any urls ,it gives a
404. How should I pass the id  of entry(which is to be edited) to
action?

I know this is a silly doubt..But I am a newbie to web programming..If
anyone can help please do

jim

-- 
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: Sub-classing users something else

2010-02-08 Thread Shawn Milochik
ALJ,

I think you'd greatly benefit from just using this:

http://docs.djangoproject.com/en/1.1/topics/auth/#storing-additional-information-about-users

You can create a model to store all your info, and use the built-in settings.py 
option AUTH_PROFILE_MODULE.
Essentially you're adding fields to the User model without having to subclass 
it.

This way, you can take full advantage of contrib.auth.models.User, while at the 
same time doing any customizations. The nice thing is that
you can easily do userobject.get_profile() to pull the instance of your custom 
class.

Shawn

-- 
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: Utilization of get_FOO_display()

2010-02-08 Thread Karen Tracey
On Mon, Feb 8, 2010 at 8:51 AM, mf  wrote:

> I want to show the human-readable name for the type selected but I
> keep getting the stored value.
>
> TYPE_CHOICES = (
>('0', 'Basic'),
>('1', 'Full'),
>('2', 'Intermediate'),
> )
>
> class ServiceType(models.Model):
>type = models.IntegerField(max_length=1, choices=TYPE_CHOICES)
>amount = models.DecimalField(max_digits=10, decimal_places=2)
>
>def __unicode__(self):
>return '%s' % (self.get_type_display())
>

The model's type field is an IntegerField yet the actual values in the
choice tuples are strings. This works OK for storing but fails to match when
the real value retrieved from the DB is an integer, since '1' == 1 evaluates
to False, for example.  Thus get_type_display() doesn't find any choice that
matches the retrieved value and falls back to returning the actual value.
Switch the '0', '1', '2' in TYPE_CHOICES to 0,1,2, and it will work.

Karen

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

2010-02-08 Thread Russell Keith-Magee
On Mon, Feb 8, 2010 at 10:42 PM, Andy Cottell  wrote:
>> > > I am new to django, and have started building a project in it. I have
>> > > tried to use theadmininterface with the project am having issues
>> > > logging in. I have setup the interface as instruced in the django
>> > > tutorial part 2, and created a new superuser and cannot use it to log
>> > > in. The user is always rejected with "Please enter a correct username
>> > > and password. Note that both fields are case-sensitive." I am using an
>> > > SQlite3 database.

> Bump!

I'm really not sure what answer you are expecting. The error message
is telling you what is wrong - the username/password combination you
are using isn't valid.

Either:
 * You aren't using the username you specified,
 * You aren't using the password you specified, or
 * You haven't created a superuser account

The only source of confusion I can think that might exist is if you
think that once you have created a superuser for the tutorial, you
don't need to create one for the superuser for your own project.

By way of diagnosis beyond this, you haven't given us much to work
with. Have you been able to successfully complete the tutorial? How
did you go about creating your superuser account (noting that Tutorial
2 doesn't actually contain *any* instructions for creating a superuser
- the superuser is created in Tutorial 1)? Have you tried creating
*another* superuser account (using the instructions linked in Tutorial
2)?

Yours,
Russ Magee %-)

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



Sub-classing users something else

2010-02-08 Thread Astley Le Jasper
(I've just started my first project and I'm already in trouble. I've
read the documentation but still haven't  assimilated it yet. So
sorry for the numpty question.)

I'm building an application to organise product demonstration events.
It will include a foreign key identifying a member of our sales staff
and one for a freelancer. There will be only one staff and freelancer
per event. Both user types will need to have access to the system.
Both will have different roles and responsibilities. And the staff
member will also have additional info, like a budget etc.

Is this a good example where the auth.models.User should be extended
to have a class for the sales staff and one for a freelancer? By
splitting them up it would make the distinction easier for our admin
people to add new sales people and freelancers.

Alternatively perhaps I should keep it simple. I did try to just have
2x one to many foreign keys to the User model, but because it's going
to the same model I had to use "related_name". But this seems so weird
having to have link table in the database when this isn't a many to
many relationship.

Any advice on what approach would be better.

ALJ

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

2010-02-08 Thread Andy Cottell
Bump!

On Feb 2, 1:48 am, Andy Cottell  wrote:
> I have done this, and created an superuser when prompted. However the
> login still fails with the same error.
>
> Here is the urls.py:
>
> from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable theadmin:
> from django.contrib importadminadmin.autodiscover()
>
> urlpatterns = patterns('',
>     # Example:
>     # (r'^microtill/', include('microtill.foo.urls')),
>
>     # Uncomment theadmin/doc line below and add
> 'django.contrib.admindocs'
>     # to INSTALLED_APPS to enableadmindocumentation:
>     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
>     # Uncomment the next line to enable theadmin:
>     (r'^admin/', include(admin.site.urls)),
> )
>
> Here is the settings.py:
>
> # Django settings for microtill project.
>
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
>
> ADMINS = (
>     # ('Your Name', 'your_em...@domain.com'),
> )
>
> MANAGERS = ADMINS
>
> DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2',
> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> DATABASE_NAME = 'till.db'             # Or path to database file if
> using sqlite3.
> DATABASE_USER = ''             # Not used with sqlite3.
> DATABASE_PASSWORD = ''         # Not used with sqlite3.
> DATABASE_HOST = ''             # Set to empty string for localhost.
> Not used with sqlite3.
> DATABASE_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.
> # 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 = 'en-us'
>
> 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
>
> # 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 foradminmedia -- 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.
>
> # List of callables that know how to import templates from various
> sources.
> TEMPLATE_LOADERS = (
>     'django.template.loaders.filesystem.load_template_source',
>     'django.template.loaders.app_directories.load_template_source',
> #     'django.template.loaders.eggs.load_template_source',
> )
>
> MIDDLEWARE_CLASSES = (
>     'django.middleware.common.CommonMiddleware',
>     'django.contrib.sessions.middleware.SessionMiddleware',
>     'django.contrib.auth.middleware.AuthenticationMiddleware',
> )
>
> ROOT_URLCONF = 'microtill.urls'
>
> TEMPLATE_DIRS = (
>     # 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.admin',
>     'microtill.stock',
> )
>
> On 2 Feb, 01:39, bedros <2bed...@gmail.com> wrote:
>
>
>
> > make sure you do syncdb to create database tables before you can
> > actually use theadmininterface for the first time.
>
> > try
>
> > python ./manage.py syncdb
>
> > On Feb 1, 4:41 pm, Andy Cottell  wrote:
>
> > > I am new to django, and have started building a project in it. I have
> > > tried to use theadmininterface with the project am having issues
> > > logging in. I have setup the interface as instruced in the django
> > > tutorial part 2, and created a new superuser and cannot use it to log
> > > in. The user is always rejected with "Please enter a correct username
> > > and password. Note that both fields are case-sensitive." I am using an
> > > SQlite3 database.
>
> > > Please help as I really like django as a framework, and would love to
> > > use it for my projects, but theadmininterface not working is a deal-
> > > breaker.- 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 

Re: Updating data

2010-02-08 Thread Anders Eide
Thank you so much!

I'm new to Django and I have to say that the framework is so easy to
use that it's frustrating to find out how to do things

-Anders

On Feb 8, 3:09 pm, Tom Evans  wrote:
> On Mon, Feb 8, 2010 at 1:46 PM, Anders Eide  wrote:
> > I have a table width movies, and I would like to make a form and a
> > view thats updates a row.
>
> > I build the form automatically from a model
>
> > class SaveMovieForm(ModelForm):
> >    class Meta:
> >        model = Movie
> >    id = forms.IntegerField(
> >        widget = forms.HiddenInput(),
> >        required = False
> >    )
>
> > And populates it like this
>
> > movie = Movie.objects.get(id=id)
>
> > form = SaveMovieForm({
> >    'title' = movie.title,
> >    ...
> > })
>
> > Then sends the form to the template using RequestContext and
> > render_to_response
>
> > But I'm getting the warning that the title already exists. This
> > results in that I can't update the row. How can I tell the form that
> > the request is a update, not a create?
>
> Pass the movie as the instance argument to SaveMovieForm, eg:
>
> form = SaveMovieForm(data=request.POST, instance=movie)
>
> 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: Updating data

2010-02-08 Thread Tom Evans
On Mon, Feb 8, 2010 at 1:46 PM, Anders Eide  wrote:
> I have a table width movies, and I would like to make a form and a
> view thats updates a row.
>
> I build the form automatically from a model
>
> class SaveMovieForm(ModelForm):
>    class Meta:
>        model = Movie
>    id = forms.IntegerField(
>        widget = forms.HiddenInput(),
>        required = False
>    )
>
> And populates it like this
>
> movie = Movie.objects.get(id=id)
>
> form = SaveMovieForm({
>    'title' = movie.title,
>    ...
> })
>
> Then sends the form to the template using RequestContext and
> render_to_response
>
> But I'm getting the warning that the title already exists. This
> results in that I can't update the row. How can I tell the form that
> the request is a update, not a create?
>

Pass the movie as the instance argument to SaveMovieForm, eg:

form = SaveMovieForm(data=request.POST, instance=movie)

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.



Updating data

2010-02-08 Thread Anders Eide
I have a table width movies, and I would like to make a form and a
view thats updates a row.

I build the form automatically from a model

class SaveMovieForm(ModelForm):
class Meta:
model = Movie
id = forms.IntegerField(
widget = forms.HiddenInput(),
required = False
)

And populates it like this

movie = Movie.objects.get(id=id)

form = SaveMovieForm({
'title' = movie.title,
...
})

Then sends the form to the template using RequestContext and
render_to_response

But I'm getting the warning that the title already exists. This
results in that I can't update the row. How can I tell the form that
the request is a update, not a create?

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



Production site.

2010-02-08 Thread Massimiliano Bertinetti
Hi all,

I finally put my first, little django site in production. This was my
first work in django after several php site (cake, zend, joomla, magento
and so on...).

I take a VPS Hosting with Ubuntu 9.10 64 bit - the same linux distro I
use for work and try to put in production the site with apache -
mod_python. For the db (since I host a cms with flatpage for the moment)
I use sqlite3.

The problem was that when I put the project onto the server my config
for serving media, admin_media and tiny_mce initially don't function,
until I create in settings.py a couple of constant with absolute path.

Now all work, but I want to learn how to use continuos integration and
having different machine to host my DBs (MySQL or PostgresSQL),
Mercurial repositories and CI server and staging and production site in
a consistent way, when my work grow.so, what can I post to you for
let me know what was eventually wrong with my configuration?

Thanks in advance!

Max-B 

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



Utilization of get_FOO_display()

2010-02-08 Thread mf
I want to show the human-readable name for the type selected but I
keep getting the stored value.

TYPE_CHOICES = (
('0', 'Basic'),
('1', 'Full'),
('2', 'Intermediate'),
)

class ServiceType(models.Model):
type = models.IntegerField(max_length=1, choices=TYPE_CHOICES)
amount = models.DecimalField(max_digits=10, decimal_places=2)

def __unicode__(self):
return '%s' % (self.get_type_display())

http://pastebin.com/m7ff5a1de

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



Inline validation

2010-02-08 Thread Gabriel Reis
Hello guys,


I have the following situation:

class FooInline(TabularInline):
model = Foo
extra = 1
max_num = 1


class MyAdmin(admin.ModelAdmin):
inlines = [FooInline,]


Is there any way to perform a validation in which the user must have filled
the fields of the inline formset?
I mean, if the user does not change anything in the inline form, raise a
form error validation?

Thanks!

Cheers,

Gabriel Reis

-- 
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: Deserializing xml or json goes into infinite recursion

2010-02-08 Thread Kurt Schwehr
Solved...

The answer is to not user "pk" as a field in your model.  I switch pk
to something else and the serialize and deserialize work fine.

-kurt

On Feb 7, 2:28 pm, Kurt Schwehr  wrote:
> class alert(models.Model):
>     pk = models.CharField(max_length=10, primary_key=True)
>     zone_id = models.IntegerField()
>     first_good_data = models.DateTimeField()
>     ...
>

-- 
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: Next previous links from a query set / generi views

2010-02-08 Thread eaman
On Feb 8, 3:38 am, Eric Abrahamsen  wrote:
[CUT]
> Now that you've got a date attribute, why not use that for next and  
> previous?
1. Date based next and prev go throught the whole photo set,
but I prefer next and prev to provide only items inside a gallery.
But I guess that's just me unable to pass an extra parameter
to the generic view.

2. I'm learning: I wanted to test an other way to get this navigation
links,
coding some custom methods.

> If you don't want to do that, you still might consider returning a  
> real object instance,
Yes this should be better, it could be more userfull if I had to
generate a PDF or some other kind of output.

> and then giving the model a get_absolute_url()  
> method and calling that in the template. That will save you hardcoding  
> the links in the template.
- http://docs.djangoproject.com/en/dev/ref/models/instances/#get-absolute-url
Thanks for the advice: this will make deployment and refactoring
easier.

>
> But if it's just an id you want, the following might be more efficient:
>
> def get_next(self):
>      all_ids = Foto.objects.filter(galleria = self.galleria,  
> id__gt=self.id).values_list("id",flat=True).order_by("id")
>      try:
>          return min(all_ids)
>      except ValueError:
>          return None
>
> Then reverse that (id__lt=self.id and use the max python function) for  
> get_prev()
>
> Hope that's helpful,
> Eric
Oh yes thanks a lot, code examples are really useful to  me as I'm not
yet very familiar with of all this 'snaky' dotted object syntax /
traversing;
I'll get into the django shell and play a bit with this.

Thanks for all this suggestions.

-- 
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: Date-based generic views - UTC handling

2010-02-08 Thread David De La Harpe Golden

On 07/02/10 18:28, Wayne Dyck wrote:


Is there an easy way to format this date_field to my local time zone
i.e. PST? I have also tried using the "date" and "time" filters within
the template itself, however, those are still UTC.

Any pointers would be appreciated.



Well, django-timezones has a template filter that'll show in localtime.
In general, setting django and your database to use UTC internally and 
using django-timezones to format user-facing time to local time is the 
sensible way to go.

http://github.com/brosner/django-timezones/

However, in your case, you may still have to write your own (possibly 
genericized) view, though, if you want to offset the achive view's date 
argument from its url to be in local time rather than UTC.  The ones in 
question are not particularly complex:


http://code.djangoproject.com/browser/django/trunk/django/views/generic/date_based.py

- basically you'd just have to augment it slightly to transform its
args from your desired timezone to UTC before doing the filter, 
otherwise you could get some objects from a few stray hours at the 
"edges" of each month taken relative to local time. Depending on your 
use case, this may not matter to you though.


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



Re: mysql master-master setup

2010-02-08 Thread Tom Evans
On Sun, Feb 7, 2010 at 11:18 PM, Dennis Kaarsemaker
 wrote:
> On ma, 2010-02-08 at 00:04 +0100, Henrik Genssen wrote:
>
>> what is the best way to setup a master-master replication using mysql
>> with django?
>
> Not to do it :)
>
>> Has anyone any experiences with this?
>
> I did not use it with django, but I have use master-master (or even
> rings with more than 2). It's brittle and should not be used. With the
> new multi-db in django 1.2 it becomes much easier to route read queries
> to a slave, thus allowing your master to scale a bit further, reducing
> the need for master-master.
>
> If you still want to use it, make sure you set auto-increment-increment
> and auto-increment-offset properly to try and avoid duplicate keys.
>

I've been running mysql multi-master replication in production for  >
1 year, I wouldn't describe it as brittle. 'invaluable', maybe. We use
it to provide cross site failover, ie one set of servers is sitting in
a separate data centre waiting for something to blow up. We found no
need to change/alter anything in django for this configuration, just
setup the DBs appropriately.

This is (roughly) the configuration we use:

# Multi Master Replication settings master 1
server-id = 1
log-bin = /var/db/mysql/bin-log
log-slave-updates
log-bin-index = /var/db/mysql/bin-log.index
log-error = /var/db/mysql/error.log
relay-log = /var/db/mysql/relay-log
relay-log-info-file = /var/db/mysql/relay-log.info
relay-log-index = /var/db/mysql/relay-log.index
auto_increment_increment = 2
auto_increment_offset = 1
master-host = 
master-user = 
master-password = 
replicate-do-db = 


# Multi Master Replication settings master 2
server-id = 1
log-bin = /var/db/mysql/bin-log
log-slave-updates
log-bin-index = /var/db/mysql/bin-log.index
log-error = /var/db/mysql/error.log
relay-log = /var/db/mysql/relay-log
relay-log-info-file = /var/db/mysql/relay-log.info
relay-log-index = /var/db/mysql/relay-log.index
auto_increment_increment = 2
auto_increment_offset = 2
master-host = 
master-user = 
master-password = 
replicate-do-db = 

Hope that is helpful.

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.