Thursday, December 30, 2010

Attempting to save instance with null ID?

I'm migrating from SQLite to Oracle, and I'm getting an error thrown on the line disn_requisition.save() claiming that it has a null ID. I have not attempted to manually set or fiddle with id fields on any model, although I do read them.

Any insight on what I need to do to address this?

IntegrityError at /upload/storage

ORA-01400: cannot insert NULL into ("INVDB"."INVDB_DISK_REQUISITION"."ID") 
Request Method: POST
Request URL: http://cmlnxbld01:8000/upload/storage
Django Version: 1.2.3
Exception Type: IntegrityError
Exception Value:
ORA-01400: cannot insert NULL into ("INVDB"."INVDB_DISK_REQUISITION"."ID") 
Exception Location: /tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django/db/backends/oracle/base.py in execute, line 507
Python Executable: /tools/python/2.7/Linux_x86_64/bin/python
Python Version: 2.7.0
Python Path: ['/home/jhayward/invdb', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django_filter-0.5.3-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/ez_setup-0.9-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/distribute-0.6.14-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/hgsvn-0.1.8-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/paramiko-1.7.6-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/pycrypto-2.3-py2.7-linux-x86_64.egg', '/tools/python/cx_Oracle/10g/2.6/Linux_x86_64/lib/python2.6/site-packages', '/home/jhayward', '/home/jhayward/invdb/HOME_DIRECTORY', '/home/jhayward/invdb/HOME_DIRECTORY/invdb', '/tools/python/2.7/Linux_x86_64/lib/python27.zip', '/tools/python/2.7/Linux_x86_64/lib/python2.7', '/tools/python/2.7/Linux_x86_64/lib/python2.7/plat-linux2', '/tools/python/2.7/Linux_x86_64/lib/python2.7/lib-tk', '/tools/python/2.7/Linux_x86_64/lib/python2.7/lib-old', '/tools/python/2.7/Linux_x86_64/lib/python2.7/lib-dynload', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Server time: Thu, 30 Dec 2010 10:04:24 -0600

--
Christos Jonathan Hayward
Christos Jonathan Hayward, an Orthodox Christian author.

Author Bio • Books • Email • Facebook • LinkedIn • Twitter • Web • What's New?

I invite you to visit my "theology, literature, and other creative works" site.

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

Re: django using wrong python???

2010/12/30 ozgur yilmaz <yelbuke@gmail.com>:
> I have Centos, and it comes with python2.4(sorry, not 2.5). I installed
> python2.6 and django is under:

I work with CentOS too but installing different python versions in
parallel seemed like a lot of unnecessary work to maintain. So I
developed python-schizoid [0], a script that installs a virtual
environment with python 2.7, django trunk and many other useful
software.

It tries to install as much software inside the virtual environment as
possible to avoid depending on the (old) software installed on the
system. The only thing it does not install is the database engine.

Working like this makes packaging and deploying *a lot* easier because
your whole project and its dependencies (and even the python binaries)
are inside one directory. You also have the script bin/activate that
sets some useful environment variables that help working inside the
environment.

I know this doesn't actually answers your question but I thought you
may find it useful.

Regards,

[0] https://github.com/tooxie/python-schizoid

--
Alvaro Mouriño
http://askani.net/

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

Re: Linux password authentication for django



On Thu, Dec 30, 2010 at 4:41 PM, Marc Aymerich <glicerinu@gmail.com> wrote:


On Thu, Dec 30, 2010 at 4:24 PM, Marc Aymerich <glicerinu@gmail.com> wrote:


On Thu, Dec 30, 2010 at 6:35 AM, Bill <billchen001@gmail.com> wrote:
Hi there,

I want to know is there any authentication module base on Linux passwd/
shadow file for django?

import pam from django.contrib.auth.models import User 
class PamBackend:
    def authenticate(self, username=None, password=None):         # Check the username/password and return a User.         if pam.authenticate(username, password, service='login'):              try:                 return User.objects.get(username=username)             except User.DoesNotExist:                 pass         return None 


ouch, I misunderstood your question. if you're using mysql as a db backend for you django project, you can use pam-mysql http://pam-mysql.sourceforge.net/ for the authentication on your servers. 

also you can look for libpam-mysql package on your distro. repositories .  

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

Re: ModelForm validation

Alex

And I seem to have been equally unclear :}

I agree that cleaned_data is only available after is_valid() - the
point being that your form *will* be valid if you have set the value
for that field in a hidden input. I do not see that this can be a
"security risk" - the default that you are setting beforehand is a
dummy (meaningless) value which, in any case, you are going to be
overriding. How is this done? Consider this example from the Django
Book (http://www.djangobook.com/en/1.0/chapter07/):

def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
topic = form.clean_data['topic']

Now if you wanted to overide the topic, you could instead have:
topic = 'my custom text'


Hope this is clearer!

Derek

On Dec 29, 4:07 pm, Axel Bock <mr.axel.b...@gmail.com> wrote:
> hi derek,
>
> thanks for your hints - was I really that unclear? hm.
>
> anyway, could you please give an example about how to "override/check the
> value for that field after the form POST"? I don't seem to be able to do
> that, and believe me, I have read the docs.
>
> I think cleaned_data is only available after is_valid() was called, but
> is_valid() throws an exception because the required field is missing - and I
> can't set it.
>
> The hidden field thing is the last thing I wanted to try. bad style, you
> know :) , cause security risk.
>
> thanks!
> Axel.
>
> 2010/12/29 derek <gamesb...@gmail.com>
>
>
>
>
>
>
>
> > Axel
>
> > Not sure I have followed all your requirements, but perhaps you can
> > try:
> > * set a default value for the required field
> > * mask the required field on the form being shown to the user (make it
> > hidden)
> > * override/check the value for that field after the form POST and data
> > "clean" (see:
> >http://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs#proce...
> > )
>
> > HTH
> > Derek
>
> > On Dec 28, 10:21 pm, Axel Bock <justsomeoneoutth...@gmail.com> wrote:
> > > Hi all,
>
> > > I have this little problem. In my little webapp I have a data model which
> > > defines several required fields. Depending on WHO is logged on, some of
> > > these fields should not be changed by the user and be pre-filled (or
> > better:
> > > post-filled) by the application.
>
> > > Currently I delete the fields out of the formset like this:
> > >             # prevent entering missions for all other bases
> > >             del missionform.fields['base']
>
> > > so the field gets not rendered in the view. Which works nicely.
>
> > > Unfortunately base is required, so the validation fails. Now how can I
> > > insert the missing values into the POST data? I tried this:
> > >         if request.user.userflag.is_student:
> > >             logging.error("studen")
> > >             inst=FlownMission(
> > >                 student=request.user,
> > >                 base=request.user.studentinfo.current_base
> > >             )
> > >         flownmission = FlownMissionForm(request.POST, instance=inst)
>
> > > which does not work at all :( . The validation fails all the time ... . I
> > > just need to inject 2 required values somewhere in the POST data, but I
> > have
> > > no clue how.
>
> > > Any help would be greatly appreciated, and I am a total django "newb" ...
> > :)
>
> > > Thanks & greetings,
> > > Axel.
>
> > --
> > 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+unsubscribe@googlegroups.com<django-users%2Bunsubscribe@google groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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

Re: Linux password authentication for django



On Thu, Dec 30, 2010 at 4:24 PM, Marc Aymerich <glicerinu@gmail.com> wrote:


On Thu, Dec 30, 2010 at 6:35 AM, Bill <billchen001@gmail.com> wrote:
Hi there,

I want to know is there any authentication module base on Linux passwd/
shadow file for django?

import pam from django.contrib.auth.models import User 
class PamBackend:
    def authenticate(self, username=None, password=None):         # Check the username/password and return a User.         if pam.authenticate(username, password, service='login'):              try:                 return User.objects.get(username=username)             except User.DoesNotExist:                 pass         return None 


ouch, I misunderstood your question. if you're using mysql as a db backend for you django project, you can use pam-mysql http://pam-mysql.sourceforge.net/ for the authentication on your servers. 



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

Re: Linux password authentication for django



On Thu, Dec 30, 2010 at 6:35 AM, Bill <billchen001@gmail.com> wrote:
Hi there,

I want to know is there any authentication module base on Linux passwd/
shadow file for django?

  import pam from django.contrib.auth.models import User 
class PamBackend:
    def authenticate(self, username=None, password=None):         # Check the username/password and return a User.         if pam.authenticate(username, password, service='login'):              try:                 return User.objects.get(username=username)             except User.DoesNotExist:                 pass         return None 
 
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: django using wrong python???

you can try ln -s python2.6 to default python, and then modify the yum script to python2.4.
--


On Thu, Dec 30, 2010 at 10:53 PM, ozgur yilmaz <yelbuke@gmail.com> wrote:
I have Centos, and it comes with python2.4(sorry, not 2.5). I installed python2.6 and django is under:

/usr/lib/python2.4/site-packages/django
/usr/lib/python2.6/site-packages/django

i defined alias in bash_profile, so when i give "python" command from shell, python2.6 works...

2010/12/30 Robbington <robbington@hotmail.co.uk>

Why/how have you two versions of Python installed?

Where is Django installed?

Rob

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