Re: Admin User registration problem...

2011-06-16 Thread ashish tiwari
thank you...

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



Re: Django and Rich Client

2011-06-16 Thread Marwan Al-Sabbagh
Out of curiosity is there a specific need for running a rich client instead
of just accessing the system app through a web browser.

On Fri, Jun 10, 2011 at 4:16 AM, Ovnicraft  wrote:

> soaplib 
>
> On Thu, Jun 9, 2011 at 1:10 PM, Knack  wrote:
>
>> Hi guys,
>>
>> I've got a prototype DB + Rich Client app and need to make a proper
>> production app out of it. The client is written in PyQt and needs to
>> fullfill quite some functional and performance requirements (I would
>> really like to keep it). The client connects directly to the DB.
>>
>> After some thoughts about security I came to the conclusion that using
>> django is the way to go. Now I seek some coarse advice / feedback
>> wether I'm heading in the right directions. I've got some miles to go
>> and looking forward to learning Django, but want to avoid newbie
>> pitfalls. So if something of the following sounds like bad ideas to
>> you, please let me know ;-).
>>
>> Current plans are:
>>
>> 1) Using an Oracle DB
>> 2) LDAP authentification
>> 3) Role based authorisation. Here I'm a bit unsure about the approach.
>> I would implement it by myself within the django world (don't know yet
>> where exactly).
>> 4) Transfering the data using a web service via https. Here are my
>> biggest uncertainties. What kind of web service to use? Rest, xml-rpc
>>
>
> I recommend you REsT, IMHO XML-RPC is not fast, SOAP is a good option but
> we get just few libraries under development soaplib[1]  is really promise.
>
>
> or soap? How to package the acual data? Embedded in the html or xml?
>>
>
> Just be light.
>
>
> Regards,
>
> As binary payload? I would need only basic stuff like log in, log out,
>> read and write whole database rows, which are basically the business
>> objects. Most of the logic is done on the rich client. I would
>> transfer large amounts (10s of business objects) of data at
>> startup time (very eager loading to the client). But also lazy loading
>> of course.
>> 5) One important concept is that I change only a small amount of the
>> data objects. Most of the changes lead to new versions. Therefore I
>> hope to be able to use caching extensivly. The data objects which are
>> immutable could be permanently cached in memory. How about
>> authorisation of these cached objects? Are there ways django takes
>> care of this?
>>
>> A long first post ;-). Any comments are appreciated!
>>
>> Cheers,
>>
>> Jan
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> Cristian Salamea
> @ovnicraft
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



email-auth without sending the activation email

2011-06-16 Thread Anaconda
I  am using the plugin email-auth which works very well but it sends
an activation email to the user and i find that this extra step will
reduce signups. Is there a way to not have the activation e-mail but
rather the user just gets logged in after registering email/password
and redirected to home page?

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



Re: Django 1.3, Apache/2.2.14, mod_wsgi/2.8 Python/2.6.5 mod_wsgi (pid=6676): Unable to get bucket brigade for request

2011-06-16 Thread chycyra
sorry for error typing: the server is Ubuntu 10.04 and i'm no using
HTTPS request

On Jun 17, 9:14 am, Heru Eko Susanto  wrote:
> hello all,
>
> i'm using Apache + mod_wsgi on ubuntu 9.10 . today i have error on my
> server:
>
> [Tue Jun 14 06:27:49 2011] [notice] Apache/2.2.14 (Ubuntu) mod_wsgi/2.8
> Python/2.6.5 configured -- resuming normal operations
> [Fri Jun 17 07:29:57 2011] [error] [client 192.168.1.4] (70007)The timeout
> specified has expired: mod_wsgi (pid=6676): Unable to get bucket brigade for
> request., referer:http://192.168.1.6/admin/master/tarip/add/
> [Fri Jun 17 07:29:59 2011] [error] [client 192.168.1.4] mod_wsgi (pid=6675):
> Exception occurred processing WSGI script
> '/var/www/nakula/wsgi/billing.wsgi'.
> [Fri Jun 17 07:29:59 2011] [error] [client 192.168.1.4] IOError: failed to
> write data
>
> here apache conf for the server:
>
> 
>     ServerName wsgi.djangoserver
>     DocumentRoot /var/www/nakula
>
>     
>         Order allow,deny
>         Allow from all
>     
>     WSGIDaemonProcess nakula.djangoserver processes=2 threads=15
> display-name=%{GRUP}
>     WSGIProcessGroup nakula.djangoserver
>
>     WSGIScriptAlias / /var/www/nakula/wsgi/billing.wsgi
> 
>
> and billing.wsgi:
>
> import os
> import sys
> path = '/var/www/nakula'
> if path not in sys.path:
>     sys.path.insert(0,path)
> os.environ['DJANGO_SETTINGS_MODULE']='settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> did I missed some configuration ? or any suggestion for this problem ?
>
> Thank you,
>
> heru

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



Re: Newbie questions about models / databases

2011-06-16 Thread Kenneth Gonsalves
On Thu, 2011-06-16 at 11:26 -0700, Dan Stromberg wrote:
> 1. How does syncdb decide what to write to the sqlite file, and what
> not
>to?  Does it only write info for a given application once?

yes - unless the model is removed - when it asks you
>2. If I set up a model, syncdb it, change the model, and syncdb
> again -
>will any changes be seen in the database file?

no
>3. If I need to start over with a conflicting model change, can I
> safely
>remove the sqlite file and syncdb again? 

yes
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Django 1.3, Apache/2.2.14, mod_wsgi/2.8 Python/2.6.5 mod_wsgi (pid=6676): Unable to get bucket brigade for request

2011-06-16 Thread Heru Eko Susanto
hello all,

i'm using Apache + mod_wsgi on ubuntu 9.10 . today i have error on my
server:

[Tue Jun 14 06:27:49 2011] [notice] Apache/2.2.14 (Ubuntu) mod_wsgi/2.8
Python/2.6.5 configured -- resuming normal operations
[Fri Jun 17 07:29:57 2011] [error] [client 192.168.1.4] (70007)The timeout
specified has expired: mod_wsgi (pid=6676): Unable to get bucket brigade for
request., referer: http://192.168.1.6/admin/master/tarip/add/
[Fri Jun 17 07:29:59 2011] [error] [client 192.168.1.4] mod_wsgi (pid=6675):
Exception occurred processing WSGI script
'/var/www/nakula/wsgi/billing.wsgi'.
[Fri Jun 17 07:29:59 2011] [error] [client 192.168.1.4] IOError: failed to
write data

here apache conf for the server:


ServerName wsgi.djangoserver
DocumentRoot /var/www/nakula


Order allow,deny
Allow from all

WSGIDaemonProcess nakula.djangoserver processes=2 threads=15
display-name=%{GRUP}
WSGIProcessGroup nakula.djangoserver

WSGIScriptAlias / /var/www/nakula/wsgi/billing.wsgi



and billing.wsgi:

import os
import sys
path = '/var/www/nakula'
if path not in sys.path:
sys.path.insert(0,path)
os.environ['DJANGO_SETTINGS_MODULE']='settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

did I missed some configuration ? or any suggestion for this problem ?

Thank you,

heru

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



mod_wsgi: URL appended to wsgi script location

2011-06-16 Thread Alan
Hello--

I'm in the painful position of having to get a production Django site
hosted on a windows machine...
My setup:
Windows 7
Apache 2.2
Python 2.6
mod_wsgi 3.3

In my httpd.conf:
WSGIScriptAlias /testsite/ C:/django/testsite/apache/django.wsgi

Visiting http://localhost/testsite shows the home page correctly
When I go to http://localhost/testsite/admin, I see this message in
the error log:

[error] [client 127.0.0.1] Target WSGI script not found or unable to
stat: C:/django/testsite/apache/django.wsgiadmin

As an experiment, when I change the conf to vend a static file as so:
Alias /testsite/ C:/django/testsite/apache/django.wsgi

[error] [client 127.0.0.1] File does not exist: C:/django/testsite/
apache/django.wsgiadmin


Likewise when I visit http://localhost/testsite/test:
[error] [client 127.0.0.1] File does not exist: C:/django/testsite/
apache/django.wsgitest



I'm a novice apache user; can someone please explain why this happens
& how I can fix it?


Thanks!
-Alan

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



is there any reason our sqlite3 DB on disk wouldn't reflect the changes made after we get a signal?

2011-06-16 Thread Sam Roberts
We are finding that after operations that add records to the DB, we
can run the cmd-line sqlite3 utility and see that the DB has been
updated.

However, when we delete records, in the post_delete signal, we've run
iterdump() on the connection handle and seen the records are gone, but
still don't see the records deleted when we use the cmdline tool.

Its possible we are being confused by some other problem, but it looks
almost as if django is using an in-memory proxy DB, and only
periodically syncing it to disk.

Or perhaps a number of changes to the model are being done inside an
explicit sqlite3 transaction, and its not until the transaction closes
that all the changes get written out?

Could this be true?

The sqlite3 devs are pretty insistent that any one line delete should
be wrapped in an auto-transaction and commited to disk immediately,
which seems to point to something we don't understand about django's
ORM and its transaction use.

We care about this because we do database mirroring.

We trap modifications to a number of the important tables, and
snapshot a copy of the ondisk DB to a backup location. We find after
deletes, that the mirrored copy
still has the deleted rows.

Thanks,
Sam

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



audit changes to models

2011-06-16 Thread Brian
Hi,

I need to add a basic audit capability to a django app. There seem to be 
lots of superficially similar apps and modules around: django-audit, 
django-audit-log, AuditTrail, SimpleHistory. Does anyone have any experience 
with these or recommendations?

The models I need to track are quite simple: A, B, C where A has a 
many-to-one relationship with B, and B has a many-to-one relationship with 
C. I'd like to track create/update/delete operations together with the name 
of the user making the change, and present a table that can be filtered by 
the name of a C instance, or by the name of the user/editor.

Thanks for any advice you can offer,

Brian

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



Re: Django Class Based FormView and multiple forms

2011-06-16 Thread Iván Raskovsky
On Thu, Jun 16, 2011 at 11:43 AM, Michel Thadeu Sabchuk
 wrote:
> Hi Russ,
>
>> ... this is an
>> area where I think there is lots of room for improvement now that we
>> have a class-based foundation to work with.
>
> Thanks for your reply!
>
> I started my own "multiple forms view":
>
> https://gist.github.com/1029336
>
> I see the ticket's approach is much more complete, I will see how I
> can help.

Hi Michel this looks great!

Would you like to merge it with my work[0']? Maybe attach a pull request?

We should agree on naming conventions for the methods, and maybe have
the same hooks. You can look at my work in the patch of #16256 or
here[1].

Why are you using a dict instead of a list?

Oh, we should also add some tests for this new view.

Regards,
Iván

[0] https://github.com/rasca/django/tree/ticket16256-more-class-based-views
[1] 
https://github.com/rasca/django/blob/ticket16256-more-class-based-views/django/views/generic/edit/formset.py

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



Re: auth.LoginTest seems to require sites

2011-06-16 Thread Brian
In case anyone else has the same issue, the problem stopped when I upgraded 
django from 1.2 to 1.3.

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



Re: When to use a model property vs. method?

2011-06-16 Thread Micky Hulse
I am reading through Chapter5+ of Dive Into Python now... Seems like
that should cover all of my questions! :D

Sorry to bug the list with my ramblings.

Thanks again Bruno!

Have a great day all!
Cheers,
Micky

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



Re: Single auth database for multiple (different) django projects

2011-06-16 Thread DK


On Thursday, June 16, 2011 2:38:52 PM UTC+2, SleepyCal wrote:
>
>
> Having a central authorization point is the way forward. I'm a bit confused 
> by this comment though:
>
> "But this still do not solve problem of NOT having multiple accounts in 
> several django projects"
>
> Could you explain what you mean?
>

As far as I know, using authorization like Google Account, Facebook or 
OpenID just makes that user has an auto generated account in Django 
connected with external account (for example Google Account). So still - you 
bypass only the fact of logging, but storing/editing user profile, some 
other additional data is complicated and involves using this auto-generated 
accounts in django.


I hope  you get my point.


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



Re: When to use a model property vs. method?

2011-06-16 Thread Micky Hulse
How's this for a rule-of-thumb(?):

1. Use a property (class/instance attribute) when an argument(s) is not needed.

2. If an argument(s) is needed (for runtime(?) calculations and/or
class/instance attributes need to be sanitized/checked/other), then
use a method (or getter/setter/descriptor).

No?

Hehe, thanks again!!!

Cheers,
Micky

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



Django on IIS7 With Windows Server 2008 R2

2011-06-16 Thread Lurton, David
Hi everyone,

 

I'm new to Django and to this group. 

 

I've been struggling getting Django 1.3 to work under Windows 2008 R2
and IIS7 for about a week or so and I've just found that some of the .py
files required by PyISAPIe refers to some signal dispatching methods
which were removed from Django long ago.  So it doesn't work at all with
Django 1.3.  Instructions for using the isapi_wsgi are indecipherable as
are instructions for FastCGI.  

 

Before I go any further with Django under IIS, I would like to ask the
community what their recommendation is for running Django under IIS?
What "glue" is preferred for connecting Django 1.3, Python 2.7.1 and IIS
on Windows Server 2008 R2?

 

Apache on windows is an option, but not a preferred one since IIS is far
easier for us to make production-ready.

 

Thanks in advance,

-David Lurton

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



Re: When to use a model property vs. method?

2011-06-16 Thread Micky Hulse
Hi Bruno! Thank you so much for your help. I really appreciate the pro
assistance. :)

On Thu, Jun 16, 2011 at 1:42 PM, bruno desthuilliers
 wrote:
> 
> This could be written much more simply as "return self.modified >
> self.created"
> 

Omg, thanks! That's way better. :D

>> def get_separator(self):
>>     return ' :: '
> In this case (returning a constant), it would be much simpler to make
> it a class (or instance) attribute.

Ah, I think I get it.

Just to clarify things for me, does attribute equal a property or method? :D

I am guessing that attribute = property, so you're saying that I
could/should do this:

@property
def separator(self):
return ' :: '

> Properties are for computed attributes - that is, things that are the
> semantically (conceptually, whatever) attributes, but requires any
> computation, either on get, set or del.

Ah, interesting... I think I need to let this all sink in a little. :)

> But well, if you prefer java-
> like getters/setters, then choice is yours... Depends on the
> programmer's background,

I have a little experience with Actionscipt 3 and PHP5 OOP... I guess
I am used to the concept/practice of getters/setters,
(public/private/other) class methods and properties.

Are you saying that a non-property model class method is equivalent to
getter/setter? Or, maybe you are saying that the "lat =
property(_get_lat)" python property syntax is like
getters/setters/accessors in other programming langs?

Again, sorry if stupid questions... sorry if this is getting OT for
the Django list.

> and of course of whether the code was written
> before new-style classes and the descriptor protocol

I have not heard of this before. Googling "new-style classes and the
descriptor protocol" now. ;)

Looks like I have a lot of learning to do! :D

Thanks again, I greatly appreciate your time and assistance.

Have a great day.

Cheers,
Micky

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



Re: Admin User registration problem...

2011-06-16 Thread Kenny Meyer
> i want to create superuser(administrator) on registration
User.objects.create_superuser is your friend.

>             user=User.objects.create_user(
>                 username=form.cleaned_data['username'],
>                 password=form.cleaned_data['password1'],
>                 email=form.cleaned_data['email'],
>                 is_staff=form.cleaned_data['is_staff'],
>             )

Maybe try instead:

user=User.objects.create_superuser(
username=form.cleaned_data['username'],
    password=form.cleaned_data['password1'],
    email=form.cleaned_data['email'],
)

Kenny



On Thu, Jun 16, 2011 at 12:03 PM, ashish tiwari  wrote:
> hi friends,
> i developed an application in django-nonrel with appengine.
> i'm using django forms for user registration.
>
> forms.py
> 
> class RegistrationForm(forms.Form):
>     username=forms.CharField(label=u'Username',max_length=30)
>     email=forms.CharField(label=u'Email')
>     is_staff=forms.BooleanField(label=u'is staff')
>
> password1=forms.CharField(label=u'Password',widget=forms.PasswordInput())
>
> password2=forms.CharField(label=u'Password(Again)',widget=forms.PasswordInput())
> views.py
> 
> def register_page(request):
>     if request.method=='POST':
>         form = RegistrationForm(request.POST)
>         if form.is_valid():
>             user=User.objects.create_user(
>                 username=form.cleaned_data['username'],
>                 password=form.cleaned_data['password1'],
>                 email=form.cleaned_data['email'],
>                 is_staff=form.cleaned_data['is_staff'],
>             )
>         return HttpResponseRedirect('/')
>     else:
>         form=RegistrationForm()
>         variables=RequestContext(request,{'form':form})
>     return
> render_to_response('interview/registration/register.html',variables)
>
> register.html
> ~
>     
>             {{ form.as_p }}
>     
> when i try to register,it throws an error ..
> "create_user() got an unexpected keyword argument 'is_staff'"
> i want to create superuser(administrator) on registration is there
> anything m doing wrong? Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/4HkVMVqNkJwJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: When to use a model property vs. method?

2011-06-16 Thread bruno desthuilliers


On 16 juin, 20:07, Micky Hulse  wrote:
> Hello,
>
> Just curious what the rule-of-thumb is for when it comes to using
> model methods vs. properties. For example:
>
> [code]
>
> @property
> def is_modified(self):
>     if self.modified > self.created:
>         return True
>     return False


This could be written much more simply as "return self.modified >
self.created"



> def get_separator(self):
>     return ' :: '

In this case (returning a constant), it would be much simpler to make
it a class (or instance) attribute.

> [/code]
>
> I feel like I have seen so many examples of methods and properties
> that return the same type of stuff, I am just confused about when to
> use one over the other.

Properties are for computed attributes - that is, things that are the
semantically (conceptually, whatever) attributes, but requires any
computation, either on get, set or del. But well, if you prefer java-
like getters/setters, then choice is yours... Depends on the
programmer's background, and of course of whether the code was written
before new-style classes and the descriptor protocol


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



Re: Newbie questions about models / databases

2011-06-16 Thread Shawn Milochik

On 06/16/2011 02:26 PM, Dan Stromberg wrote:



   1. How does syncdb decide what to write to the sqlite file, and
  what not to?  Does it only write info for a given application once?
   2. If I set up a model, syncdb it, change the model, and syncdb
  again - will any changes be seen in the database file?
   3. If I need to start over with a conflicting model change, can I
  safely remove the sqlite file and syncdb again?





1. Once only, then you need to use South.

2. Never, see #1.

3. Certainly, if you don't care about your data.


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



Re: IOError

2011-06-16 Thread Shawn Milochik

On 06/16/2011 03:00 PM, vivek kumar bagaria wrote:

IOError at /search/

The path to your Whoosh index 'search/engine' is not writable for the 
current user/group"


it will be very helpful if you could help me regarding this error

thanks in advance




This is not a Django issue but a Linux/UNIX issue. Look up 
file/directory permissions on Google, or search the great forums at 
unix.com.


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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to load CSS: Django Template, CSS and image

2011-06-16 Thread Tim Shaffer
Shouldn't you really be putting your js/css in your static directory?

Check out the docs for managing static files:

https://docs.djangoproject.com/en/1.3/howto/static-files/

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



IOError

2011-06-16 Thread vivek kumar bagaria
hi all,
i am vivek and was currently working on a project and wanted to
implement search using haystack.
   i followed the documentation and could get the template working and
indexed the model(the name is users)
  when i tried to use it on localhost i got error


"
IOError at /search/

The path to your Whoosh index 'search/engine' is not writable for the
current user/group"

it will be very helpful if you could help me regarding this error

thanks in advance

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



overriding widget for "group" in User model

2011-06-16 Thread Brian Craft
Is there an easy way to get checkboxes for groups in the User admin,
rather than a multiselect?

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



Should I use Pinax for my social networking site?

2011-06-16 Thread slothario
I apologize in advance if you get questions like this all the time - I
did a search and read through a few posts, but I want to see if anyone
has any direct advice for me. :)

I'm working on a startup and we're currently deciding what path to go
down. We're considering something out-of-the-box like Pinax, but I
worry that it could become too constricting as we add more features -
this is going to need to be a fully customized, scalable website. Do
you think Pinax is ideally suited for our website, or do you think
we'd regret it as things become more and more complicated? Also, while
I know you're going to be slanted towards Django, what do you think
about using Ruby on Rails and its software packages?

(For the record, I've done a bunch of random programming, IT, and web
dev stuff across the board - PHP, Ruby on Rails, database stuff, etc.
I'm not afraid to get my hands dirty and dig in deep - I love to
figure out stuff as I go - but I wouldn't consider myself an advanced
coder.)

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



Newbie questions about models / databases

2011-06-16 Thread Dan Stromberg
I'm developing my first django application, but I have a lot of Python
experience.

I have a couple of related questions about database/model information and
manage.py syncdb, in combination with sqlite3:

   1. How does syncdb decide what to write to the sqlite file, and what not
   to?  Does it only write info for a given application once?
   2. If I set up a model, syncdb it, change the model, and syncdb again -
   will any changes be seen in the database file?
   3. If I need to start over with a conflicting model change, can I safely
   remove the sqlite file and syncdb again?

Thanks!

-- 
Dan Stromberg

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



How to load CSS: Django Template, CSS and image

2011-06-16 Thread yesnik
In this lesson I’ll show you how to make Django load your template
containing CSS and image.

1. Let’s create a project ‘girl’:
django-admin.py startproject girl

2. In ‘girl’ directory we create 2 new directories:

- templates

- media

3. Put index.html in ‘templates’ directory.

-- index.html --





If this text RED, then CSS loaded successfully!



---

4. In ‘media’ directory we create ‘css’ directory and put there
style.css.

-- style.css --
p{color: red}
---

5. Also in ‘media’ directory we create ‘images’ directory and put
there 01.jpg

6. In directory ‘girl’ I changed settings.py:
 settings.py (only my changes) --
TEMPLATE_DIRS = ('C:/django/nik/girl/templates', )

Note: In TEMPLATE_DIRS path ‘girl’ is the name of our project.

7. In directory ‘girl’ we change urls.py:

 urls.py 
from django.conf.urls.defaults import patterns, include, url
from django.conf import settings

urlpatterns = patterns('',
(r'^$', 'girl.views.index'),
)

# We're going to use the Django server in development,
# so we'll server also the estatic content.
if settings.DEBUG:
urlpatterns += patterns('',
   (r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root':'./media/'}),
)
--

8. In directory ‘girl’ we create views.py:

 views.py --
from django.shortcuts import render_to_response

def index(request):
return render_to_response('index.html', )
--

9. Then we execute command in shell:
manage.py syncdb

10. At last let’s start Django server:
manage.py runserver

11. Open your browser and go to: http://127.0.0.1:8000/
And you’ll see red text and pic.

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



Intermittent OperationalError on multiple Django servers

2011-06-16 Thread Steven Smith
On two separate Django servers, I'm seeing variations on this error:


 File "/usr/lib64/python2.6/site-packages/django/db/models/sql/
compiler.py", line 731, in execute_sql
   cursor = self.connection.cursor()

 File "/usr/lib64/python2.6/site-packages/django/db/backends/
__init__.py", line 75, in cursor
   cursor = self._cursor()

 File "/usr/lib64/python2.6/site-packages/django/db/backends/
postgresql_psycopg2/base.py", line 136, in _cursor
   self.connection = Database.connect(**conn_params)

OperationalError: could not connect to server: Connection refused
   Is the server running on host "localhost" and accepting
   TCP/IP connections on port 5432?



99% of the time, the user agent is one of the search engines' bots, so
I don't think very many users are seeing it, but it's definitely
affecting my SEO, since, the search engine can't crawl the site. And
it makes me cringe every time I see the error emails...


Anybody have a nudge in the right direction as to where I might start
looking? This is Django 1.2.5 with Postgres 9.0.3, running on a 64-bit
linux system with Apache 2.2.16 and mod_wsgi 3.3.

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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Field Type for S3 Storage?

2011-06-16 Thread Ivo Brodien
>  How does the |mageField know the dimensions of the image?

Nevermind.

Just saw that the file gets opened for the dimension by looking at the source 
code.

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



satchmo images

2011-06-16 Thread Bobby Roberts
anyone know where to adjust the upload size of the product images in
satchmo?

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



Field Type for S3 Storage?

2011-06-16 Thread Ivo Brodien
hello,

I am planing a django application, which manages photos that are stored in a S3 
Bucket.

With boto and django-storages I can declare an ImageField and images get 
uploaded to S3 easily.

But I want to make a mobile client use an API to upload photos directly to S3 
(using signed Forms) and tell the django app about the uploaded file. This way 
I can take off load of the server.

The validation of a API form expects the actual image data in the POST request. 
I can prevent an error by changing the form validation but what about the 
height and width attributes if I only store the path of the file in the DB? How 
does the |mageField know the dimensions of the image?

Thanks
Ivo 




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



When to use a model property vs. method?

2011-06-16 Thread Micky Hulse
Hello,

Just curious what the rule-of-thumb is for when it comes to using
model methods vs. properties. For example:

[code]

@property
def is_modified(self):
if self.modified > self.created:
return True
return False

def get_separator(self):
return ' :: '

[/code]

I feel like I have seen so many examples of methods and properties
that return the same type of stuff, I am just confused about when to
use one over the other.

Just hoping some of the pro Django/Python users on this list could
school me on this one. :D

Thanks so much!

Cheers,
Micky

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



Re: When to use a model property vs. method?

2011-06-16 Thread Micky Hulse
On Thu, Jun 16, 2011 at 11:07 AM, Micky Hulse  wrote:
> Just hoping some of the pro Django/Python users on this list could
> school me on this one. :D

Actually, here's an example that I am working on now.

In my model, I have a CharField that holds the latitude/longitude with
values that look like:

44.08577787869324,-123.052459359169

I would like to write model methods to return latitude and longitude.

[code]

def lat(self):
# ...

def lng(self):
# ...

[code]

Should I use a property decorator?

Also, what is the difference between this:

[code]

def _get_lat(self):
# ...
lat = property(_get_lat)

[/code]

... and this:

[code]

@property
def lat(self):
# ...

[/code]

Sorry if stupid questions.

Thanks!
Micky

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



Re: Helper methods like rails or taglibs/tagfiles like java

2011-06-16 Thread Rodrigo Gomes
Yes, but the point is not about generate code. Is to follow a DRY
principle...If I have a "multiple select list" with a specific
behavior,look-and-feel, with some javascript surrounding the code, etc, I
don't want to write this everywhere...I just want to create once and use it
anywhere...with just a line of code...

And I can do this easily with java through tagfiles, and sometimes taglibs.
And now with django I'm using inclusion tag as suggested by Tom.

The only reason that I'm not enjoying inclusion tags so much, is because I
can not pass named parameters to them...only positional. But is works

[]'s
Rodrigo Gomes

On Wed, Jun 15, 2011 at 10:29 PM, Kenneth Gonsalves
wrote:

> On Wed, 2011-06-15 at 11:01 -0300, Rodrigo Gomes wrote:
> > But I think that I'm missing something. Is it so hard to write a
> > simple
> > custom select box, for example? I need to write a parser, a render and
> > put
> > in the html in another file? Or there is a easer way to do that?
> >
> >
>
> as mentioned, django philosophy is against generating code.
> --
> regards
> KG
> http://lawgon.livejournal.com
> Coimbatore LUG rox
> http://ilugcbe.techstud.org/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Chat

2011-06-16 Thread Nadae Ivar BADIO

Hi,

I am programing a chat with python django anyone have a example for me 
please.


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



Re: ManyToMany field and deletes

2011-06-16 Thread Marc Aymerich
On Thu, Jun 16, 2011 at 5:36 PM, Tom Evans  wrote:
> On Thu, Jun 16, 2011 at 4:16 PM, Marc Aymerich  wrote:
>> On Thu, Jun 16, 2011 at 3:55 PM, Russell Keith-Magee
>>  wrote:
>>
>> Hi Russell, many thanks for your answer :)
>>
>>> It has this behaviour because it's the most sensible general approach
>>> when an m2m relation is involved.
>>>
>>> Consider the general case: a relation between Person and Club. A
>>> person can belong to many clubs, and each club can have many members.
>>> If a person dies (i.e., you delete their record), the clubs they
>>> belonged to continue to exist; simliarly, if a club disbands, the
>>> people don't die.
>>
>> Yes, I agree with that, most M2M cases it makes sense with 0
>> relations. But django let you to define the relation with null=False
>> (moreover, this is the default value). I dont see any situation as the
>> one you define where the M2M has null=False and there is a case when
>> you want to keep the related obects after deleting the related
>> objects.
>>
>> For example, in my case I have a M2M relation between VirtualHosts and
>> Domains. A VirtualHost can have many domains but it must have at least
>> one, so I can't have VirtualHosts without a domain.
>
> Can you have domains that belong to multiple virtualhosts? (I assume
> you are modelling Apache here, and the answer is, no, you cannot).
> Surely a foreign key from domain to virtualhost is a more apt
> relationship.
>

Yep, but I have Domain and VirtualHost models in a seperate reusable
apps (dns and webs). So if I define VirtualHost as a Domain FK I have
this app dependency: 'dns' depends on 'webs', when ("in the real
life") the dependency should be: 'webs' depends on 'dns'.

>> I thought that this behaviour was because django ORM strictly emulates
>> SQL delete on cascade, but then I realized that deletes on inherited
>> models is an exception case. Because when you delete a child, the
>> parent also has been deleted, and the relation is made with a FK child
>> -> parent. So why do not make an exception with M2M(null=False) too?
>
> It is nonsensical to say M2M(null=False) (or null=True), since an M2M
> 'field' is not a field at all, it is the existence of a row in a
> separate table. There is nothing to null out! It should be purely
> business logic whether to remove a domain if you remove the vhost
> holding that domain, or to remove the vhost if you remove all the
> domains from it.

As I understand, in a 'model level', M2M could be interpreted just as
a relation, and with null=True/False you're saying that this relation
is 0..n or 1..n. At least, this is how django form field validator
interpret this """field""" property, raising an exception if you're
trying to save an object after deleting all of their M2M related
objects. I think it's an inconsistency that a validator "think" that
"you're wrong saving an object without relations", but a 'delete
collector' thinks that "doesn't matter if an object has no remaining
M2M relations". (always talking assuming null=False).

br.
-- 
Marc

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



Admin User registration problem...

2011-06-16 Thread ashish tiwari
hi friends,
i developed an application in django-nonrel with appengine.
i'm using django forms for user registration.

forms.py

class RegistrationForm(forms.Form):
username=forms.CharField(label=u'Username',max_length=30)
email=forms.CharField(label=u'Email')
is_staff=forms.BooleanField(label=u'is staff')

password1=forms.CharField(label=u'Password',widget=forms.PasswordInput())

password2=forms.CharField(label=u'Password(Again)',widget=forms.PasswordInput())

views.py

def register_page(request):
if request.method=='POST':
form = RegistrationForm(request.POST)
if form.is_valid():
user=User.objects.create_user(
username=form.cleaned_data['username'],
password=form.cleaned_data['password1'],
email=form.cleaned_data['email'],
is_staff=form.cleaned_data['is_staff'],
)
return HttpResponseRedirect('/')
else:
form=RegistrationForm()
variables=RequestContext(request,{'form':form})
return 
render_to_response('interview/registration/register.html',variables)

register.html
~

{{ form.as_p }}


when i try to register,it throws an error .. 
"create_user() got an unexpected keyword argument 'is_staff'" 
i want to create superuser(administrator) on registration is there 
anything m doing wrong? Thanks in advance

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



django form radio input layout

2011-06-16 Thread NateB

Hello all,

I posted this to stackoverflow a couple weeks ago, but I have yet to get any
takers.  I was able to backburner this for a little bit, but I'd like to see
it wrapped up.

In my form class, I have a forms.ChoiceField whose widget is a
forms.RadioSelect widget, one of whose choices needs to be presented with an
inline text input (which is also a field in the form). I'm using custom
validation to ignore the text field when its radio choice is not selected.
When rendered, I want it to appear like below:


 No Textbox
 One Textbox: 


However, I can't simply produce this in my template, because the radio
choices are not exposed. I can't see a way to do this without tightly
coupling my form to my template, or alternately, putting all of the
presentation logic in the form class. What is the right way to solve this
problem?

I'm a much better backend programmer than web designer, and I'm on this
project alone, so maybe it's a lack of education - is what I described
simply poor design? Should I just be designing this a different way? I'm
really open to any suggestion here that will help me move past this.

If you're a stackoverflow user, and you'd like 15 rep for answering, 
http://stackoverflow.com/questions/6218299/django-form-radio-input-layout
the question is here 
-- 
View this message in context: 
http://old.nabble.com/django-form-radio-input-layout-tp31862033p31862033.html
Sent from the django-users mailing list archive at Nabble.com.

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



Re: ManyToMany field and deletes

2011-06-16 Thread Tom Evans
On Thu, Jun 16, 2011 at 4:16 PM, Marc Aymerich  wrote:
> On Thu, Jun 16, 2011 at 3:55 PM, Russell Keith-Magee
>  wrote:
>
> Hi Russell, many thanks for your answer :)
>
>> It has this behaviour because it's the most sensible general approach
>> when an m2m relation is involved.
>>
>> Consider the general case: a relation between Person and Club. A
>> person can belong to many clubs, and each club can have many members.
>> If a person dies (i.e., you delete their record), the clubs they
>> belonged to continue to exist; simliarly, if a club disbands, the
>> people don't die.
>
> Yes, I agree with that, most M2M cases it makes sense with 0
> relations. But django let you to define the relation with null=False
> (moreover, this is the default value). I dont see any situation as the
> one you define where the M2M has null=False and there is a case when
> you want to keep the related obects after deleting the related
> objects.
>
> For example, in my case I have a M2M relation between VirtualHosts and
> Domains. A VirtualHost can have many domains but it must have at least
> one, so I can't have VirtualHosts without a domain.

Can you have domains that belong to multiple virtualhosts? (I assume
you are modelling Apache here, and the answer is, no, you cannot).
Surely a foreign key from domain to virtualhost is a more apt
relationship.

>
> I thought that this behaviour was because django ORM strictly emulates
> SQL delete on cascade, but then I realized that deletes on inherited
> models is an exception case. Because when you delete a child, the
> parent also has been deleted, and the relation is made with a FK child
> -> parent. So why do not make an exception with M2M(null=False) too?

It is nonsensical to say M2M(null=False) (or null=True), since an M2M
'field' is not a field at all, it is the existence of a row in a
separate table. There is nothing to null out! It should be purely
business logic whether to remove a domain if you remove the vhost
holding that domain, or to remove the vhost if you remove all the
domains from it.

Cheers

Tom

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



Re: ManyToMany field and deletes

2011-06-16 Thread Marc Aymerich
On Thu, Jun 16, 2011 at 3:55 PM, Russell Keith-Magee
 wrote:

Hi Russell, many thanks for your answer :)

> It has this behaviour because it's the most sensible general approach
> when an m2m relation is involved.
>
> Consider the general case: a relation between Person and Club. A
> person can belong to many clubs, and each club can have many members.
> If a person dies (i.e., you delete their record), the clubs they
> belonged to continue to exist; simliarly, if a club disbands, the
> people don't die.

Yes, I agree with that, most M2M cases it makes sense with 0
relations. But django let you to define the relation with null=False
(moreover, this is the default value). I dont see any situation as the
one you define where the M2M has null=False and there is a case when
you want to keep the related obects after deleting the related
objects.

For example, in my case I have a M2M relation between VirtualHosts and
Domains. A VirtualHost can have many domains but it must have at least
one, so I can't have VirtualHosts without a domain.

I thought that this behaviour was because django ORM strictly emulates
SQL delete on cascade, but then I realized that deletes on inherited
models is an exception case. Because when you delete a child, the
parent also has been deleted, and the relation is made with a FK child
-> parent. So why do not make an exception with M2M(null=False) too?

>> I think it's a bit problematic because you can have 'orphan objects',
>> and more over a change form for this object will raise a validation
>> exception if you don't create a new relation.
>
> This definition of "orphan objects" only applies in certain specific
> validation cases -- for example, if every Person *must* belong to at
> least one club.

This validation exception will happens if you lets the default null
value when you define a ManyToManyField :)

>
>> Are anyone encouraged to explain a some good reason for this behavior? jeje
>> What is the best way to avoid this? maybe overriding the save method
>> but the down side of this is that admin delete confirmation page
>> doesn't will be aware of this. Is there any other option?
>
> The best option I can think of is to handle this with a custom m2m
> model. Instead of using Django's default M2M model (the one that is
> autogenerated when you define a m2m relation), define your own M2M
> model, specify it as a the "through" model on the m2m relation, and
> implement logic to maintain the validation rules you want.

Yep, this sounds better than override the delete method.
Thanks!!

-- 
Marc

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



Re: Django Class Based FormView and multiple forms

2011-06-16 Thread Michel Thadeu Sabchuk
Hi Russ,

> ... this is an
> area where I think there is lots of room for improvement now that we
> have a class-based foundation to work with.

Thanks for your reply!

I started my own "multiple forms view":

https://gist.github.com/1029336

I see the ticket's approach is much more complete, I will see how I
can help.

Best regards!

--
Michel Sabchuk
Brasil

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



Re: Django Class Based FormView and multiple forms

2011-06-16 Thread Russell Keith-Magee
On Wed, Jun 8, 2011 at 10:33 PM, Michel Thadeu Sabchuk
 wrote:
> Hi guys,
>
> Is there a general guideline to work with class based generic views
> and multiple forms? I already use FormView but it seems focused on a
> single form.
>
> Suppose a user profile registration: with function based views, I use
> two forms, one for the user account and other for the profile.
>
> I can start directly on the TemplateView or I can fill the FormView
> with 2 forms (with some customization) but, before it, I want to know
> if anyone didn't find a better way to do it ;)
>
> Some recommendation?

This is a known limitation of FormView, inherited from it's heritage
in the function-based generic views. There is an open ticket [1] that
aims to address some of these limitations; more broadly, this is an
area where I think there is lots of room for improvement now that we
have a class-based foundation to work with.

[1] https://code.djangoproject.com/ticket/16256

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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ManyToMany field and deletes

2011-06-16 Thread Russell Keith-Magee
On Mon, Jun 13, 2011 at 3:54 AM, Marc Aymerich  wrote:
> Hi ,
> I realize that django doesn't delete related objects when M2M field
> hasn't remaining relations. I don't see why django has this behaviour
> by default.

It has this behaviour because it's the most sensible general approach
when an m2m relation is involved.

Consider the general case: a relation between Person and Club. A
person can belong to many clubs, and each club can have many members.
If a person dies (i.e., you delete their record), the clubs they
belonged to continue to exist; simliarly, if a club disbands, the
people don't die.

> I think it's a bit problematic because you can have 'orphan objects',
> and more over a change form for this object will raise a validation
> exception if you don't create a new relation.

This definition of "orphan objects" only applies in certain specific
validation cases -- for example, if every Person *must* belong to at
least one club.

> Are anyone encouraged to explain a some good reason for this behavior? jeje
> What is the best way to avoid this? maybe overriding the save method
> but the down side of this is that admin delete confirmation page
> doesn't will be aware of this. Is there any other option?

The best option I can think of is to handle this with a custom m2m
model. Instead of using Django's default M2M model (the one that is
autogenerated when you define a m2m relation), define your own M2M
model, specify it as a the "through" model on the m2m relation, and
implement logic to maintain the validation rules you want.

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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Single auth database for multiple (different) django projects

2011-06-16 Thread Cal Leeming [Simplicity Media Ltd]
On Thu, Jun 16, 2011 at 1:26 PM, DK  wrote:

> Hi,
>
> I need to develop several django projects (let's assume that there are
> highly different one from each other). The common thing is users/groups
> data. If a user register into one of this sites, he should be able to use
> this same account credentials for all other sites.
>

I'm going to reply based on the assumption that the different sites are kept
within multiple code bases?


>
> I really didn't find any obvious solution to this problem:
>
> 1) Keeping everything in one database (single django project) - not
> possible, every of a project is big enough to be worth keeping separate,
> also using something like SITES (not really an issue here)  would provide do
> keeping data of all separate projects in one big database, what will cause a
> problems with maintenance (backuping everything together, etc.).
>

Not a good idea, you could open yourself up to all sorts of race conditions,
compatibility, and migration issues.


>
> 2) Using django multiple database support -  this would be great to put
> auth models into seperate common database, but django does
> not officially support multidatabase foreign key relations - making this
> useless. Any model with relation to auth.User would not be supported this
> way (in my projects almost every thing is somehow conneted to the user so
> this is dead end for me).
>

Same as above.


>
> 3) Using several databases and keeping auth tables in sync by external tool
> - very, very error prone. Writing something that deals with coherency
> problem will be very difficult, and there also will be a delay between
> sync's of databases in several projects - not really acceptable - user data
> should be stored in one point.
>

Noo.


>
> 4) Creating central authorization point with Profiles, and make custom
> django authorization module that would work exaclty like OpenID
> authorization. But this still do not solve problem of NOT having multiple
> accounts in several django projects (even connected to one central Profile).
>

Having a central authorization point is the way forward. I'm a bit confused
by this comment though:

"But this still do not solve problem of NOT having multiple accounts in
several django projects"

Could you explain what you mean?

Cal



>
> Any idea?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/2m_lo5mn8sYJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Single auth database for multiple (different) django projects

2011-06-16 Thread Shawn Milochik

How about Celery & RabbitMQ?

Use Django's signaling functionality to kick off a Celery task, use 
Celery to make it async and nearly real-time, then transfer the info 
securely.


I recommend *not* allowing the data to be serialized in the RabbitMQ 
message (for security & performance), but rather initiate a call to the 
other servers via HTTPS or scp with the info, or prompting the other 
servers to do a callback to the originating server via HTTPS or scp call 
of their own.


Of course, there's no way to avoid race conditions because a person can 
be logged into more than one of these apps and once and make changes 
nearly simultaneously, but


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



Single auth database for multiple (different) django projects

2011-06-16 Thread DK
Hi,

I need to develop several django projects (let's assume that there are 
highly different one from each other). The common thing is users/groups 
data. If a user register into one of this sites, he should be able to use 
this same account credentials for all other sites.

I really didn't find any obvious solution to this problem:

1) Keeping everything in one database (single django project) - not 
possible, every of a project is big enough to be worth keeping separate, 
also using something like SITES (not really an issue here)  would provide do 
keeping data of all separate projects in one big database, what will cause a 
problems with maintenance (backuping everything together, etc.)

2) Using django multiple database support -  this would be great to put auth 
models into seperate common database, but django does not officially support 
multidatabase foreign key relations - making this useless. Any model with 
relation to auth.User would not be supported this way (in my projects almost 
every thing is somehow conneted to the user so this is dead end for me).

3) Using several databases and keeping auth tables in sync by external tool 
- very, very error prone. Writing something that deals with coherency 
problem will be very difficult, and there also will be a delay between 
sync's of databases in several projects - not really acceptable - user data 
should be stored in one point.

4) Creating central authorization point with Profiles, and make custom 
django authorization module that would work exaclty like OpenID 
authorization. But this still do not solve problem of NOT having multiple 
accounts in several django projects (even connected to one central Profile).

Any idea?

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



Re: Django aggregation equivalent of SUM(IF(field = x, 1, 0)) - 40 million row table

2011-06-16 Thread Cal Leeming [Simplicity Media Ltd]
Hmm, to be honest, most people don't really have the amount of data that we
have, and thus would be able to use multiple queries with a filter()
instead.

I've had a look through the Django sql aggregates and models aggregates,
however I realised that for this to be included in the core, I'd have to add
support for all the other databases too. Sadly, I haven't got enough spare
time to create/patch/test to this extent, so it looks like I'll have to use
a raw() for now.

Thanks for getting back to me anyway though, I'll update the ticket with
this discussion.

Cal

On Thu, Jun 16, 2011 at 1:11 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> On Thu, Jun 16, 2011 at 7:41 PM, Cal Leeming [Simplicity Media Ltd]
>  wrote:
> > Hi Russ,
> > Thanks for getting back to me. Ticket 11305 looks like what I need, but
> the
> > code is extremely hacky. The second link you pasted seems to take the
> right
> > approach, and I agree with you that the F() object should be used.
> > If I create a sane/clean patch (with F() support) as a stand alone class,
> > would you consider having it merged into the core?
>
> It depends a little on the exact use case your patch covers. If your
> aggregate only covers an obscure edge case, I'd prefer to see it live
> externally; but if you can make a case that it's a common use case (or
> it's obvious that it is a common use case), then a suitably robust and
> tested patch could be considered for core.
>
> 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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Django aggregation equivalent of SUM(IF(field = x, 1, 0)) - 40 million row table

2011-06-16 Thread Russell Keith-Magee
On Thu, Jun 16, 2011 at 7:41 PM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> Hi Russ,
> Thanks for getting back to me. Ticket 11305 looks like what I need, but the
> code is extremely hacky. The second link you pasted seems to take the right
> approach, and I agree with you that the F() object should be used.
> If I create a sane/clean patch (with F() support) as a stand alone class,
> would you consider having it merged into the core?

It depends a little on the exact use case your patch covers. If your
aggregate only covers an obscure edge case, I'd prefer to see it live
externally; but if you can make a case that it's a common use case (or
it's obvious that it is a common use case), then a suitably robust and
tested patch could be considered for core.

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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django aggregation equivalent of SUM(IF(field = x, 1, 0)) - 40 million row table

2011-06-16 Thread Cal Leeming [Simplicity Media Ltd]
Hi Russ,

Thanks for getting back to me. Ticket 11305 looks like what I need, but the
code is extremely hacky. The second link you pasted seems to take the right
approach, and I agree with you that the F() object should be used.

If I create a sane/clean patch (with F() support) as a stand alone class,
would you consider having it merged into the core?

Cal

On Thu, Jun 16, 2011 at 12:27 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> On Thu, Jun 16, 2011 at 7:20 PM, Cal Leeming [Simplicity Media Ltd]
>  wrote:
> > Hey guys,
> > I've picked through as much as the Django docs as possible, but can't
> seem
> > to find any reference to Sum() allowing any in-method conditionals (i.e.
> a
> > conditional to Sum() with an in-line IF(), without the use of a
> > WHERE/filter).
> > The original query in MySQL is:
> >
> > mysql> select SUM(is_spam) as is_spam, SUM(is_image_blocked) as
> > is_image_blocked, SUM(IF(dl_job_state = 2, 1, 0)) as dl_job_success
> COUNT(*)
> > as total_rows from fourchan_post;
> > +-+--+++
> > | is_spam | is_image_blocked | dl_job_success | total_rows |
> > +-+--+++
> > |9116 |   266516 |5010939 |   38832166 |
> > +-+--+++
> > 1 row in set (3 min 13.14 sec)
> >
> > In Django, I'm using (incomplete):
>  Post.objects.aggregate(Count('id'), Sum('is_spam'),
>  Sum('is_image_blocked'), Sum('is_checked'))
> > So far, the only way I can see to do this, would be to do a filter()
> before
> > the aggregate, but this will affect the other Sum()'s which would mean
> > multiple queries would be necessary. Normally this wouldn't be an issue,
> but
> > the table has over 40 million rows lol (and it already takes well over 3
> > minutes to execute)
> > Ideally, I'd like to try and find a way (within the ORM), to specify an
> IF
> > conditional for the Sum(), thus only having to perform a single query. If
> > this isn't possible, I'll put in a feature request for it.
>
> I haven't looked into your specific use case in detail, but it *might*
> be possible to do this with a custom aggregate. SUM, COUNT etc are all
> just classes in Django, so you can extend and define your own if you
> want.
>
> Ticket #11305 [1] seems to describe almost exactly the feature you are
> asking for (although they wanted COUNT, not SUM); in the discussion
> for the ticket, Alex gives a code sample implementing conditional
> aggregates.
>
> There were also discussions on django-users back when aggregates were
> introduced, describing how to define a custom aggregate [2].
>
> Both these references are worth a look.
>
> [1] https://code.djangoproject.com/ticket/11305
> [2]
> http://groups.google.com/group/django-users/browse_thread/thread/bd5a6b329b009cfa
>
> 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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Django aggregation equivalent of SUM(IF(field = x, 1, 0)) - 40 million row table

2011-06-16 Thread Russell Keith-Magee
On Thu, Jun 16, 2011 at 7:20 PM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> Hey guys,
> I've picked through as much as the Django docs as possible, but can't seem
> to find any reference to Sum() allowing any in-method conditionals (i.e. a
> conditional to Sum() with an in-line IF(), without the use of a
> WHERE/filter).
> The original query in MySQL is:
>
> mysql> select SUM(is_spam) as is_spam, SUM(is_image_blocked) as
> is_image_blocked, SUM(IF(dl_job_state = 2, 1, 0)) as dl_job_success COUNT(*)
> as total_rows from fourchan_post;
> +-+--+++
> | is_spam | is_image_blocked | dl_job_success | total_rows |
> +-+--+++
> |    9116 |           266516 |        5010939 |   38832166 |
> +-+--+++
> 1 row in set (3 min 13.14 sec)
>
> In Django, I'm using (incomplete):
 Post.objects.aggregate(Count('id'), Sum('is_spam'),
 Sum('is_image_blocked'), Sum('is_checked'))
> So far, the only way I can see to do this, would be to do a filter() before
> the aggregate, but this will affect the other Sum()'s which would mean
> multiple queries would be necessary. Normally this wouldn't be an issue, but
> the table has over 40 million rows lol (and it already takes well over 3
> minutes to execute)
> Ideally, I'd like to try and find a way (within the ORM), to specify an IF
> conditional for the Sum(), thus only having to perform a single query. If
> this isn't possible, I'll put in a feature request for it.

I haven't looked into your specific use case in detail, but it *might*
be possible to do this with a custom aggregate. SUM, COUNT etc are all
just classes in Django, so you can extend and define your own if you
want.

Ticket #11305 [1] seems to describe almost exactly the feature you are
asking for (although they wanted COUNT, not SUM); in the discussion
for the ticket, Alex gives a code sample implementing conditional
aggregates.

There were also discussions on django-users back when aggregates were
introduced, describing how to define a custom aggregate [2].

Both these references are worth a look.

[1] https://code.djangoproject.com/ticket/11305
[2] 
http://groups.google.com/group/django-users/browse_thread/thread/bd5a6b329b009cfa

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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django aggregation equivalent of SUM(IF(field = x, 1, 0)) - 40 million row table

2011-06-16 Thread Cal Leeming [Simplicity Media Ltd]
Hey guys,

I've picked through as much as the Django docs as possible, but can't seem
to find any reference to Sum() allowing any in-method conditionals (i.e. a
conditional to Sum() with an in-line IF(), without the use of a
WHERE/filter).

The original query in MySQL is:

mysql> select SUM(is_spam) as is_spam, SUM(is_image_blocked) as
is_image_blocked, SUM(IF(dl_job_state = 2, 1, 0)) as dl_job_success COUNT(*)
as total_rows from fourchan_post;
+-+--+++
| is_spam | is_image_blocked | dl_job_success | total_rows |
+-+--+++
|9116 |   266516 |5010939 |   38832166 |
+-+--+++
1 row in set (3 min 13.14 sec)


In Django, I'm using (incomplete):

>>> Post.objects.aggregate(Count('id'), Sum('is_spam'),
Sum('is_image_blocked'), Sum('is_checked'))

So far, the only way I can see to do this, would be to do a filter() before
the aggregate, but this will affect the other Sum()'s which would mean
multiple queries would be necessary. Normally this wouldn't be an issue, but
the table has over 40 million rows lol (and it already takes well over 3
minutes to execute)

Ideally, I'd like to try and find a way (within the ORM), to specify an IF
conditional for the Sum(), thus only having to perform a single query. If
this isn't possible, I'll put in a feature request for it.

Thanks

Cal

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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Tom Evans
On Thu, Jun 16, 2011 at 11:55 AM, Kenneth Gonsalves
 wrote:
> those entries are old. The point is that the built in User.get_profile()
> only works with onetoone. The difference is in the reverse lookup.

That is not correct.

It will still work perfectly with ForeignKey(unique=True), it is just
better to use a OneToOneField, because of the better handling of the
inverse relation, cleaner and clearer syntax, etc.

Cheers

Tom

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



MongoDB with django?

2011-06-16 Thread Roy Smith
I'm exploring packages to use MongoDB with django.  So far, I've
found:

* DjanMon (https://github.com/mdirolf/djanMon/)
* Mongoengine (http://mongoengine.org)
* MongoKIT
* Mango
* Pymongo-bongo
* Mongodb-engine (https://github.com/django-mongodb-engine/mongodb-
engine)
* Django-nonrel (http://www.allbuttonspressed.com/projects/django-
nonrel)
* Django MongoDB Engine (http://django-mongodb.org)

Are there any major players I've missed?

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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Kenneth Gonsalves
On Thu, 2011-06-16 at 12:24 +0200, Ivo Brodien wrote:
> This Django Book however is old and in the new one in Chapter 14:
> Sessions, Users, and Registration the User Profile does not get
> mentioned anymore.
> 
> Also the first search result in google for “django user profile” is
> James Bennetts blog entry where he also uses Foreign Key.
> 
> What is the difference between Foreign Key (unique= true) and a
> OneToOne field anyway? 

those entries are old. The point is that the built in User.get_profile()
only works with onetoone. The difference is in the reverse lookup.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Ivo Brodien
> In the paragraph preceding this link it explicitly states to use
> OneToOneField. The Django documentation is canonical, if it says one
> thing, and elsewhere on the internet says something else, the internet
> is wrong. The internet is often wrong.
> 
> The difference between a ForeignKey(unique=True) and OneToOneField is
> that on the reverse side of the relationship, the one-to-one is
> represented as a single attribute on the instance, where as the
> foreign key is represented as an object manager.

thanks. I did not read carefully. And of course, django docs is what I rely on 
in the first place.

they are just great and easy to read.

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



Re: Internationalization query for List & dictionary

2011-06-16 Thread Anand Agarwal
Thanks Tom

Regards
Anand
http://bootstraptoday.com





On Thu, Jun 16, 2011 at 3:49 PM, Tom Evans  wrote:

> On Thu, Jun 16, 2011 at 11:16 AM, Anand Agarwal 
> wrote:
> > Hi All
> >
> > Is there a way to define _ for items in python dictionary and list other
> > than individual items using gettext_lazy?
> >
> > eg: _(['hello', 'world'])  does this work?
> >
> > or do I have to do
> >
> > [_('hello'), _('world')]
> >
> >
> > similarly whats the syntax for dictionary??
> >
> > Regards
> > Anand
> >
>
> No shortcuts. You could do [ _(f) for f in ['hello', 'world']], but
> then that would not mark up the strings 'hello' and 'world' for
> translation, so they would not be inserted into the translation
> category.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Tom Evans
On Thu, Jun 16, 2011 at 11:24 AM, Ivo Brodien  wrote:
>
> Actually, I've read that ForeignKey is now the way to specify it.
>
> unique foreign key *was* the correct way as onetoone was broken. This is
> no longer true.
>
> where is the most up to date info on this?
> In the dev docs about storing additional user info on djangoproject.com
> there is a link to an old Django Book
> Chapter 12 of the Django book
> there it says:
>

In the paragraph preceding this link it explicitly states to use
OneToOneField. The Django documentation is canonical, if it says one
thing, and elsewhere on the internet says something else, the internet
is wrong. The internet is often wrong.

The difference between a ForeignKey(unique=True) and OneToOneField is
that on the reverse side of the relationship, the one-to-one is
represented as a single attribute on the instance, where as the
foreign key is represented as an object manager.

Eg:

user = User.objects.get(id=1)
user.userprofile_set.get() # If it is a ForeignKEy
user.userprofile # If it is OneToOneField

Cheers

Tom

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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Ivo Brodien

>> Actually, I've read that ForeignKey is now the way to specify it. 
> 
> unique foreign key *was* the correct way as onetoone was broken. This is
> no longer true.

where is the most up to date info on this?

In the dev docs about storing additional user info on djangoproject.com there 
is a link to an old Django Book 

Chapter 12 of the Django book

there it says: 

 user = models.ForeignKey(User, unique=True)

This Django Book however is old and in the new one in Chapter 14: Sessions, 
Users, and Registration the User Profile does not get mentioned anymore.

Also the first search result in google for “django user profile” is James 
Bennetts blog entry where he also uses Foreign Key.

What is the difference between Foreign Key (unique= true) and a OneToOne field 
anyway?

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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Internationalization query for List & dictionary

2011-06-16 Thread Tom Evans
On Thu, Jun 16, 2011 at 11:16 AM, Anand Agarwal  wrote:
> Hi All
>
> Is there a way to define _ for items in python dictionary and list other
> than individual items using gettext_lazy?
>
> eg: _(['hello', 'world'])  does this work?
>
> or do I have to do
>
> [_('hello'), _('world')]
>
>
> similarly whats the syntax for dictionary??
>
> Regards
> Anand
>

No shortcuts. You could do [ _(f) for f in ['hello', 'world']], but
then that would not mark up the strings 'hello' and 'world' for
translation, so they would not be inserted into the translation
category.

Cheers

Tom

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



Internationalization query for List & dictionary

2011-06-16 Thread Anand Agarwal
Hi All

Is there a way to define _ for items in python dictionary and list other
than individual items using gettext_lazy?

eg: _(['hello', 'world'])  does this work?

or do I have to do

[_('hello'), _('world')]


similarly whats the syntax for dictionary??

Regards
Anand

http://bootstraptoday.com
Accelerate your Ideas!

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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Benedict Verheyen
On 16/06/2011 11:29, Kenneth Gonsalves wrote:
> On Thu, 2011-06-16 at 11:10 +0200, Benedict Verheyen wrote:
>> On 16/06/2011 10:43, Kenneth Gonsalves wrote:
>>> On Thu, 2011-06-16 at 10:10 +0200, Benedict Verheyen wrote:
 user = models.ForeignKey(User, unique=True)
>>>
>>> you need onetoone for this to work.
>>
>> Hi,
>>
>> Actually, I've read that ForeignKey is now the way to specify it. 
> 
> unique foreign key *was* the correct way as onetoone was broken. This is
> no longer true.

Ok,

thanks for the info

Regards,
Benedict

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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Kenneth Gonsalves
On Thu, 2011-06-16 at 11:10 +0200, Benedict Verheyen wrote:
> On 16/06/2011 10:43, Kenneth Gonsalves wrote:
> > On Thu, 2011-06-16 at 10:10 +0200, Benedict Verheyen wrote:
> >> user = models.ForeignKey(User, unique=True)
> > 
> > you need onetoone for this to work.
> 
> Hi,
> 
> Actually, I've read that ForeignKey is now the way to specify it. 

unique foreign key *was* the correct way as onetoone was broken. This is
no longer true.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Benedict Verheyen
On 16/06/2011 10:43, Kenneth Gonsalves wrote:
> On Thu, 2011-06-16 at 10:10 +0200, Benedict Verheyen wrote:
>> user = models.ForeignKey(User, unique=True)
> 
> you need onetoone for this to work.

Hi,

Actually, I've read that ForeignKey is now the way to specify it.
Anyway, the problem has been solved as Jari pointed out that
I didn't specify the correct app name in my model.

Thanks,
Benedict


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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Benedict Verheyen
On 16/06/2011 10:27, Ivo Brodien wrote:
> an idea: Do you have a __init__.py  in every subfolder? also the models and 
> userprofile folder under calltracking_main ?
> 
> 

Ivo,

i do have an __init__.py in every folder.
As Jari pointed out, it was the appname in my UserProfile model
that was incorrect.

Thanks,
Benedict

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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Benedict Verheyen
On 16/06/2011 10:25, Jani Tiainen wrote:
> On Thu, 2011-06-16 at 10:10 +0200, Benedict Verheyen wrote:
>> Hi,
>>
>>
>> The syncdb command doesn't want to create the UserProfile table.
>> Also when I was trying to get this working while running the app,
>> it was complaining about AUTH_PROFILE_MODULE.
>> It is however correctly specified in my settings.py:
>> ...
>> AUTH_PROFILE_MODULE = 'calltracking_main.UserProfile'
> ^   app named
> "calltracking_main"
> 




> 
> Note that you have specified app name for UserProfile as "calltracking"
> but referring it (settings at least) as appname "calltracking_main".
> 
> 
> Probably fixing appname in model would fix all other issues as well.
> 

Jani,


thanks a million!
I've looked over that one. A few hours of futile searching :)
It was indeed the solution.
I changed the appname to calltracking_main and it worked as expected.

Regards,
Benedict

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



Re: django.db.utils.IntegrityError: null value in column “layer_id_id” violates not-null constraint . How to debug ?

2011-06-16 Thread Satyajit Sarangi
What I want is a very simple thing .
I want the primary key of Sdr_Layer to be the foreign key of Test table .
How do I manage it ?
And , I am assigning values to Test via Layermapping tool , which as you
said that passes a dict .

I think the problem here is the layermapping tries to map onto the Test
model , but doesn't know what to do about the layer_id  . Thats what I think
. Not sure . What can be the way out ?

On Thu, Jun 16, 2011 at 2:19 PM, Daniel Roseman wrote:

> On Wednesday, 15 June 2011 22:25:24 UTC+1, Satyajit Sarangi wrote:
>>
>> his is my models.py
>>
>> from django.db import models
>>
>> class Sdr_Layer(models.Model): layer_name =
>> models.CharField(max_length = 100)
>> layer_attribute_name=models.CharField(max_length=100)
>>
>> # This is an auto-generated Django model module created by ogrinspect.
>> from django.contrib.gis.db import models
>>
>>
>>
>>
>>
>>
>>
>>
>> # This is an auto-generated Django model module created by ogrinspect.
>> from django.contrib.gis.db import models
>>
>> class Test(models.Model):
>> layer_id= models.ForeignKey(Sdr_Layer)
>> name = models.CharField(max_length=80)
>> descriptio = models.CharField(max_length=80)
>> geom = models.PolygonField(srid=4326)
>> objects = models.GeoManager()
>> S = Sdr_Layer(layer_name="Test")
>>
>> # Auto-generated `LayerMapping` dictionary for Test model
>> test_mapping = {
>> 'name' : 'Name',
>> 'descriptio' : 'Descriptio',
>> 'geom' : 'POLYGON25D',
>> }
>> S.layer_attribute_name=test_mapping
>> S.save();
>>
>> When I am trying to load data to Test model , it throws me a not_null
>> error on layer_id which is the foreign key here . I basically want the
>> primary key of Sdr_Layer to act as a foreign key here . Sdr_Layer
>> table does have values . So , why such an error ?
>
>
>
> On Wednesday, 15 June 2011 22:25:24 UTC+1, Satyajit Sarangi wrote:
>>
>> his is my models.py
>>
>> from django.db import models
>>
>> class Sdr_Layer(models.Model): layer_name =
>> models.CharField(max_length = 100)
>> layer_attribute_name=models.CharField(max_length=100)
>>
>> # This is an auto-generated Django model module created by ogrinspect.
>> from django.contrib.gis.db import models
>>
>> # This is an auto-generated Django model module created by ogrinspect.
>> from django.contrib.gis.db import models
>>
>> class Test(models.Model):
>> layer_id= models.ForeignKey(Sdr_Layer)
>> name = models.CharField(max_length=80)
>> descriptio = models.CharField(max_length=80)
>> geom = models.PolygonField(srid=4326)
>> objects = models.GeoManager()
>> S = Sdr_Layer(layer_name="Test")
>>
>> # Auto-generated `LayerMapping` dictionary for Test model
>> test_mapping = {
>> 'name' : 'Name',
>> 'descriptio' : 'Descriptio',
>> 'geom' : 'POLYGON25D',
>> }
>> S.layer_attribute_name=test_mapping
>> S.save();
>>
>> When I am trying to load data to Test model , it throws me a not_null
>> error on layer_id which is the foreign key here . I basically want the
>> primary key of Sdr_Layer to act as a foreign key here . Sdr_Layer
>> table does have values . So , why such an error ?
>
>
> You need to think things through a bit more carefully. It seems like you're
> randomly assigning things without really having any idea of what you're
> doing.
>
> This code:
> S = Sdr_Layer(layer_name="Test")
> instantiates a new Sdr_Layer object, with the name "Test".
>
> This line:
> S.layer_attribute_name=test_mapping
> tries to do something very strange, which is to assign a dictionary to your
> CharField. You can do that, but it will be converted to a string on save.
>
> Now, none of this code would throw a "not_null error on layer_id", because
> layer_id is a field on the Test model, which you don't even use in this
> code. So, there must be code you're not showing us. Also, there is a reason
> why Python prints the full traceback on an error: it's useful debugging
> information, not random cruft. Post it too.
>
> FWIW, I suspect you wanted to do this:
>
> t = Test(**layer_mapping)
> t.layer_id = S
> t.save()
> --
> DR.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/mELn7nUrAOMJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
*Satyajit Sarangi*

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



Re: django.db.utils.IntegrityError: null value in column “layer_id_id” violates not-null constraint . How to debug ?

2011-06-16 Thread Daniel Roseman
On Wednesday, 15 June 2011 22:25:24 UTC+1, Satyajit Sarangi wrote:
>
> his is my models.py 
>
> from django.db import models 
>
> class Sdr_Layer(models.Model): layer_name = 
> models.CharField(max_length = 100) 
> layer_attribute_name=models.CharField(max_length=100) 
>
> # This is an auto-generated Django model module created by ogrinspect. 
> from django.contrib.gis.db import models 
>
>
>
>
>
>
>
>
> # This is an auto-generated Django model module created by ogrinspect. 
> from django.contrib.gis.db import models 
>
> class Test(models.Model): 
> layer_id= models.ForeignKey(Sdr_Layer) 
> name = models.CharField(max_length=80) 
> descriptio = models.CharField(max_length=80) 
> geom = models.PolygonField(srid=4326) 
> objects = models.GeoManager() 
> S = Sdr_Layer(layer_name="Test") 
>
> # Auto-generated `LayerMapping` dictionary for Test model 
> test_mapping = { 
> 'name' : 'Name', 
> 'descriptio' : 'Descriptio', 
> 'geom' : 'POLYGON25D', 
> } 
> S.layer_attribute_name=test_mapping 
> S.save(); 
>
> When I am trying to load data to Test model , it throws me a not_null 
> error on layer_id which is the foreign key here . I basically want the 
> primary key of Sdr_Layer to act as a foreign key here . Sdr_Layer 
> table does have values . So , why such an error ?



On Wednesday, 15 June 2011 22:25:24 UTC+1, Satyajit Sarangi wrote:
>
> his is my models.py 
>
> from django.db import models 
>
> class Sdr_Layer(models.Model): layer_name = 
> models.CharField(max_length = 100) 
> layer_attribute_name=models.CharField(max_length=100) 
>
> # This is an auto-generated Django model module created by ogrinspect. 
> from django.contrib.gis.db import models 
>
> # This is an auto-generated Django model module created by ogrinspect. 
> from django.contrib.gis.db import models 
>
> class Test(models.Model): 
> layer_id= models.ForeignKey(Sdr_Layer) 
> name = models.CharField(max_length=80) 
> descriptio = models.CharField(max_length=80) 
> geom = models.PolygonField(srid=4326) 
> objects = models.GeoManager() 
> S = Sdr_Layer(layer_name="Test") 
>
> # Auto-generated `LayerMapping` dictionary for Test model 
> test_mapping = { 
> 'name' : 'Name', 
> 'descriptio' : 'Descriptio', 
> 'geom' : 'POLYGON25D', 
> } 
> S.layer_attribute_name=test_mapping 
> S.save(); 
>
> When I am trying to load data to Test model , it throws me a not_null 
> error on layer_id which is the foreign key here . I basically want the 
> primary key of Sdr_Layer to act as a foreign key here . Sdr_Layer 
> table does have values . So , why such an error ?


You need to think things through a bit more carefully. It seems like you're 
randomly assigning things without really having any idea of what you're 
doing.

This code:
S = Sdr_Layer(layer_name="Test") 
instantiates a new Sdr_Layer object, with the name "Test".

This line:
S.layer_attribute_name=test_mapping 
tries to do something very strange, which is to assign a dictionary to your 
CharField. You can do that, but it will be converted to a string on save.

Now, none of this code would throw a "not_null error on layer_id", because 
layer_id is a field on the Test model, which you don't even use in this 
code. So, there must be code you're not showing us. Also, there is a reason 
why Python prints the full traceback on an error: it's useful debugging 
information, not random cruft. Post it too.

FWIW, I suspect you wanted to do this:

t = Test(**layer_mapping)
t.layer_id = S
t.save()
--
DR.

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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Kenneth Gonsalves
On Thu, 2011-06-16 at 10:10 +0200, Benedict Verheyen wrote:
> user = models.ForeignKey(User, unique=True)

you need onetoone for this to work.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Should/Can I use API methods for other views? (django-piston)

2011-06-16 Thread Ivo Brodien
I was wondering if I can/should access the API methods I use with django-piston.

Lets say I want to get some objects belonging to a user in the read API method.

On a web request that does not use the API call but is a simple request from a 
browser client should my view than call the read method of the handler so i 
don’t repeat myself?

Or should I even make another method which will be called by the APIs read 
method and my other view which serves html?

Probably the latter, right? Now that I think of it, this method could probably 
be one of a custom Manager for my model.

thanks for clarification


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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Ivo Brodien
an idea: Do you have a __init__.py  in every subfolder? also the models and 
userprofile folder under calltracking_main ?


On Jun 16, 2011, at 10:10 AM, Benedict Verheyen wrote:

> Hi,
> 
> 
> The syncdb command doesn't want to create the UserProfile table.
> Also when I was trying to get this working while running the app,
> it was complaining about AUTH_PROFILE_MODULE.
> It is however correctly specified in my settings.py:
> ...
> AUTH_PROFILE_MODULE = 'calltracking_main.UserProfile'
> ...
> Installed apps is ok:
> INSTALLED_APPS = (
>'django.contrib.auth',
>...
> 'calltracking.calltracking_main',
> )
> 
> model:
> class UserProfile(models.Model):
>class Meta:
>verbose_name = _('UserProfile')
>verbose_name_plural = _('UserProfiles')
>db_table = 'calltracking_userprofile'
>ordering = ('displayname',)
>app_label = 'calltracking'
>displayname = models.CharField(max_length=50)
>department = models.CharField(max_length=30, blank=True)
>user = models.ForeignKey(User, unique=True)
>def __unicode__(self):
>return self.displayname
> 
> As I split models, I have to specify this in the __init__.py file:
> ...
> from calltracking_main.models.userprofile import UserProfile
> ...
> 
> I don't know if this is relevant, but here's my wsgi:
> import sys
> import os
> 
> apache_dir = os.path.dirname(os.path.abspath(__file__))
> project_dir = os.path.normpath(os.path.join(apache_dir + '/../..'))
> app_dir = os.path.normpath(os.path.join(apache_dir + '/..'))
> 
> sys.path = [
>os.path.join(project_dir, 'lib/python2.7/site-packages'),
>project_dir,
>app_dir
>] + sys.path
> 
> os.environ['DJANGO_SETTINGS_MODULE'] = 'calltracking.settings'
> 
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
> 
> 
> So syndb doesn't pick up on the UserProfile, what am I doing wrong?
> Can I force recreation of the model? I have delete the whole db but still no 
> luck.
> I upgraded Django (tracking trunk) but that wasn't a sollution either.
> 
> Weird thing is that this code is a fork from another project (very minor 
> differences)
> and there, I didn't encounter any errors.
> Both projects run on virtualhosts specified in apache with 
> wsgi/nginx/memcached,
> from a virtualenv.
> 
> Thanks for any info,
> 
> Regards,
> Benedict
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: syncdb doesn't create UserProfile table

2011-06-16 Thread Jani Tiainen
On Thu, 2011-06-16 at 10:10 +0200, Benedict Verheyen wrote:
> Hi,
> 
> 
> The syncdb command doesn't want to create the UserProfile table.
> Also when I was trying to get this working while running the app,
> it was complaining about AUTH_PROFILE_MODULE.
> It is however correctly specified in my settings.py:
> ...
> AUTH_PROFILE_MODULE = 'calltracking_main.UserProfile'
^   app named
"calltracking_main"

> Installed apps is ok:
> INSTALLED_APPS = (
> 'django.contrib.auth',
> ...
>  'calltracking.calltracking_main',
> )
>
> model:
> class UserProfile(models.Model):
> class Meta:
> verbose_name = _('UserProfile')
> verbose_name_plural = _('UserProfiles')
> db_table = 'calltracking_userprofile'
> ordering = ('displayname',)
> app_label = 'calltracking'
 ^^ Only "calltracking"

> displayname = models.CharField(max_length=50)
> department = models.CharField(max_length=30, blank=True)
> user = models.ForeignKey(User, unique=True)
> def __unicode__(self):
> return self.displayname
> 
> As I split models, I have to specify this in the __init__.py file:
> ...
> from calltracking_main.models.userprofile import UserProfile
> ...

Note that you have specified app name for UserProfile as "calltracking"
but referring it (settings at least) as appname "calltracking_main".


Probably fixing appname in model would fix all other issues as well.

-- 

Jani Tiainen


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



syncdb doesn't create UserProfile table

2011-06-16 Thread Benedict Verheyen
Hi,


The syncdb command doesn't want to create the UserProfile table.
Also when I was trying to get this working while running the app,
it was complaining about AUTH_PROFILE_MODULE.
It is however correctly specified in my settings.py:
...
AUTH_PROFILE_MODULE = 'calltracking_main.UserProfile'
...
Installed apps is ok:
INSTALLED_APPS = (
'django.contrib.auth',
...
 'calltracking.calltracking_main',
)

model:
class UserProfile(models.Model):
class Meta:
verbose_name = _('UserProfile')
verbose_name_plural = _('UserProfiles')
db_table = 'calltracking_userprofile'
ordering = ('displayname',)
app_label = 'calltracking'
displayname = models.CharField(max_length=50)
department = models.CharField(max_length=30, blank=True)
user = models.ForeignKey(User, unique=True)
def __unicode__(self):
return self.displayname

As I split models, I have to specify this in the __init__.py file:
...
from calltracking_main.models.userprofile import UserProfile
...

I don't know if this is relevant, but here's my wsgi:
import sys
import os

apache_dir = os.path.dirname(os.path.abspath(__file__))
project_dir = os.path.normpath(os.path.join(apache_dir + '/../..'))
app_dir = os.path.normpath(os.path.join(apache_dir + '/..'))

sys.path = [
os.path.join(project_dir, 'lib/python2.7/site-packages'),
project_dir,
app_dir
] + sys.path

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

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


So syndb doesn't pick up on the UserProfile, what am I doing wrong?
Can I force recreation of the model? I have delete the whole db but still no 
luck.
I upgraded Django (tracking trunk) but that wasn't a sollution either.

Weird thing is that this code is a fork from another project (very minor 
differences)
and there, I didn't encounter any errors.
Both projects run on virtualhosts specified in apache with wsgi/nginx/memcached,
from a virtualenv.

Thanks for any info,

Regards,
Benedict

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