I just want to add an ratings filed. I've added djangoratings in installed apps and my model is
from django.db import models
from djangoratings import RatingField
class Rat(models.Model):
search= models.CharField(max_length=10)
rating = RatingField(range=5)
When I syncdb it comes up with no model found djangoratings. Is there anything i want to do more.
Thanks in advance
Have you installed the package djangoratings? Following the install instructions here
It seems like syncdb can't find the models.py of the djangorating package.
Related
When running makemigrations for other apps in this particular project I sporadically get the following wagtailcore migration being created (e.g. in this case wagtail/wagtailcore/migrations/0033_auto_20170210_0710.py) and my app migrations setting it as a dependancy. I've tried to track down the reason several times but failed and resorted to just deleting it and updating the dependancy in my app migration. I'd be grateful if anyone can point out why/where/how/what I'm doing wrong/missing here.
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-10 07:10
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0032_add_bulk_delete_page_permission'),
]
operations = [
migrations.AlterField(
model_name='page',
name='owner',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='owned_pages', to=settings.AUTH_USER_MODEL, verbose_name='owner'),
),
]
It wasn't a Wagtail issue. It was a Puput issue fixed in the version 0.9. Please try to update to that version.
I am building a GAE webapp using Python. I am also using the Datastore and trying to bulk upload data to the DB using the terminal and a CSV file as per:
https://developers.google.com/appengine/docs/python/tools/uploadingdata
I have created a Loader class in a separate.py file in my app root directory. I am not really sure if this loader class should be in my main.py webapp file, or another file in the root directory.
Loader class:
import datetime
from google.appengine.ext import db
from google.appengine.tools import bulkloader
import models
class FTSELoader(bulkloader.Loader):
def __init__(self):
bulkloader.Loader.__init__(self, 'FTSE',
[('date', lambda x: datetime.datetime.strptime(x, '%Y/%m/%d')),
('close', float)])
loaders = [FTSELoader]
My kind class (i.e. my Datastore table) I am trying to create/upload is called "FTSE". I then run this command in Terminal:
appcfg.py upload_data --config_file=FTSEdataloader.py --filename=FTSEdata.csv -- kind=FTSE --url=http://<myapp.appspot.com>/_ah/remote_api
I get the following error:
File "FTSEdataloader.py", line 4, in
import models
ImportError: No module named models
I do not have a "models.py" like in the GAE demonstration. What should take its place?
Thanks
I had the same problem. I'm not sure why the appcfg.py can't find the models module when running the upload script. I got around the problem by doing this:
import datetime
from google.appengine.ext import db
from google.appengine.tools import bulkloader
class FTSE(db.Model):
date = DateTimeProperty()
close = FloatProperty()
class FTSELoader(bulkloader.Loader):
def __init__(self):
bulkloader.Loader.__init__(self, 'FTSE',
[('date', lambda x: datetime.datetime.strptime(x, '%Y/%m/%d')),
('close', float)])
loaders = [FTSELoader]
Basically it is just putting your model definition in the bulkloader. It certainly isn't the best way to do this, but it will work around the PYTHONPATH problem that appcfg.py seems to have when it is running the bulk upload.
You do this using a file of Python code. The file imports or defines the Model classes for the entities being created, defines a loader class for each kind you wish to import, and declares the available loader classes in a global variable.
For example, say you have a Model class named "FTSE" defined in a file named models.py (which is in your PYTHON PATH, such as the directory where you'll run the tool Ex: C:\Python27) that resembles the following:
models.py
from google.appengine.ext import db
class FTSE(db.Model):
date = db.DateProperty()
close = db.FloatProperty()
I am still new to Python and GAE. I have an application on local server that is running just fine. I can add entity to my datastore, I can view my website, etc: everything is fine.
Now I am trying to use bulkloader to add entities to my datastore. I followed the tutorial at https://developers.google.com/appengine/docs/python/tools/uploadingdata. My loader is below:
from google.appengine.ext import ndb
from google.appengine.tools import bulkloader
import my_model
class ArticleLoader(bulkloader.Loader):
def __init__(self):
bulkloader.Loader.__init__(self, 'Article',
[('title', str),
('author', str)
])
loaders = [ArticleLoader]
I am getting the error:
No module named my_model
Does anyone have a fix for this?
Note: I am only using one directory. So my loader is in the same location as the other file that imports the my_model module.
This can also happen if your PYTHONPATH is not properly set up. If you're on Linux, try running this before you run the Bulkloader:
export PYTHONPATH=$PYTHONPATH:.
This appends your current directory to your PYTHONPATH and should make your my_model module visible. Since my memory is terrible and I always forget to do it, I've ended up using a simple shell script that includes this at the beginning and then the bulkload command itself.
If you're on Windows, you should be able to modify your path by using sys.path.append. Haven't tested this, but you could try adding this to your script (note that this should work on Linux as well):
import sys
# ...
sys.path.append('.')
Your code should be located in a file named my_model.py. You are getting that error because there is no module named my_module. Might be worth a read of the Python module and package docs.
I have installed pycrypto version 2.6 , and i am getting this error
from Crypto.Cipher import blockalgo
ImportError: cannot import name blockalgo
I have read many post but i am unable to solve this problem
If you are not able to import anything from Crypto.Cipher at all, it might be due to folders, crypto and respective egg info, under site-packages are created with lower-case 'c'
/Library/Python/2.7/site-packages/crypto
/Library/Python/2.7/site-packages/crypto-1.0.0-py2.7.egg-info
Imports were successful when same case was used while importing
from crypto.Cipher import AES
or renaming the folders
/Library/Python/2.7/site-packages/Crypto-1.0.0-py2.7.egg-info
/Library/Python/2.7/site-packages/Crypto
I went with the later, to have consistency with others.
I use Eclipse and was able to overcome this problem using one of the above solutions.
Sometimes we overlook these kind of details easily. Its a long shot, hope this helps!
I'm trying to follow the grails tutorial here.
When I create a new controller using create-controller XXX.Card and modify it to use scaffolding as per the tutorial:
package XXX
class CardController {
def scaffold = Card
}
I get the following exception when I click on XXX.CardController:
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: static XXX.Card.list() is applicable for argument types: (org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap) values: [[max:10, action:list, controller:card]]
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:54)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:121)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:54)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:342)
Caused by: groovy.lang.MissingMethodException: No signature of method: static XXX.Card.list() is applicable for argument types: (org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap) values: [[max:10, action:list, controller:card]]
at XXX.CardController$_closure2.doCall(script1258397512682.groovy:14)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
at XXX.CardController$_closure2.doCall(script1258397512682.groovy)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
... 5 more
I'm using Grails 1.1.1 with the app-engine 0.8.5 and gorm-jpa 0.5 plugins.
What am I doing wrong?
Here's the script I use to reproduce this problem:
rm -rf ~/.grails/1.1.1/projects/XXX
grails create-app XXX
cd XXX
grails install-plugin gorm-jpa
grails install-plugin app-engine # Note: specify JPA when prompted
grails create-domain-class XXX.Card
grails create-controller XXX.Card
cat > grails-app/controllers/XXX/CardController.groovy <<EOF
package XXX
class CardController {
def scaffold = Card
}
EOF
cat > grails-app/domain/XXX/Card.groovy <<EOF
package XXX
class Card {
List emails
static hasMany = [emails:String]
}
EOF
grails app-engine
I just re-created your scenario with the following steps, using Grails 1.1.1:
grails create-app XXX
cd XXX
grails create-domain-class XXX.Card
grails create-controller XXX.Card
-- Edited grails-app\Controllers\XXX\Card.groovy removing the index action and adding the scaffold declaration "def scaffold = Card"
grails run-app
When I visited http://localhost:8080/XXX/card, I was given the appropriate list page for the Card class (which had no entries, and no columns, since I hadn't added anything to Card)
Note the lowercase "card" (you seem to have it correct), this is important. Controller paths in the URL are defaulted to start with a lower case.
Hope this helps. If you can't follow these steps and get it to work, I'd look at those plugins you installed.
have you tried installing the gorm-jpa plugin? I don't think list() is implemented in the app-engine plugin, but rather in gorm-jpa.
jdo has no gorm support.
After some conversations on the forums, it appears that GORM is only lightly working with App Engine at this time. Until the next release of the various plugins involved (app-engine and gorm-jpa) it's probably best to stay away from GORM with App Engine.
Problem trying to use scaffolding with app-engine
New user grails+app-engine frustration
Thanks for all the help, Tomas.