Comments (6)
If you register a model as being an "SEO model", it should automatically create SEO model instance for each of your model instances. To register a model, use the seo_models
meta option, and provide of list of app names or even specific models. For example:
class BasicExample(seo.MetaData):
heading = seo.Tag(name="h1")
class Meta:
seo_models = ('myapp', 'flatpages.FlatPage')
I'll close this ticket, but please reopen if you think that it should be possible to manually add seo models in the admin for a given model instance. It wouldn't be too difficult to implement, but I prefer to keep things simple.
from django-seo.
Thank you for your response.
The problem i had was not knowing that the proper way to add a metadata instance for a model instance is inlines, placed on the model instance's admin. Because these fields "_content_type_id" and "_object_id" are not visible in a usual form.
I have a situation, where i need to place inlines for inlines. That is, objects, which should have metadata in inline, are inlines itself (don't have a normal admin).
Trying now to implement something like "Add another" button (in front of related fields in Django admin forms) to open a popup for creating a metadata instance in that popup for a specified inline object. Maybe you can probably advice something? Because, i think, that is somewhere too complex, and it has to be simplier.
Thank you one more.
from django-seo.
I'm not sure if there is anything currently in this library that will solve your problem directly. I've added documentation to readthedocs.org, which might be helpful.
from django-seo.
I can't get the inlines to work. Once I register it and go to the Model in the Admin I get the error:
MyMetadataModelInstance has no field named 'content_type'
from app.seo import MyMetadata
class ProfileAdmin(admin.ModelAdmin):
inlines = [get_inline(MyMetadata)]
admin.site.register(Profile, ProfileAdmin)
In the seo.py I have:
from rollyourown import seo
class MyMetadata(seo.Metadata):
title = seo.Tag(head=True, max_length=68)
description = seo.MetaTag(max_length=155)
keywords = seo.KeywordTag()
class Meta:
seo_models = ('event.Event', 'profiles.Profile', 'blog.Post')
Am I doing something wrong or is this a bug?
Thanks,
Phil
from django-seo.
This sounds like a bug, the field should be called _content_type
(the underscore is to allow you to add your own metadata field called content_type
).
I suspect the following fields are missing from the inline created for you:
ct_field = "_content_type"
ct_fk_field = "_object_id"
I'll try to create a test to catch this and add the two fields to the inline.
from django-seo.
I've committed an automated test and a fix for this problem. Thanks for letting me know!
from django-seo.
Related Issues (20)
- It's hard to migrate an existing Metadata model
- 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
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.