[mezzanine-users] Re: How to load template based on slug?

2017-11-06 Thread Tom Tanner
I read those, but unfortunately I'm not sure I understand.

I changed my directory a bit, so it's...
theme/
- templates/
-- pages/
--- project_pages/
 project_base.html
 projects/
- some-content.html

My `views.py` changed slightly..
def project_detail(request, slug, template="project_pages/project_base.html"
, extra_context=None):
 '''
 Custom templates are checked for by using the name
 `project_pages/projects/XXX.html`` where `XXX` is the project slug.
 '''
 project = get_object_or_404(Project, slug=slug, status=2)
 context = {
 "project": project,
 "editable_obj": project
 }
 context.update(extra_context or {})
 templates = [u"project_pages/projects/%s.html" % str(slug), template]
 return TemplateResponse(request, templates, context)

I used my site's Admin page to add a `ProjectLinkPage` object with slug 
`some-content.html`, which looks like this:
{% extends "project_base.html" %}
{% load mezzanine_tags keyword_tags %}
{% block main %}
 Here is some content
{% endblock %}

But I still get a 404 error when I go to 
`http://127.0.0.1:8000/projects/some-content/`. I know you mentioned using 
an underscore, but I'd like to access each project page like 
`/projects/name-of-project/`. 

Is this possible?


On Monday, November 6, 2017 at 3:08:12 PM UTC-5, Rainell Dilou Gómez wrote:
>
> Well, you can take advantage of the work you have done so far, that is, 
> you have created your own content type, then you should make the necessary 
> adjustments so that Mezzanine dynamically loads the indicated template, for 
> example by the slug field. Obviously, each slug should correspond to a real 
> template in its files (html, css and js files).
> Before starting with this work, I would recommend you (strongly 
> recommended) to read the *Django documentation about the work with 
> templates * and 
> also the *mezzanine documentation* 
> .
>
> Il giorno domenica 5 novembre 2017 00:35:50 UTC+1, Tom Tanner ha scritto:
>>
>> Hey everyone,
>>
>> When I go to `http://127.0.0.1:8000/projects/some-slug` 
>> , I want Mezzanine to fetch 
>> the `project_detail.html` template, which would include `some-slug.html`. 
>> How do I do this? 
>>
>> Here's `urls.py`.
>> url("^projects/(?P.*)%s$" % _slash, project_detail, name=
>> "project_detail"), 
>>
>>
>>
>> `models.py`.
>> class ProjectLinkPage(Displayable)
>>  '''
>>  A page representing the format of the page that 
>>  has links to standalone, projectlink projectlinks
>>  '''
>>
>>
>>  # Fields and `class Meta`, etc...
>>
>>
>>  @models.permalink
>>  def get_absolute_url(self):
>>  return ("project_detail", (), {"slug": self.slug})
>>
>>
>> `views.py`
>> def project_detail(request, slug, template="projects/project_detail.html"
>> , extra_context=None):
>>  '''
>>  Custom templates are checked for by using the name
>>  `projects/project_detail/XXX.html`` where `XXX` is the project slug.
>>  '''
>>
>>
>>  project = get_object_or_404(Project, slug=slug, status=2)
>>  context = {
>>  "project": project,
>>  "editable_obj": project
>>  }
>>  context.update(extra_context or {})
>>  templates = [u"projects/project_detail/%s.html" % str(slug), template]
>>  return TemplateResponse(request, templates, context)
>>
>> `project_detail.html`
>> {% extends "base.html" %}
>> {% load mezzanine_tags keyword_tags %}
>>
>>
>> {% block meta_title %}
>>  {{ project.meta_title }}
>> {% endblock %}
>>
>>
>> {% block meta_keywords %}
>>  {% metablock %}
>>  {% keywords_for project as tags %}
>>  {% for tag in tags %}{% if not forloop.first %}, {% endif %}{{ tag }}{% 
>> endfor %}
>>  {% endmetablock %}
>> {% endblock %}
>>
>>
>> {% block meta_description %}
>>  {% metablock %}{{ project.description }}{% endmetablock %}
>> {% endblock %}
>>
>>
>> {% block title %}
>>  {{ project.title }} 
>> {% endblock %}
>>
>>
>> {% block main %}
>>  {{ project.content }}
>> {% endblock %}
>>
>> But I'm not sure where to go from here. How do I transfer the slug to 
>> `project_detail.html` so it knows where to look? In this case, I'd have a 
>> folder named `slugs` in the same directory as `project_detail.html`. And 
>> `slugs` would have templates named after slugs.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Re: How to load template based on slug?

2017-11-06 Thread Ken Bolton
On Mon, Nov 6, 2017 at 3:08 PM, Rainell Dilou Gómez  wrote:

>
> Before starting with this work, I would recommend you (strongly
> recommended) to read the *Django documentation about the work with
> templates * and
> also the *mezzanine documentation*
> .
>
>
I've been biting my tongue, Rainell, thank you for taking the words from my
mouth!

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: How to load template based on slug?

2017-11-06 Thread Rainell Dilou Gómez
Well, you can take advantage of the work you have done so far, that is, you 
have created your own content type, then you should make the necessary 
adjustments so that Mezzanine dynamically loads the indicated template, for 
example by the slug field. Obviously, each slug should correspond to a real 
template in its files (html, css and js files).
Before starting with this work, I would recommend you (strongly 
recommended) to read the *Django documentation about the work with 
templates * and also 
the *mezzanine documentation* 
.

Il giorno domenica 5 novembre 2017 00:35:50 UTC+1, Tom Tanner ha scritto:
>
> Hey everyone,
>
> When I go to `http://127.0.0.1:8000/projects/some-slug` 
> , I want Mezzanine to fetch the 
> `project_detail.html` template, which would include `some-slug.html`. How 
> do I do this? 
>
> Here's `urls.py`.
> url("^projects/(?P.*)%s$" % _slash, project_detail, name=
> "project_detail"), 
>
>
>
> `models.py`.
> class ProjectLinkPage(Displayable)
>  '''
>  A page representing the format of the page that 
>  has links to standalone, projectlink projectlinks
>  '''
>
>
>  # Fields and `class Meta`, etc...
>
>
>  @models.permalink
>  def get_absolute_url(self):
>  return ("project_detail", (), {"slug": self.slug})
>
>
> `views.py`
> def project_detail(request, slug, template="projects/project_detail.html", 
> extra_context=None):
>  '''
>  Custom templates are checked for by using the name
>  `projects/project_detail/XXX.html`` where `XXX` is the project slug.
>  '''
>
>
>  project = get_object_or_404(Project, slug=slug, status=2)
>  context = {
>  "project": project,
>  "editable_obj": project
>  }
>  context.update(extra_context or {})
>  templates = [u"projects/project_detail/%s.html" % str(slug), template]
>  return TemplateResponse(request, templates, context)
>
> `project_detail.html`
> {% extends "base.html" %}
> {% load mezzanine_tags keyword_tags %}
>
>
> {% block meta_title %}
>  {{ project.meta_title }}
> {% endblock %}
>
>
> {% block meta_keywords %}
>  {% metablock %}
>  {% keywords_for project as tags %}
>  {% for tag in tags %}{% if not forloop.first %}, {% endif %}{{ tag }}{% 
> endfor %}
>  {% endmetablock %}
> {% endblock %}
>
>
> {% block meta_description %}
>  {% metablock %}{{ project.description }}{% endmetablock %}
> {% endblock %}
>
>
> {% block title %}
>  {{ project.title }} 
> {% endblock %}
>
>
> {% block main %}
>  {{ project.content }}
> {% endblock %}
>
> But I'm not sure where to go from here. How do I transfer the slug to 
> `project_detail.html` so it knows where to look? In this case, I'd have a 
> folder named `slugs` in the same directory as `project_detail.html`. And 
> `slugs` would have templates named after slugs.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Datatable CRUD, master/detail forms and nice jQuery/Bootstrap interactivity.

2017-11-06 Thread Michel Depiesse
Hi folks,

I want to write software for stock management and accounting.

I need datatable CRUD, master/detail forms and nice jQuery/Bootstrap 
interactivity.

I have two questions :
- Is Mezzanine a tool for this kind of application ?
- Can I add freely the django packages in a Mezzanine application ?

Thank you very much for your attention
Michel Depiesse Consulting
Antwerp

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: How to load template based on slug?

2017-11-06 Thread Rainell Dilou Gómez
Yes, Django uses SQLite by default. See DATABASES configuration in 
local_settings.py, this file is in your project folder. The "ENGINE" key 
specify the type of database should be used. If you want to use PostgreSQL 
set that key as follow

"ENGINE": "django.db.backends.postgresql_psycopg2"

Create a new database for your project in your PostgreSQL server and 
completing the DATABASES configuration in local_settings.py. 

After completing the new configuration of DATABASES, comment your 
application (# projects,) or your applications in the INSTALLED_APPS, in 
settings.py, and execute the command createdb (manage.py createdb). Then 
uncomment your application or applications in INSTALLED_APPS an execute 
makemigrations (manage.py makemigrations) and migrate (manage.py migrate). 

If you have installed a PostgreSQL client, for example pgAdmin4, now you 
can see the entire structure of the mezzanine database.

Il giorno domenica 5 novembre 2017 00:35:50 UTC+1, Tom Tanner ha scritto:
>
> Hey everyone,
>
> When I go to `http://127.0.0.1:8000/projects/some-slug` 
> , I want Mezzanine to fetch the 
> `project_detail.html` template, which would include `some-slug.html`. How 
> do I do this? 
>
> Here's `urls.py`.
> url("^projects/(?P.*)%s$" % _slash, project_detail, name=
> "project_detail"), 
>
>
>
> `models.py`.
> class ProjectLinkPage(Displayable)
>  '''
>  A page representing the format of the page that 
>  has links to standalone, projectlink projectlinks
>  '''
>
>
>  # Fields and `class Meta`, etc...
>
>
>  @models.permalink
>  def get_absolute_url(self):
>  return ("project_detail", (), {"slug": self.slug})
>
>
> `views.py`
> def project_detail(request, slug, template="projects/project_detail.html", 
> extra_context=None):
>  '''
>  Custom templates are checked for by using the name
>  `projects/project_detail/XXX.html`` where `XXX` is the project slug.
>  '''
>
>
>  project = get_object_or_404(Project, slug=slug, status=2)
>  context = {
>  "project": project,
>  "editable_obj": project
>  }
>  context.update(extra_context or {})
>  templates = [u"projects/project_detail/%s.html" % str(slug), template]
>  return TemplateResponse(request, templates, context)
>
> `project_detail.html`
> {% extends "base.html" %}
> {% load mezzanine_tags keyword_tags %}
>
>
> {% block meta_title %}
>  {{ project.meta_title }}
> {% endblock %}
>
>
> {% block meta_keywords %}
>  {% metablock %}
>  {% keywords_for project as tags %}
>  {% for tag in tags %}{% if not forloop.first %}, {% endif %}{{ tag }}{% 
> endfor %}
>  {% endmetablock %}
> {% endblock %}
>
>
> {% block meta_description %}
>  {% metablock %}{{ project.description }}{% endmetablock %}
> {% endblock %}
>
>
> {% block title %}
>  {{ project.title }} 
> {% endblock %}
>
>
> {% block main %}
>  {{ project.content }}
> {% endblock %}
>
> But I'm not sure where to go from here. How do I transfer the slug to 
> `project_detail.html` so it knows where to look? In this case, I'd have a 
> folder named `slugs` in the same directory as `project_detail.html`. And 
> `slugs` would have templates named after slugs.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.