Matching query does not exist

29 views
Skip to first unread message

Ivan Martić

unread,
Jan 18, 2019, 4:25:52 AM1/18/19
to Django users
Hi all,
 i am having trouble to get this query on db table right. 
I am always getting error.

Please check shell erorr attached.

I appreciate your help!




models.txt
shell-error.txt
query.txt

Kasper Laudrup

unread,
Jan 18, 2019, 4:49:56 AM1/18/19
to django...@googlegroups.com
Hi Ivan,

On 1/18/19 10:25 AM, Ivan Martić wrote:
> Hi all,
>  i am having trouble to get this query on db table right.
> I am always getting error.
>

In your definition of the Material model, the materialid field is
defined like this:

materialid = models.CharField(db_column='MaterialID', max_length=10)

Whereas you refer to it in Productgroupinput like this:

materialid = models.ForeignKey(Material, on_delete=models.CASCADE,
db_column='Materialid', max_length=10)

Notice the difference in the db_column parameter?

I guess that could be the cause of your error.

Kind regards,

Kasper Laudrup


Aditya Singh

unread,
Jan 18, 2019, 4:51:22 AM1/18/19
to django...@googlegroups.com
😃




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8daaaf0f-17c3-69c5-8b86-915df7ba348e%40stacktrace.dk.

For more options, visit https://groups.google.com/d/optout.

Ivan Martić

unread,
Jan 18, 2019, 4:59:21 AM1/18/19
to Django users
Thank you Kasper, 

i have copied that model after doing inspectdb. So it should be set by default from django that way. Usually all was ok..
Also, i have tried that  change now and got the same result.

Any other idea where i gone wrong?

Kasper Laudrup

unread,
Jan 18, 2019, 5:16:21 AM1/18/19
to django...@googlegroups.com
Hi Ivan,

On 1/18/19 10:59 AM, Ivan Martić wrote:
> Thank you Kasper,
>

You're welcome.
Sorry, not really. I'm wondering why you are specifying your database
columns explicitly though? I've never had a need for that, but I'm far
from being very experienced with Django.

Hopefully someone else can help you.

Kind regards,

Kasper Laudrup

Ivan Martić

unread,
Jan 18, 2019, 5:23:21 AM1/18/19
to django...@googlegroups.com
Hi,

im not sure that i understand "specifying your database columns explicitly".
I have connected to existing MSSQL database so i had to adapt my model due to that. Just copied model from inspectdb and added:
- def __str__
-ForeignKey(class name, on delete=models.CASCADE)    xtimes for materialid and group.

I am not so experience  as you :) but i think you are on the good lead.
I am watching this case :
Seems like same issue, same error occured.
What do you think?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Kasper Laudrup

unread,
Jan 18, 2019, 5:27:11 AM1/18/19
to django...@googlegroups.com
Hi again Ivan,

On 1/18/19 11:22 AM, Ivan Martić wrote:
> im not sure that i understand "specifying your database columns explicitly".
> I have connected to existing MSSQL database so i had to adapt my model
> due to that.

That's exactly what I mean :-)

I don't have any experience with using existing database models with
Django (I just let Django take care of handling database entries).

Hopefully someone else can help you.

Best of luck.

Kasper Laudrup
Reply all
Reply to author
Forward
0 new messages