Comments (12)
Thanks for the report!
This isn't in the test suite for some reason, and it doesn't throw an exception when running sqlite. I've cleaned up the tests to get them to run on postgres and will add a new one for this.
I'm not sure how to fix it though: there's a signal to create a metadata object when a new instance on the related model is created, but the admin tries to add the one you just edited inline afterwards.
from django-seo.
The only fix I can think of is to disable the instance adding via post_save signal when an inline is used. The difficulty is then trying to work out which models use the inline.
Another option would be to require an explicit command to switch on automatic metadata creation, with a warning in the docs that it cannot coexist with an inline form in the admin.
from django-seo.
hmmm. can you point me to the code parts that are involved? i am not familiar enough with the application. would it be possible to check if the object was already created? in that case just using the object and editing the fields? kind of like get_or_create?
from django-seo.
Nope, not possible and would be problematic in its own way.
The solution is actually simple: if you use an inline form in the admin, don't put the model in the seo_models
setting. That setting will add a new metadata instance automatically, and the inline with do something similar, so there's no need for both.
I've updated the docs to mention it, and fixed some other problems I saw when using inlines in the admin. I hope that this won't be a point of confusion, otherwise I might have to consider removing the seo_models
feature.
Thanks for the report! I'm feeling a bit better about the library and maybe even confident enough to push a release to pypi.
Cheers,
Will
from django-seo.
(PS make sure you pull an update, I've fixed something else you might come up against)
from django-seo.
cool. it works to add them as inlines now. I have one more small problem. when I do:
{% get_metadata for profile as metadata %}{{ metadata }} in my templates I never get any data back. This happens when I attached metadata to the object and also when I did not (in that case it should display the default values)
am I doing something wrong?
thanks for the quick responses...it is sunday afterall ;)
from django-seo.
Sorry, I worked on the first part and forgot to come back to the second. I'll look into this now.
from django-seo.
Do you definitely have a get_absolute_url
method on your profile object? (will speed up my attempt to reproduce the problem)
from django-seo.
(By the way, you don't have to include the "for profile" bit if you are currently on the profile page, the metadata for the current path is displayed when you don't use the "for obj" syntax)
from django-seo.
i have:
@models.permalink
def get_absolute_url(self):
return ('location_detail', (), {'username': self.user.username })
in my Profile model. The get_absolute_url matches the url on the page.
url(r'^(?P[\w.-]+)/$', 'xxx.views.location',
name='location_detail'),
thats the url pattern.
when I remove "for profile" I get the default values back, but I don't get the values I attached to the model.
a question on the side:
why would you get the metadata over the url if you already have the actual businessobject that the metadata is associated to?
from django-seo.
Not sure about this, can you confirm in the admin that the relevant "XYZ Metadata (model instance)" objects have an (accurate) path? Up until earlier today the admin inline wouldn't have added an accurate path.
(side question: for flexibility. you only need to specify the metdata in the base template, and it will work for all pages, even the one's without associated objects (like when you link metadata to views or raw paths). The value can also be cached against the path, so there doesn't have to be a performance hit)
Thanks for the feedback!
from django-seo.
when I remove "for profile" I get the default values back, but I don't get the values I attached to the model.
I'm guessing that this one has to do with not using RequestContext
. I've added a strict check with a friendly message to help people out who fall into this trap.
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.