Hi,

  Are you wrapping the insert statement in a Try?  First, make sure
you're doing that.

  Also, add a parameter after "except Exception" like so:

try:
   instance = TableClassName.(field="a value",
user_id=request.user.id)
   instance.save()

except Exception, msg <--- add this
   print msg


The output of msg will tell you exactly what's going on.

(Make sure also you're including all of the fields that are "not
null", but I'm guessing that particular error would cause the full-
page development error output that Django gives you.)

Steve



On May 18, 8:37 am, beetlecube <sitecontac...@gmail.com> wrote:
> ( Not sure what happened to the post, the subject appeared, but post
> content is missing)
> -------------------------------------------------------------------------
> Hi I am currently using 1.1:
>
> For the first time, I'm using a table without the built in
> autoincrement field. As we know, the way to tell Django -not- to use
> the "id" is to manually specify one of the fields as primary_key=True.
>
> Here is my table:
>
> class Rssitem(models.Model):
>     url_key = models.CharField(max_length=40, primary_key=True)
>     title = models.CharField(max_length=1024)
>     date_to_resend = models.DateTimeField()
>     user = models.ForeignKey(User)
>
> When I run the app and my View function is called - the one that
> inserts a record into the table - the insert never happens.
>
> I get no error while watching the console.   I know that the values to
> be inserted into the table, are being passed into the view, via my
> print statements.
>
> Would this be related to some other configuration I'm not taking care,
> due to me breaking the usual mold of not allowing Django to use the
> 'id' field?
>
> The postgresql schema:
>
> CREATE TABLE rssitem
> (
>   url_key character varying(40) NOT NULL,
>   title character varying(1024) NOT NULL,
>   date_to_resend timestamp with time zone NOT NULL,
>   user_id integer NOT NULL,
>   CONSTRAINT rssitem_pkey PRIMARY KEY (url_key),
>
>   CONSTRAINT rssitem_user_id_fkey FOREIGN KEY (user_id)
>       REFERENCES auth_user (id) MATCH SIMPLE
>       ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY
> DEFERRED
> )
> WITH (OIDS=FALSE);
> ALTER TABLE rssitem OWNER TO postgres;
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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

Reply via email to