How can I adjust my code to adapt the Django upgrade? - python

from django.template.base import TagHelperNode, VariableNode
ImportError: cannot import name TagHelperNode
I had upgrade Django from 1.8.14 to 1.11.17

It should be:
from django.template.library import TagHelperNode
Reference can be found here.

Related

sqlalchemy and sqlalchemy-clickhouse import error

I'm trying to import sqlalchemy library
import pandas as pd
import sqlalchemy as sa
engine = sa.create_engine('postgresql://{login}:{password}#database.org:5432/database'.format(login = 'login', password='password'))
engine_ch = sa.create_engine('clickhouse://database#ip')
but this ends up with an error
ImportError: cannot import name '_literal_as_label_reference'
I've checked this post, installed the right versions of both libraries, there was no errors during installation, but the import error remains
sqlalchemy version is 1.3.24, sqlalchemy-clickhouse version is 0.1.5.post0

How to import a model to a file in Django

I have the following structure of the project:
I have folder modules. And I have file save_to.py
I need to import a model from bedienungsanleitung app. But when I try to do it, it gives an error
No module named 'manuals_project.bedienungsanleitung'
I try to do it the following way:
from manuals_project.bedienungsanleitung.models import Link
from .bedienungsanleitung.models import Link
from bedienungsanleitung.models import Link
from ..models import Link
What is the mistake? Can someone help me?
You may try:
from bedienungsanleitung.models import Link
from manuals_project.bedienungsanleitung.models import Link
I don't see that you have models under bedienungsanleitung. Did you mean to say
from manuals_project.models import Link

cannot import the module in Python

I have the following folder structure.
check_site
- test_site
-- views.py
- app2
- app3
- modules
-- url.py
-- usability.py
module ulr.py contains one class inside - Url.py
class URL:
...
module usability.py contains one class that inherit URL class
from url import URL
class Usability(URL):
...
And then I have a view.py where I neen to import class Usability
from modules.url import URL
from modules.usability import Usability
And here is a problem. It gives me an error
from url import URL
ModuleNotFoundError: No module named 'url'
I've tried to change the import in usability.py to
from modules.url import URL but in this case it gives the error in the usability.py
Unable to import modules.url
I've also tried
from .url import URL and from check_site.modules.url import URL But these also don't work
If someone knows how to fix it, please help
Well, the problem lies here because by default Python searches for the file in the current directory but the file u want to import is not in the same directory as your program.
You should try sys.path
# some_file.py
import sys
# insert at 1, 0 is the script path (or '' in REPL)
sys.path.insert(1, '/path/to/application/app/folder')
import file
This should work in most cases.

recurly error message: cannot import name Account

Hello I've followed these steps:
on my code folder
pip install recurly
Create code:
import recurly
from recurly import Account
recurly.SUBDOMAIN = 'mi-domain'
recurly.API_KEY = 'abdcdddd1d7445fba86b5ca35eef00d5'
recurly.DEFAULT_CURRENCY = 'USD'
account = Account.get('id45')
account.delete()
and when I try to execute code above
I get
ImportError: cannot import name Account
Why is it that imports recurly with no problem but cannot import resources?
You'll have to call recurly.Account.get('id45') to get the account you'd like. You can find an example with correct syntax here: https://github.com/recurly/recurly-js-examples/blob/master/api/python/app.py#L70

PYthon 3.3 - api bufferapp. Cant update

i want to publish an update on bufferapp.com with python.
I installed the python buffer modul: https://github.com/bufferapp/buffer-python
I managed to connect to their api with python3.
But if i use the update.publish() command it gives me the following error:
nameerror: "update" is not defined.
Im using this code:
from pprint import pprint as pp
from colorama import Fore
from buffpy.models.update import Update
from buffpy.managers.profiles import Profiles
from buffpy.managers.updates import Updates
from buffpy.api import API
token = 'awesome_token'
api = API(client_id='client_id',
client_secret='client_secret',
access_token=token)
# publish now
update.publish()
What am i doing wrong?
Thank you for your help.

Categories