GithubHelp home page GithubHelp logo

romansalin / django-seo2 Goto Github PK

View Code? Open in Web Editor NEW
60.0 60.0 45.0 585 KB

Provides a set of tools for managing Search Engine Optimisation (SEO) metadata for Django sites.

License: MIT License

Python 99.94% HTML 0.06%

django-seo2's People

Contributors

hginer avatar jcastiarena avatar kmike avatar matthewwithanm avatar willhardy avatar wx-ast avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

django-seo2's Issues

Unicode and cache

Once I set use_cache to True, I got this exception:

Traceback (most recent call last):
  File "/Users/erik/src/django/giaroo/source/djangoseo/templatetags/seo.py", line 65, in render
    **kwargs)
  File "/Users/erik/src/django/giaroo/source/djangoseo/base.py", line 301, in get_metadata
    return metadata._get_formatted_data(path, context, site, language)
  File "/Users/erik/src/django/giaroo/source/djangoseo/base.py", line 253, in _get_formatted_data
    site, language)
  File "/Users/erik/src/django/giaroo/source/djangoseo/base.py", line 43, in __init__
    hexpath = hashlib.md5(iri_to_uri(path)).hexdigest()
TypeError: Unicode-objects must be encoded before hashing

Current language overrides chosen language of Metadata

The path is not saved correctly if the use_i18n is set to True.

The _path field value is always set according to the current language instead of the chosen one. It should be translated automatically, otherwise, it does not make any sense and it does not work properly.

populate_from does not work for literals

Documentation says it is possible to pass literal value as a default value for tags:

http://django-seo2.readthedocs.io/en/latest/reference/definition.html?highlight=default#populate_from

... but it does not work (the tag won't show up in the header):

class MyMetadata(seo.Metadata):
    description = seo.MetaTag(max_length=155, populate_from='Default description')

but a callback works:

def default_description(metadata, **kwargs):
    return "Default description"
default_description.short_description = "Standard description will be used"

class MyMetadata(seo.Metadata):
    description = seo.MetaTag(max_length=155, populate_from=default_description)

coercing to Unicode: need string or buffer, ContentType found

Any idea about this?

ERROR:django.request:Internal Server Error: /admin/djangoseo/youlunmetadatamodel/add/
Traceback (most recent call last):
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = wrapped_callback(request, _callback_args, *_callback_kwargs)
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 583, in wrapper
return self.admin_site.admin_view(view)(_args, *_kwargs)
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/utils/decorators.py", line 105, in _wrapped_view
response = view_func(request, _args, *_kwargs)
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/views/decorators/cache.py", line 52, in _wrapped_view_func
response = view_func(request, _args, *_kwargs)
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 206, in inner
return view(request, _args, *_kwargs)
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1453, in add_view
return self.changeform_view(request, None, form_url, extra_context)
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/utils/decorators.py", line 29, in _wrapper
return bound_func(_args, *_kwargs)
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/utils/decorators.py", line 105, in _wrapped_view
response = view_func(request, _args, *_kwargs)
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/utils/decorators.py", line 25, in bound_func
return func.get(self, type(self))(_args2, *_kwargs2)
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/db/transaction.py", line 394, in inner
return func(_args, *_kwargs)
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1407, in changeform_view
self.log_addition(request, new_object)
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 776, in log_addition
object_repr=force_text(object),
File "/home/vagrant/virtualenv/local/lib/python2.7/site-packages/django/utils/encoding.py", line 85, in force_text
s = six.text_type(s)
TypeError: coercing to Unicode: need string or buffer, ContentType found

Error djangoseo_webmetadataview._site_id does not exist

I have model like this

class WebMetadata(seo.Metadata):
    title = seo.Tag(head=True, max_length=68)
    description = seo.MetaTag(max_length=155)
    keywords = seo.KeywordTag()
    heading = seo.Tag(name="h1")

    # facebook tag
    og_title = seo.MetaTag(name="og:title", populate_from="title",
                           verbose_name="facebook title")
    og_description = seo.MetaTag(name="og:description",
                                 populate_from="description",
                                 verbose_name="facebook description")
    og_type = seo.MetaTag(name="og:type", populate_from="type",
                          verbose_name="facebook type")
    og_site_name = seo.MetaTag(name="og:site_name", populate_from="site_name",
                               verbose_name="facebook site name")
    og_url = seo.MetaTag(name="og:url", populate_from="url site",
                         verbose_name="facebook url")
    og_locale = seo.MetaTag(name="og:locale", populate_from="locale site",
                            verbose_name="facebook locale")

    class Meta:
        use_sites = True
        use_cache = True
        use_i18n = True
        seo_models = ('web', 'web.Categories')
        seo_views = ('web', )

Migrate database ok ! But when connect url

/admin/djangoseo/webmetadataview/

Exception raise

ProgrammingError at /admin/djangoseo/webmetadataview/
column djangoseo_webmetadataview._site_id does not exist
LINE 1: ..."og_locale", "djangoseo_webmetadataview"."_view", "djangoseo...

I checked on my database . Column _site_id does not exist ... Can you explain ?

New Fields not coming in meta tags

Hi,

I have added two new fields for meta tags but both are not coming in my templates. Other default fields, title, keywords, description and heading are coming properly.

What should I do ? Any pointers ?

Thank you.

TypeError: __str__ returned non-string while trying to add Meta to Model

I were trying to add a new Meta info to model (not instance), then got this error. Adding into modelinstance or url works fine.

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/admin/djangoseo/mymetadatamodel/add/

Django Version: 1.9.9
Python Version: 3.5.2
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'goto',
 'nested_inline',
 'django_jinja',
 'filer',
 'easy_thumbnails',
 'social.apps.django_app.default',
 'import_export',
 'adminsortable2',
 'admin_export',
 'djangoseo']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/contrib/admin/options.py" in wrapper
  541.                 return self.admin_site.admin_view(view)(*args, **kwargs)

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/contrib/admin/sites.py" in inner
  244.             return view(request, *args, **kwargs)

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/contrib/admin/options.py" in add_view
  1437.         return self.changeform_view(request, None, form_url, extra_context)

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/usr/lib64/python3.5/contextlib.py" in inner
  30.                 return func(*args, **kwds)

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/contrib/admin/options.py" in changeform_view
  1382.                     self.log_addition(request, new_object, change_message)

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/contrib/admin/options.py" in log_addition
  714.             object_repr=force_text(object),

File "/home/oleg/coding/goto/gotosite/env/lib/python3.5/site-packages/django/utils/encoding.py" in force_text
  76.                     s = six.text_type(s)

Exception Type: TypeError at /admin/djangoseo/mymetadatamodel/add/
Exception Value: __str__ returned non-string (type ContentType)

errors with django 1.11, py 3.5.2

Hi I take it youre aware there are issues with django 1.11 but wanted to post errors in case they help with future compatibility. This happens when I click either of the 4 DJANGOSEO admin options in admin.

My metadatas (Model Instance)
My metadatas (Model)
My metadatas (Path)
My metadatas (View)

Environment:
Request Method: GET
Request URL: http://djang0.me/admin/djangoseo/mymetadataview/

Django Version: 1.11
Python Version: 3.5.2
Installed Applications:
['home',
'blog',
'dashboard',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.sitemaps',
'djangoseo',
'safedelete',
'ckeditor',
'ckeditor_uploader']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback:

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)

The above exception (relation "djangoseo_mymetadataview" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "djangoseo_mymetadataview"
^
) was the direct cause of the following exception:

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/contrib/admin/options.py" in wrapper
551. return self.admin_site.admin_view(view)(*args, **kwargs)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/contrib/admin/sites.py" in inner
224. return view(request, *args, **kwargs)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/utils/decorators.py" in bound_func
63. return func.get(self, type(self))(*args2, **kwargs2)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/contrib/admin/options.py" in changelist_view
1542. self.list_max_show_all, self.list_editable, self,

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/contrib/admin/views/main.py" in init
79. self.get_results(request)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/contrib/admin/views/main.py" in get_results
177. result_count = paginator.count

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/utils/functional.py" in get
35. res = instance.dict[self.name] = self.func(instance)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/core/paginator.py" in count
79. return self.object_list.count()

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/db/models/query.py" in count
363. return self.query.get_count(using=self.db)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/db/models/sql/query.py" in get_count
498. number = obj.get_aggregation(using, ['__count'])['__count']

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/db/models/sql/query.py" in get_aggregation
479. result = compiler.execute_sql(SINGLE)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql
876. cursor.execute(sql, params)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
80. return super(CursorDebugWrapper, self).execute(sql, params)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/db/utils.py" in exit
94. six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/utils/six.py" in reraise
685. raise value.with_traceback(tb)

File "/var/www/djang0/venv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /admin/djangoseo/mymetadataview/
Exception Value: relation "djangoseo_mymetadataview" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "djangoseo_mymetadataview"
^

Any way to get the SEO fields associated with the model instance?

I have an admin with seo like the following which is working fine:

class MymodelAdmin(admin.ModelAdmin):
inlines = [get_inline(MyMetadata)]

admin.site.register(Mymodel, MymodelAdmin)

Now in the view, when I get an instance Mymodel, I wanted to get the associated SEO fields as well. I was wondering what a good way would be to do so!

I have tried the following in my view already, for example:


from djangoseo import base

obj = Mymodel.objects.get(id=1)
res = base.get_linked_metadata_dict(obj)

res here contains the html, but I need a dictionary instead! any help plz!?

No seo models

Migrate doesn't create seo models.
I've just followed the tutorial and it should be pretty simple since all you need is to register 'djangoseo' app and create metadata class. Maybe I'm missing something?
Django 1.9.1
Python 2.7.10

Migrations not working

relation "djangoseo_mymetadatapath" does not exist
LINE 1: ...heading", "djangoseo_mymetadatapath"."_path" FROM "djangoseo...

Django Version: 1.9.2

TransactionManagementError or RuntimeError

I had a nasty error when saving my second seo instance with same language and for same model:
Sometimes it was:
RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.
... and sometimes:
TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.
After debugging into the deep... I found out that the reason was that my models had no get_absolute_path method and therefore it resulted in an IntegrityError because there is a unique constraint for language and path (which was empty therefore)...
Adding get_absolute_path method to all my models fixed it...
This should be added to docs... to save some people lots of time...
Thanks.

Can't use templatetags in templates for extending

Hi,

When I include the {% load seo %} and {% get_metadata %} tags in base.html, it works well. However, if I try to include the tags in a template that extends base.html, it doesn't work.

Use case: I have some templates where I want the metadata to be taken from a model instance (which if I understood has to be in the format {% get_metadata from obj %} so those views need this tag), while other templates should use paths instead.

Table not found

no such table: djangoseo_mymetadatapath

how can i create the table ?

makemigration error

CommandError: System check identified some issues:

ERRORS:
djangoseo.MyMetadataModel._content_type: (fields.E304) Reverse accessor for 'MyMetadataModel._content_type' clashes with reverse accessor for 'MyMetadataModel._content_type'.
    HINT: Add or change a related_name argument to the definition for 'MyMetadataModel._content_type' or 'MyMetadataModel._content_type'.
djangoseo.MyMetadataModelInstance._content_type: (fields.E304) Reverse accessor for 'MyMetadataModelInstance._content_type' clashes with reverse accessor for 'MyMetadataModelInstance._content_type'.
    HINT: Add or change a related_name argument to the definition for 'MyMetadataModelInstance._content_type' or 'MyMetadataModelInstance._content_type'.

While running python manage.py makemigrations

Django-seo2 supports Django 1.9.13?

I have added djangoseo app to settings.py.
But djangoseo model is'nt dispalyed on admin site. I have followed the instructions in Readme.md.

Please help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.