I have an e-commerce app based on Django. The product model contains basic fields like name, brand, short description, etc. So far, I only have a "generic product detail page" that displays these information for each product.
Now I want to create more extensive product detail pages for some of the products with django cms so that they contain more product information and seo keywords. This means that most products would just have the "generic" detail page and some have a more extensive version.
I am using a url path like mydomain.com/products/product-slug and the view finds the respective product to be displayed using the product-slug. So far, this "/products/..." path is handled outside of the django-cms url namespace.
I am rather new to django cms and unsure how I should handle this project. My first idea would be:
Add empty django-cms placeholders to the generic detail page
Include the /products/... path in the django-cms namespace
Run a script that creates a page in django-cms for each individual product (whenever a new product is added to the database, a new django-cms page must then be added as well programatically)
Go to the products of high interest and add additional content with django-cms editor
Do you have any other ideas how I could handle this task?
Related
I want to add some content on one of my Wagtail pages and I am trying to import that Wagtail page on all my other wagtail pages. The reason I am trying to do this is that if in the future I make a change on the content it should consistently reflect on all the other Wagtail pages.
Is there a way that I can import a Wagtail page on all my other Wagtail pages, if so please let me know.
Thanks in advance!
I have a website which has the following Configurations:
1) Django-2.0.8
2) Wagtail-2.2.4
A custom template tag is a good way to achieve this, as it provides a place to run custom Python code (for retrieving the necessary data) before outputting the results to the template, either directly as a string or by rendering a template. For example, if you had a footer_text field on a HomePage model, and wanted to display the footer text of the HomePage with slug 'home' on every page, you could define a custom tag as follows:
#register.inclusion_tag('myapp/includes/footer.html')
def footer():
homepage = HomePage.objects.get(slug='home')
return {'footer_text': homepage.footer_text}
You could also look at Wagtail's site settings module as a way to define global content to be re-used across a site (although it's missing a few features that you'd get from defining it on a page model, such as moderation workflow and revision history).
I'm totally new to Mezzanine CMS. I got handed a site to work with and so far I've been able to do all the changes without problem. I've run across a problem in which they want a new section in the home page. I go to the admin section to edit the home page, but there is no extra content field.
On the home page, I see 4 sections "content" "priorities" "testimonials" and "clients". I would like to have another "content" area as a 5th section. How do I go on and add this section? I'm totally new to Django but would be appreciative if someone could explain or point in the right direction.
Here is a link to an image for reference.
https://imgur.com/a/sUKOtvS
Thanks in advance
The homepage content would be backed by a Django model with attributes for the partners and testimonial fields. You'll need to find the Python class for this model in your code base (you could search for those field names), and you'll need to add a new attribute for the new section you need.
Django and Mezzanine have lots of different field types you can use for these attributes, so consult their respective documentation for how those work (Django's are a lot more comprehensive, so start there).
Once you've done that, you'll need to create a database migration for the new attribute - that adds the field to the database table that will store the actual content, again consult the Django documentation for how these work.
Finally you may need to add the new field to the Admin class, which is the Python class (similar to the model) that controls which fields appear in the admin interface, and how they appear. I say "may" as these generally appear automatically without any code, but if things have been modified to a certain extent, you may need to do this manually.
When and where should I use wagtail pages and when should I write my custom urls and views using django? for example should I create pages for user profiles or should I add a urlpattern for profile and write profile logic in a django view?
This question is pretty broad and it depends a lot on what you are trying to achieve, but here are some thoughts.
General Approach
Use Wagtail pages if your pages have CMS (user) editable content and need to be placed (and easily moved) within the main page tree along with other editable pages.
If a page is not editable and URL must be fixed, it might be best to approach this either with Django URLs and views. Eg. Sitemap or Search page.
The docs cover how to set up mixed URLs in Integrating into Django.
Specific Use Case - User Profiles
You could create a Wagtail page model like UserProfileIndex which could contain some CMS editable content about that page such as body text and images.
This assumes you are wanting to make a social media type index and page for each user.
Then use RoutablePageMixin to have the URLs for each individual profile page.
Sometimes this index page thinking can come in handy, it let's you change the root URL but puts the logic for sub-urls within the model.
Remember that this means CMS users could technically change the slug of this page, unless it is locked down.
If you are trying to create a user profile page that is more suited for a user to manage their profile then it would probably best to use Django view.
I have a django project, in one of admin pages I'm adding data to the table
And I want after I choose one of themes, in Students name will be only students enrolled for this theme. How I can filter them by theme name?
Django does not do this out of the box. One third-party package I often see recommended to accomplish this common task (as opposed to writing your own ajax to do it) is django smart selects.
I have assigned some featured products in my homepage and somehow the link to product is different from that of my menu.
For example:
From menu:
http://www.example.com/store/products/littleshirt
From featured products section:
http://www.example.com/store/littleshirt
I am using opencart extension menu but I don't supposed that is the source of this problem.
I need the URL to point to same location as the url for featured product link to the product nicely but the side product menu only display parent categories.
Is there anyway to resolve this?
The "OpenCart Featured Products and News" Module is a jquery based open cart module which is shows the Selected Featured Products and/or News or relevant posts
OpenCart featured products and news is useful and has a nice plugin.
http://codecanyon.net/item/opencart-featured-products-and-news/4368564?ref=wpproducts
Known problem for me. Using canonicals referencing the desired URL for these duplicates is sort of a solution for this problem. For example:
http://www.example.com/store/littleshirt
contains a canonical to the desired URL:
http://www.example.com/store/products/littleshirt
This will prefent search engines from indexing/crawling the duplicate page and your correct/desired page from losing metrics.
p.s. I had to change the URL's to example.com for my post to get through.