Django: module 'django_mysql.models' has no attribute 'JSONField'? - mysql

I'm running Django 4.0. I've got a models with fields declared like this:
industries = models.JSONField()
On MakeMigration, Django is throwing the error:
module 'django_mysql.models' has no attribute 'JSONField'
There are at least 3 previous SO posts on this. They advise using Django's models.JSONField(), which I am doing.
I'm using:
Django 4.0
Python 3.9.13
django-mysql 4.7.0
Why am I getting this error message?
Update
Possibly relevant somehow: the error is being thrown in an old migration file from 2019.

Thanks to Willem Van Onsem for the answer. He pointed out that I must still be referencing django_mysql.models.JSONField somehow. Sure enough, I had old migration files that were doing that. (And here's the SO thread about how to fix that.)
#Willem, if you'd like to post your comment in the form of an answer here, I will mark it as the accepted answer.

Related

Upgraded to angular 9.1 - error is Property 'supportsDOMEvents'

Here is the issue
error TS2416: Property 'supportsDOMEvents' in type 'ɵangular_packages_platform_browser_p
latform_browser_o' is not assignable to the same property in base type 'ɵDomAdapter'.
As #DrTeeth already mentioned, it's hard to help w/o any further infos.
But I've had a similar problem and want to share what had helped for me: This was a simple inconsistency of my dependencies. I', using a 3rd party Angular Component Library which was incompatible with the newer (Ivy-enabled) version, after I updated Angular itself. For me, the error message had some details about the package in question and after updating it, too, everything worked fine.

Cakephp 3.1 have issues with PHP7.2

I have develop my web application by using cakephp 3.1. My service provider has update the php version to 7.2. Now my application is not work well, as it was working with PHP5.6, Its showing different warnings with debug=true; and the big problem is its not showing line which have some problem, if some is there. Here is warning message.
Warning: count() [function.count]: Parameter must be an array or an object that implements Countable in D:\xampp7\htdocs\bighris\vendor\cakephp\cakephp\src\Database\QueryCompiler.php on line 115
In case some errors are there its not showing it, in the following way, there I can't find the line number and the file which have the problem.
https://www.screencast.com/t/qIQB1YIW
Please help me to solve the issue, Thanks
As per the Cakephp github issues:
PHP 7.2 has changed count's behavior
that's why you are getting errors.
PHP 7.2 has changed count's behavior causing problems with QueryCompiler
You can follow the below link or change your PHP version to 7.1 or less to resolve this issue.
Stop warnings when using count in QueryCompiler in PHP 7.2
it looks like you are passing some wrong data to count function, guess you are passing some query directly to count. Or something like that.
If you may show the code of the controller you are facing issue it may be a great help.
there is solution for you....
2020-09-30 06:22:30 Warning: Warning (2): count() [function.count]: Parameter must be an array or an object that implements Countable in [D:\xampp\htdocs\gym_master\vendor\cakephp\cakephp\src\Database\QueryCompiler.php, line 126]
please check your php version...

Not able to use built-in models i.e. "user", error: no response from server

I have created many models in loopback for my project. And use these models with the help of "http://localhost:3000/explorer" in my browser.
These model API's are working fine. But, whenever I tried to use built-in models i.e "user" from the explorer. I got the below error:
and in the terminal. I got the below error. And terminal command automatically terminates.
I am new in the loopback. Why am I not able to use built-in models "user".
Please, help me.
Thanks in advance.
To anyone else that encounters this, I ran into this today and found this question unanswered, so I will do my best to give my explanation and findings here.
The error, roleModel.isInRole is not a function, means simply that the role model does not have a function called isInRole.
In my case, this was because another model was automatically generated from an existing database table called Role, which overrode the internal Role model of Loopback.
When the internal Role model is overridden, the isInRole function is not inherited automatically and will result in the above error.

parse4cn1 has some issue when working with Node JS and parse-server open source

The parse4cn1 library works well with parse.com but it has some issues when working with Node 4.3.2 and parse-server open source. For example, when calling the ParseUser.signup() function, the "Invalid key name" exception is always happened. I tried to debug and figure out that the ParseCommand object should add the ParseConstants.CONTENT_TYPE_JSON to its header in order to make it can work. I don't why because it still works without doing this with parse.com.
Another issue is the ParseQuery.find() is always failed when using the ParseQuery.whereContainedIn(). The server exception is "ParseException [code=102, msg=Improper encode of parameter, cause=null]". I guess this issue probably regarding the parameter has the json format in this case as well but I don't know to to resolve it. Any advice is appreciate. Sidiabale, do you have any advice? Thanks!
These problems are solved in version 3.0 of parse4cn1. Apparently, Parse Server is stricter with the need to specify the content-type header so code that previously worked with Parse.com does not work with Parse Server. I've addressed these issues in the aforementioned release. Try again with version 3.0 and let me know if you encounter any issues.

Grails package change for domain class caused DuplicateMappingException

While working through a tutorial to start learning Grails, I made a mistake and ran:
grails create-domain-class com.FooBar
instead of:
grails create-domain-class com.acme.FooBar
It was immediately obvious I had made an error so I tried the following:
Searched for a function that reverses the create-domain-class command, it seems there isn't one.
Searched for advice on the web and the consensus is that you can delete a domain class file, any associated views and tests, then to be safe run a text search for your class name in your project directory for any references you may have missed. I have done all this.
Then I ran the correct command to create com.acme.FooBar, which worked.
After this the app fails to run and reports the following error:
org.hibernate.DuplicateMappingException: duplicate import: FooBar refers to both com.acme.FooBar and com.FooBar (try using auto-import="false")
After adding the following code to com.acme.FooBar:
...
static mapping = {
autoImport false
}
...
The app now runs as expected.
However as an experienced Java developer who occasionally does refactor a package I would like to understand how to do that without causing a DuplicateMappingException or resorting to the "autoImport false" solution.
Thanks.
You shouldn't be doing
static mapping = {
autoImport false
}
As, by doing this you said that don't check for domain just by name and look up for package as well. Hence, once you do that you will have to use Fully qualified name of the class in your queries / hqls which may itch sometimes.
You should be removing the Domain completely i.e.
remove the Domain
remove the view folder creating by default with very same name and so do the controller
Now, do grails clean-all(Make it a thumb rule to use grails clean-all first for any issue unexpectedly occuring).
To be more accurate do remove target directory from your project and then do run grails run-app.
I had done very same thing many times and got it resolved by above steps.
Hope it helps.