Comments (4)
I'm not entirely sure I understand what your problem is. Does your model define get_absolute_url
? Could it be that get_absolute_url
fails for some reason?
from django-seo.
Yeah you rox ! I am sorry I didn't find anything about this part in the tutorial :(
I have added in my Page model:
def get_absolute_url(self):
return ("page", [self.slug])
So now the frameworks works great for : "path" & "model instance" !
I still have trouble for my metadata "view" & "model" part... Do I need to add something in the view or in the urls.py to link the url/view to the model?
from django-seo.
Thanks god (every god ;-) ), no any reference to this in the docs.¿or yes?
;-)
from django-seo.
Hi again.
Some weeks ago, when i discovered this project, i manage to do exacly what is shown on this post.
Now i have no problem in fetching seo-data related to "model-instances" or "paths"....
Now i'm on another project, and i'm running in the same issue.
Really I don't think that edditing , from admin , the "path" which I want to associate the data is the best way.
One of the nicier things of this app is that a can add "matatags" to my models without needing to add any simgle line of code to the model.
So what I've tried is to use the same "populate_from", and to assign a "default value " when the is no "model_instance":
def populate_title(metadata, model_instance = None, **kwargs):
print kwargs
#Si la petición de meta info viene asociada a la instancia de un modelo
if model_instance:
return u'HELLA - %s -%s - ' % (model_instance._meta.verbose_name ,smart_unicode(model_instance.heading, encoding='utf-8', strings_only=False, errors='strict'))
else:
return 'Hella - mAIN cATEGORRY PAGE'
With this, now i have a "fallback" for this Metadatamodel, when used from my "category" template as this:
{% block seo %}
{% load seo %}
{% get_metadata MyMetadata %}
{%endblock %}
But now i'm running into another little issue (i'm sure that this is not the rigth way of facing this ...but...is the only way i havefound).
i'm trying to "reuse" the same method ("populate_title") for more than one Model. I also have more than one "SeoModel) So..i call the same "populate_from" from both SeoModels.
When the method is called i try to determine the class (model_instance) and build a diferente "tag".
The only point of doing this is having all the logic of tags assigning in one method ( outside from my app models).
The code looks like this:
def populate_title(metadata, model_instance = None, **kwargs):
#if model instance exists
if model_instance:
#post innovaciones
if model_instance._meta.verbose_name == PostInnovaciones._meta.verbose_name:
return u'HELLA - %s -%s - ' % (model_instance._meta.verbose_name ,smart_unicode(model_instance.heading, encoding='utf-8', strings_only=False, errors='strict'))
#novedades
elif model_instance._meta.verbose_name == Novedades._meta.verbose_name:
return u'HELLA - %s -%s - ' % (model_instance._meta.verbose_name ,smart_unicode(model_instance.heading, encoding='utf-8', strings_only=False, errors='strict'))
#if no model instance
else:
#post innovaciones
if model_instance._meta.verbose_name == PostInnovaciones._meta.verbose_name:
return u'HELLA - %s -' % (model_instance._meta.verbose_name )
#novedades
elif model_instance._meta.verbose_name == Novedades._meta.verbose_name:
return u'HELLA - %s -%s - ' % (model_instance._meta.verbose_name )
Obviosly the last part of the code (after "else") is not working, because the is no "model_instance".
So... i've two diferent questions:
- Which is the right way of assigning "matainfo" to the "model" it self.
- If there is not an answer to this ( sure there is one, but i'm to stupid to see it), ¿is there any way of finding who has called the "propulate_title" method (when no model instance is linked), so i can show create the proper "tag".
Thanks in advance.
from django-seo.
Related Issues (20)
- get_inline() should return multiple inlines when Meta.use_sites or Meta.use_i18n are True HOT 1
- Flatpages per page SEO data editing HOT 4
- When using i18n_patterns, every path is prefixed with the current language so it can have several versions HOT 1
- Unable to use namespacing in view names
- TemplateSyntaxError: {% get_metadata %} needs some path information SHOW When set Debug=False,but set to True, no error out. HOT 4
- seo_models is not able to detect GIS model properties
- Multiple MetaModel and Inheritance
- cannot import rollyourown HOT 1
- external data (e.g. {{ product }}) won't be rendered and just stays as {{ product }}. So, dynamic values such as {{ product }} cannot be used in, for example, title field.
- Django 1.7 : ImportError cannot import name get_verbose_name HOT 1
- Is there any flask SEO?
- Does not work in django v1.8.0 HOT 11
- IntegrityError at /admin/seo/mymetadatamodelinstance/add/ HOT 2
- django-seo2 has been released HOT 1
- ImportError: cannot import name SortedDict (With Django 1.9) HOT 2
- value too long for type character varying(68)
- File "/usr/local/python3.4/lib/python3.3/site-packages/Django-1.8.11-py3.3.egg/django/db/backends/mysql/base.py", line 27, in <module> raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
- AttributeError: type object 'MyMetadata' has no attribute '_meta'
- ImportError: cannot import name 'SortedDict' HOT 3
- yep it fking dead
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-seo.