Integrating Social Auth

2011-10-24 Thread Sachin Gupta
I have been trying to integrate social-authand it has been a failure till now. I have done all the steps mentioned on this page, added the backends and the keys but it is not working. I am struggling how to get the templates working. If anyone can he

Re: Subclassing the ForeignKey field type

2011-10-24 Thread guyf
Hi Tobia, I have just discovered your post and I am trying to do something very similar (create and XML doc from an object hierarchy). I have started by trying to use the @toxml decorator and override the __serialize__ method on my model. See (partially working) code below. @toxml class Risk(mode

Re: Subclassing the ForeignKey field type

2011-10-24 Thread Tobia Conforto
Hi Guy I do think my approach is better. Remember the Django motto "Don't Repeat Yourself"! The serialization logic belongs to a library class, not in your models. I can't give you my entire code (it belongs to my employer) but I can point you to the right direction. -Tobia # your model: class

How to make a foreign key field of type other than int?

2011-10-24 Thread Kayode Odeyemi
Hello all, Is there a way to have a foreign key on a model which uses a type other than Django's forceful int type to make the storage for a ModelChoiceField widget? I have something like this I'm working with: forms.py class BranchModelChoiceField(ModelChoiceField): def label_

Re: Django as a Standalone Desktop Application

2011-10-24 Thread Tom Evans
On Sun, Oct 23, 2011 at 2:32 AM, Alex Mandel wrote: > Also the best part of this design is that you can turn it into a web app > at any time by simply opening a port on a machine to allow others to > connect. > Is that supposed to be a plus? Sounds like a nightmare. The smart way to do this is t

Help w/ optimization

2011-10-24 Thread Kurtis
Hey guys, I have some custom context in a view. I'm going to be replicating this context three times for different object relationships. I didn't count, but looking at django-debug-toolbar I'm thinking this block of code runs at around 10 queries. Times that by 3 and I'm going to be bogging my app

Re: Login problems under heavy load

2011-10-24 Thread Tom Evans
On Fri, Oct 21, 2011 at 6:15 PM, Alpesh Gajbe wrote: > >  File "/usr/local/lib/python2.6/dist-packages/django/http/__init__.py", > line 296, in read >   return self._stream.read(*args, **kwargs) > > IOError: request data read error > tl;dr - the user got bored waiting, pressed 'stop' on their bro

Re: How to add extra fields to User table

2011-10-24 Thread Kayode Odeyemi
On Sun, Oct 23, 2011 at 8:52 AM, Chen Xu wrote: > Hi, Every one: > I am trying to create a user registration form. > The default of User table has limited number of fields, but I want to add > more into it. > Therefore, I am wondering what is the better way to do it? Creating another > UserProfil

Re: Help w/ optimization

2011-10-24 Thread Tom Evans
On Mon, Oct 24, 2011 at 11:59 AM, Kurtis wrote: > Hey guys, > > I have some custom context in a view. I'm going to be replicating this > context three times for different object relationships. I didn't > count, but looking at django-debug-toolbar I'm thinking this block of > code runs at around 10

Re: Help w/ optimization

2011-10-24 Thread Flavia Missi
Looks like a genre has a genre group associated with it, right? You could use select_related [1] method when selecting all genres, so, when Django executes the query, all the relation comes in only one query. [1] https://docs.djangoproject.com/en/1.3/ref/models/querysets/#django.db.models.query.Qu

Re: How do you pinpoint a performance issue?

2011-10-24 Thread Tom Evans
On Fri, Oct 21, 2011 at 8:08 PM, Shawn Milochik wrote: > Real-life situation: > >    I deployed a week's worth of code changes to production. Upon > restart, site wouldn't load anymore. Nothing but a 404 error. > > Long story short: > >    By using Django's logging, I discovered that a query was b

Re: Help w/ optimization

2011-10-24 Thread Kurtis Mullins
Thanks guys! I appreciate the great answers! On Mon, Oct 24, 2011 at 7:30 AM, Flavia Missi wrote: > Looks like a genre has a genre group associated with it, right? You could > use select_related [1] method when selecting all genres, so, when Django > executes the query, all the relation comes in

Re: Help w/ optimization

2011-10-24 Thread Tom Evans
On Mon, Oct 24, 2011 at 12:30 PM, Flavia Missi wrote: > Looks like a genre has a genre group associated with it, right? You could > use select_related [1] method when selecting all genres, so, when Django > executes the query, all the relation comes in only one query. > > [1] https://docs.djangopr

How to set up Apache to serve up django websites?

2011-10-24 Thread Roger Marcus
I have the django project Mezzanine up and working well. They have done a much better job in making it easier for the user to install and run their project. I am now fighting to get this all working with apache. >From the django documentation, chapter 20, i have inserted: SetHandler python

Re: redirect problems

2011-10-24 Thread nicolas HERSOG
Hi everyone, I digged more but i'm still stuck. I understood that i have to use namespaceURL. So i modified my url.py this way : from myAppFront.views import article url (r'^article/(?P\d+)/$', myAppFront.views.article, name='article'), and this is my addComment view : def a

Re: Django and Shibboleth

2011-10-24 Thread Tom Evans
On Fri, Oct 21, 2011 at 2:45 PM, Alfred Buterol wrote: > I'm investigating the options for using Shibboleth in a Django > deployment. From what I've found, things look somewhat sparse. Can > anyone comment on the following? > > *  Is anyone using the django_shibboleth module (see > http://code.arc

Re: How to make a foreign key field of type other than int?

2011-10-24 Thread Jani Tiainen
Hi, It really depends what is the result you're after. Since your post doesn't indicate I made two guesses: 1) You want to store transaction in denormalized form. Meaning that branch name will be stored as a string without any relation to existing data. This is good for history record keepi

Re: Help w/ optimization

2011-10-24 Thread Flavia Missi
I'm sorry, I think I didn't explain myself right. I always use select_related when I need a join, thus, I avoid more then one query. When I don't need a join I don't use it :) []'s On Mon, Oct 24, 2011 at 9:34 AM, Tom Evans wrote: > On Mon, Oct 24, 2011 at 12:30 PM, Flavia Missi > wrote: > > L

Re: How to set up Apache to serve up django websites?

2011-10-24 Thread Andre Terra
ImportError: Could not import settings 'portal.settings' (Is it on sys.path?): No module named portal.settings I tried to add this to my apache envvars file as: export PATH=/home/roger/projects/playground/feincms_env/bin:/home/roger/projects/portal:$PATH You need to add /home/roger/projects to

Re: Setting default values in a form from DB table

2011-10-24 Thread Andre Terra
You should always populate your form in forms.py. This is done using the 'initial' kwarg and is thoroughly explained in the docs! [1] Borrowing from the tutorial's Poll model [2]: Class PollsForm(forms.Form): def __init__ (self, *args, **kwargs): self.instance = kwargs.pop('instance',

Re: How to make a foreign key field of type other than int?

2011-10-24 Thread Kayode Odeyemi
On Mon, Oct 24, 2011 at 1:11 PM, Jani Tiainen wrote: > Hi, > > It really depends what is the result you're after. > What I'm really after is such that whenever a transaction is edited and the branch name on that transaction is changed, the model Transaction should save the changed value in the d

Re: Setting default values in a form from DB table

2011-10-24 Thread Swaroop Shankar V
Thank a lot Andre, this is my first project in Django so kind of confused at many parts. The links will help me to fix my issue. Thanks and Regards, Swaroop Shankar V On Mon, Oct 24, 2011 at 6:03 PM, Andre Terra wrote: > You should always populate your form in forms.py. This is done using th

Re: How to make a foreign key field of type other than int?

2011-10-24 Thread Tom Evans
On Mon, Oct 24, 2011 at 11:14 AM, Kayode Odeyemi wrote: > Hello all, > > class BranchModelChoiceField(ModelChoiceField): >     def label_from_instance(self, obj): >     return obj > > class TransactionUpdateForm(forms.ModelForm): >     branchqs = Branch.objects.values_list(u'name_branch', flat

Re: sprintf in python (not strictly django, but used all the time in django webapps)

2011-10-24 Thread Tom Evans
On Thu, Oct 20, 2011 at 7:17 PM, Cal Leeming [Simplicity Media Ltd] wrote: > So, just out of curiosity, how many other people didn't realise you > could do this: > print '%(language)s has %(number)03d quote types.' % \ > ...       {"language": "Python", "number": 2} > > > Instead of this: > >

Re: sprintf in python (not strictly django, but used all the time in django webapps)

2011-10-24 Thread Cal Leeming [Simplicity Media Ltd]
You're correct :L Thanks for this - I think I might replace my daily break with random Python docs pages, rather than 'theregister' for a few weeks! Cal On Mon, Oct 24, 2011 at 3:09 PM, Tom Evans wrote: > On Thu, Oct 20, 2011 at 7:17 PM, Cal Leeming [Simplicity Media Ltd] > wrote: > > So, jus

Re: Iteration over queryset in a model

2011-10-24 Thread eyscooby
So with the items that are still waiting to be complete i wanted to show how many days the ticket has been open by doing something like ... return date.today() - self.issued_date and then those that are complete ... return self.competion_date - self.issued_date Can i create 2 managers f

Re: django, celery and rabbitmq. Task gets added twice

2011-10-24 Thread tom
problem has been solved. Actually, the post_save signal was issued twice. This page helped me: https://code.djangoproject.com/wiki/Signals#Helppost_saveseemstobeemittedtwiceforeachsave -- You received this message because you are subscribed to the Google Groups "Django users" group. To view th

Re: VirtualHost/Cache

2011-10-24 Thread Tom Evans
On Fri, Oct 21, 2011 at 10:57 AM, Didex wrote: > Hello everyone, > > I am trying setup a webserver(Centos) with two django sites, but i am > have cache problems. > > > http.config: > > NameVirtualHost *:80 > WSGIPythonEggs /usr/local/django/eggs > WSGIPythonPath /usr/local/django:/usr/local/django

Re: Integrating Social Auth

2011-10-24 Thread Sid
It would help us in answering your question, if you would explain what all you tried + what error you're getting. I've used social-auth a number of times, it was a breeze to setup. The only frictional part was in custom settings, domain(callback url) white-listing that needed to happen on some

Re: VirtualHost/Cache

2011-10-24 Thread Didex
Okay, I will change the ServerName, but my version of Django is 1.2.5. Thank you. On 24 Out, 15:14, Tom Evans wrote: > On Fri, Oct 21, 2011 at 10:57 AM, Didex wrote: > > Hello everyone, > > > I am trying setup a webserver(Centos) with two django sites, but i am > > havecacheproblems. > > > h

Re: How to make a foreign key field of type other than int?

2011-10-24 Thread Kayode Odeyemi
On Mon, Oct 24, 2011 at 2:57 PM, Tom Evans wrote: > On Mon, Oct 24, 2011 at 11:14 AM, Kayode Odeyemi > wrote: > > Hello all, > > > > class BranchModelChoiceField(ModelChoiceField): > > def label_from_instance(self, obj): > > return obj > > > > class TransactionUpdateForm(forms.ModelF

Problem with GaoDjango models

2011-10-24 Thread Odagi
Hello all. I'm playing with geodjango and have some doubts. I'll really appreciate any comment and suggestion. This is my problem. First, I've defined this (abstract) class: from django.contrib.gis.db import models from django.contrib.gis.geos import * class LocatableModel(models.Model): cou

Re: Field.Choices in Template

2011-10-24 Thread Tom Evans
On Thu, Oct 20, 2011 at 8:37 PM, Kurtis wrote: > Hey, > > I'm trying to build a custom template for my ModelForm. My ModelForm > contains several M2M fields. If I run the ModelForm.as_view and then > in my template print {{ form.as_p }} it'll automagically display those > choices. > > Now what I w

Fixed fields in forms

2011-10-24 Thread Torsten Bronger
Hallöchen! I have some fields in a model form that the user is not allowed to change. The set of fields must be determined at runtime because it depends on the permissions of the current user. Thus, I have defined a self.fixed_fields in my form's constructor which is a set of str. It contains t

Re: How to make a foreign key field of type other than int?

2011-10-24 Thread Tom Evans
On Mon, Oct 24, 2011 at 4:21 PM, Kayode Odeyemi wrote: > On Mon, Oct 24, 2011 at 2:57 PM, Tom Evans wrote: >> >> On Mon, Oct 24, 2011 at 11:14 AM, Kayode Odeyemi >> wrote: >> > Hello all, >> > >> > class BranchModelChoiceField(ModelChoiceField): >> >     def label_from_instance(self, obj): >> >

Re: redirect problems

2011-10-24 Thread Tom Evans
On Mon, Oct 24, 2011 at 12:34 PM, nicolas HERSOG wrote: > Hi everyone, > I digged more but i'm still stuck. > I understood that i have to use namespaceURL. > So i modified my url.py this way : > from myAppFront.views import article >     url (r'^article/(?P\d+)/$', >         myAppFront.views.artic

Re: How to make a foreign key field of type other than int?

2011-10-24 Thread Kayode Odeyemi
On Mon, Oct 24, 2011 at 4:34 PM, Tom Evans wrote: > On Mon, Oct 24, 2011 at 4:21 PM, Kayode Odeyemi wrote: > > On Mon, Oct 24, 2011 at 2:57 PM, Tom Evans > wrote: > >> > >> On Mon, Oct 24, 2011 at 11:14 AM, Kayode Odeyemi > >> wrote: > >> > Hello all, > >> > > >> > class BranchModelChoiceField

Re: How to make a foreign key field of type other than int?

2011-10-24 Thread Carl Meyer
Hi, On Oct 24, 10:53 am, Kayode Odeyemi wrote: > I'm sorry but it doesn't just seem to work for me. I have tried > > possibilities like: > > self.fields['branch_name'].choices = > Branch.objects.all().values('name_branch', 'name_branch') > self.fields['branch_name'].choices = > Branch.objects.all

Problem with saving many to many relationships

2011-10-24 Thread basd basd
I'm trying to set up a many to many relationship, but when I save the model I get "TypeError: 'layer_set' is an invalid keyword argument for this function". In class Experiment(Job) I declare the model with: layer_set = models.ManyToManyField(LayerSet, blank=True, default = "default layer"

Re: Django as a Standalone Desktop Application

2011-10-24 Thread Alex Mandel
On 10/24/2011 03:42 AM, Tom Evans wrote: > On Sun, Oct 23, 2011 at 2:32 AM, Alex Mandel > wrote: >> Also the best part of this design is that you can turn it into a web app >> at any time by simply opening a port on a machine to allow others to >> connect. >> > > Is that supposed to be a plus? S

Re: Django as a Standalone Desktop Application

2011-10-24 Thread graeme
On Oct 24, 3:42 pm, Tom Evans wrote: > I have a number of non-web django processes, so I'm not against that > in general. However, installing a full LAMP/WAMP stack, django and all You do not necessarilly need a full lamp stack. Use Cherrpy (or similar) and SQLite for example. I can think of pl

User data being exposed with mod_wsgi/apache

2011-10-24 Thread Jennifer Bell
On my site, some user data is automatically filled in to a form if a user is logged in by accessing request.user in the view code. On deployment, it seems that if *any* user is logged in, forms requested via another browser will be filled in with their data. The data is not filled in if no user i

OneToOneField causes NotFound exception?

2011-10-24 Thread Paolo
Hi, It looks like if I'm using a OneToOne field (with blank=True etc set) and happen to try and access this field when it's Null (or None) then I get a NotFound exception? My expectation was it would return None of nothing was set, not raise an exception? I could of course catch this except

Models non-relational sources and multiple sources

2011-10-24 Thread dabent
I'm building a Django app that's becoming more complex and it's quite apparent I'm going to need models whose source is not always a relational database. e.g.: thrift, json, text files in custom formatted syntax. Are there any standard approaches on how to handle this situation? I assume there a

Inline element not working as expected.

2011-10-24 Thread jenia ivlev
In the admin I want to use inline elements. I want category to display the items it is related to. But I get this error: Exception at /admin/store/category/7/ has no ForeignKey to It's true, of-course, since I chose to use Category to point to the items it has. But, how can I get the admin to l

Re: Field.Choices in Template

2011-10-24 Thread Kurtis
Thank you so much for this, Tom! I've asked this question quite a few times in IRC and couldn't come across the answer I was looking for. I figured it was possible, I just had no idea how to access it. Much appreciation! On Oct 24, 11:26 am, Tom Evans wrote: > On Thu, Oct 20, 2011 at 8:37 PM, Kur

Re: redirect problems

2011-10-24 Thread nicolas HERSOG
God you'r right ! Thanks to your answer i found why my "named" url didn't work. I wrote this in my urls.py : (r'^article/(?P\d+)/$', myAppFront.views.article, name='article'), instead of : *url*(r'^article/(?P\d+)/$', myAppFront.views.article, name='article'), AND, you'r right, i didn't u