Getting values set across relation spanning multiple tables

2009-09-03 Thread bvemu

Hi

I needed a query to get the values set of a model which has multiple
child models like below

class Vehicle(models.Model):
 vehicle_pkey = models.OneToOneField(User, primary_key=True,
parent_link=True)
 vehiclename=models.CharField(max_length=20)

class no_of_tyres(models.Model):
   no_of_tyres_pkey=models.ForeignKey
(Vehicle,related_name='no_of_tyres_relatedname')
   numberoftyres=models.IntegerField()

class brand_name(models.Model):
   brand_name_pkey=models.ForeignKey
(Vehicle,related_name='brand_name_relatedname')
   brandname=models.CharField(max_length=20)

My first question is
Can I get all the details of the models into a single values set like
below
query_which_I_dont_know.values
('username','vehiclename','numberoftyres','brandname')


To complicate further imagine I have one more field in brand_name
which is cost

class brand_name(models.Model):
   brand_name_pkey=models.ForeignKey
(Vehicle,related_name='brand_name_relatedname')
   brandname=models.CharField(max_length=20)
   costofvehicle=models.IntegerField()

My second question is
 say I want to obtain the values set (as in the above query ) of
all the vehicle whose cost is >1000 and  which has 4 numberoftyres how
can I get it

Thanks in advance

Regards
Subramanyam

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



Clarification required on one-to-one save method

2009-08-18 Thread bvemu

Hi All


To maintain a 1-1 relation with User table I have defined the
following in my models


class UserDetails(models.Model):
user_id = models.OneToOneField(User, primary_key=True,
parent_link=True)
choices= models.PositiveSmallIntegerField(null=False,
blank=False, choices=menu_filler(choice_list))

My query is : Inorder to enforce/ensure that a one to one relation
w.r.t UserDetails/User records exists
which of the following is a better practise and why

1.) Override the Save method in Class UserDetails:
like

def save():
   #create the user
   #create the userdetails

2.) Write a method in extendedmanager of UserDetails
like

class MyManager()
   # create the user
   # create the record


class UserDetails():
objects=MyManager()


Thanks in advance

Regards
Subramanyam
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Can I link python editor IDLE 1.2.4 to python manage.py shell

2009-08-06 Thread bvemu

Hi

Is there any way to launch IDLE 1.2.4  (a python IDE  on windows and
comes default with python installation)
when we want to launch a shell from manage.py

for example
# python manage.py shell
should open up IDLE with the appropriate env variables set


Thanks in advance

Regards
Subramanyam
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Retrieving the values from query set

2009-08-02 Thread bvemu

Hi

In my project I want to store an integer as the username

To randomly allocate a new username I need the list of available
usernames (integer type list)

I tried the following ways

user_list=[]
user_list=list(User.objects.values('username').order_by('username'))

and when I try to print the values of list , it actually represents a
string like ('fieldname':'value')

>>> fun(user_list)
{'username': u'1'}
{'username': u'103'}
{'username': u'11'}
{'username': u'121'}
{'username': u'13'}
{'username': u'13421'}
{'username': u'1342323221'}
{'username': u'1342333661'}
{'username': u'134563661'}

Is there a django way of retrieving only the values as a list  and not
the fieldname


Thanks in advance

Subramanyam


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



Issue on using emailID as the username

2009-06-23 Thread bvemu

Hi

I was using the email ID as the username as shown below in my view.py


view.py
--
def signup(request)
..
  username=emailid ;
  valid_user = authenticate
(username=username,password=password  )
..

and it works fine for me

Django version being the development version

# django-admin.py --version
1.1 beta 1 SVN-10957



1.) The problem is in the admin interface "@" is not accepted as
username while I can populate the same from the view.py
Is this an expected behaviour or should I raise a ticket ( if at all
it doesnt exists )

2.) Do we have a configuration file or so where we can define these
constraints like max_length of user name, accepted character set  in
the user name and others.
I can very well change the code in django-trunk of my web server,  but
I dont want to do that since I want to avoid the overhead of re-doing
the svn tasks

Thanks
Subramanyam
--~--~-~--~~~---~--~~
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 use email instead of username for user authentication?

2009-06-22 Thread bvemu

Hi

Further to the above discussion,
  I did implement the code and it worked for me for the authentication
while using the email id as the username
(username=emailid ; valid_user = authenticate (username=username,
password=password  )

# django-admin.py --version
1.1 beta 1 SVN-10957

1.) The problem is in the admin interface "@" is not accepted as
username while I can populate the same from the view.py
Is this an expected behaviour or should I raise a ticket ( if at all
it doesnt exists )

2.) Do we have a configuration file or so where we can define these
constraints like max_length of user name, accepted characters set  in
the user name and others.
I can very well change the code in django-trunk of my web server,  but
I dont want to do that since I want to avoid the overhead of re-doing
the svn tasks

Thanks
Vemu


On Apr 13, 11:22 am, Praveen  wrote:
> You please check the satchmo package there they are using email as
> username in satchmo-registration using
> user=generate_id(email,firstname)
>
> On Apr 13, 9:44 am, pkenjora  wrote:
>
> > Malcolm,  <- Remembered the 'l' this time!
>
> > To keep things simple and avoid fragmenting this discussion into a
> > million different dead end tit for tats , I'll try to reign in the
> > main points.
>
> > 1. The default authentication method in Django should have no inherent
> > restrictions.  Such as blocking '@' in the username.  This leaves the
> > default framework open and free of workarounds.  This approach would
> > not preclude any project specific requirements.
>
> > 2. Any authentication method having restrictions should be an opt in
> > method.  The current method is a restrictive authentication method,
> > one that does not allow email, and should be made optional.
>
> > 3. When you boil down the hundreds of specific use cases out there you
> > still end up with the above two points.  In which case I would make
> > the argument that if you need to block emails as user names then it is
> > you who should write a new authentication handler.  In your own words,
> > the framework allows this and its only a few lines of code.
>
> > Now for the dead end tit for tat... this is really project philosophy
> > not framework philosophy... hence I feel like it is circular
> > discussion that distracts from the main point...
>
> > Authenticating by email does not require me to check my email every
> > time I log in.  So if my email is no longer accessible (left my job) I
> > can simply log in and change it to a new one.  If changing the
> > username requires checking my email then I will have the same problem
> > if I use email as my username or not.
>
> > You yourself identify the username as mainly an authentication
> > mechanism not necessarily a display value.  Thats all the more reason
> > to have a robust restriction free out of the box implementation of
> > authentication.
>
> > Thanks for reading the feedback, I still fail to see how you can
> > include project specific requirements in a framework? The
> > implementation you are advocating is a subset of the general
> > implementation I would like to see bundled out of the box.  Why not
> > move it into an optional module?
>
> > -Paul
>
> > On Apr 11, 4:13 pm, Malcolm Tredinnick 
> > wrote:
>
> > > On Sat, 2009-04-11 at 07:52 -0700, pkenjora wrote:
> > > > Malcom,
>
> > > Well, I'm not "Malcom" (sic), but I'll reply anyway.
>
> > > >    Google, FaceBook, and LinkedIn have been using email authentication
> > > > for how long now?  With the default constraints you've put on Django a
> > > > developer would have to "work around" the out of the box code to make
> > > > the project behave like the big 3 names on the web.
>
> > > There's some assumption there that what they're doing is a good idea.
> > > Their systems have the usability problems I've mentioned. It's also not
> > > clear their authentication methods are the best around. In any case, as
> > > I note below (and have written elsewhere), you're simply not restricted
> > > from using this system and can do so without patching Django, if that's
> > > the way you want to go. There's no restriction in place here!
>
> > > The combined size of forums and social networking sites not pretending
> > > that my "handle" is an email address is, I'll wager, larger than
> > > Facebook or LinkedIn, certainly. Which has precisely the same small
> > > weight as your examples. The point being that there are valid use-cases
> > > in both directions and you'll notice that that's never been disputed.
>
> > > [...]
>
> > > >   As far as your reasons go, I'm fairly sure its just as easy to
> > > > change the email as it is the username,
>
> > > I'm sorry you feel that way. It's patently false. The username is only
> > > used on the site you are creating an account for. Your email address has
> > > much wider usage and creating a new one isn't always possible or
> > > desirable (signing up to 

python manage.py dbshell throws error

2009-05-14 Thread bvemu

Hi  All

I am executing the command  "python manage.py dbshell" and it throws
the following error
"Profiling timer expired"


I have an alias in my .bashrc  of
alias mysql='mysql -u subramanyam -pxxx'
Tried unaliasing mysql but didnt work whereas it works fine from
command line

Any pointers on this would be helpful

Thanks in Advance
-Vemu
--~--~-~--~~~---~--~~
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 setup problem when executing syncdb

2009-03-02 Thread bvemu

Hi All

I apologise for posting a wrong answer , thanks karen for correcting
it

btw is it also applicable on linux I have been searching for MySQLdb
for python 2.6 on linux and could not find it

Thanks
Vemu

On Mar 2, 10:34 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Mon, Mar 2, 2009 at 12:03 PM, bvemu <balu.v...@gmail.com> wrote:
>
> > Hi Ches
>
> > The issue is that you are using python version 2.6  for which there is
> > no  support from the MySQLdb package
>
> This is not true.  A pointer to a binary of MySQLdb for Python 2.6 on
> Windows was posted a while ago, AKK referred to it earlier in this thread:
>
> http://groups.google.com/group/django-users/msg/5b5f4dee148d0fc3
>
> I have tried this (just a brief test, my "real" use of Django/MySQL is on
> Linux, not Windows) and it worked fine, excepting some Deprecation warnings
> for use of sets, but that is harmless.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 setup problem when executing syncdb

2009-03-02 Thread bvemu

Hi Ches

The issue is that you are using python version 2.6  for which there is
no  support from the MySQLdb package
so you have to downgrade your python version to 2.5.4 and let your
PYTHONPATH point to that  (for example I am using SLE 11.1 henceforth
placed the bin of python 2.5.4 in my /home/subramanyam/bin directory
and it worked  )

Regards
Vemu


ches wrote:
> Dear All,
> I have install Python2.6,Django 1.0.2, I'm sure it is installed
> ok,since there is no errors on "import django" from the
> interpreter,however when executing syncdb, I got:
>
> C:\Django\projects\documenti>manage.py syncdb
> Traceback (most recent call last):
>   File "C:\Django\projects\documenti\manage.py", line 11, in 
> execute_manager(settings)
>   File "C:\Python26\lib\site-packages\django\core\management
> \__init__.py", line
> 340, in execute_manager
> utility.execute()
>   File "C:\Python26\lib\site-packages\django\core\management
> \__init__.py", line
> 295, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "C:\Python26\lib\site-packages\django\core\management\base.py",
> line 192,
>  in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "C:\Python26\lib\site-packages\django\core\management\base.py",
> line 218,
>  in execute
> self.validate()
>   File "C:\Python26\lib\site-packages\django\core\management\base.py",
> line 246,
>  in validate
> num_errors = get_validation_errors(s, app)
>   File "C:\Python26\lib\site-packages\django\core\management
> \validation.py", lin
> e 22, in get_validation_errors
> from django.db import models, connection
>   File "C:\Python26\lib\site-packages\django\db\__init__.py", line 16,
> in  e>
> backend = __import__('%s%s.base' % (_import_path,
> settings.DATABASE_ENGINE),
>  {}, {}, [''])
>   File "C:\Python26\lib\site-packages\django\db\backends\mysql
> \base.py", line 13
> , in 
> raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> module: No mo
> dule named MySQLdb
>
> Do you have an idea?
>
> Kind Regards,
>ches
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---