You can do it using command lines in a terminal, which is very laborious, 
or by installing a client that facilitates the work. In any case, it 
depends on the type of database you are using. By default Django, and also 
Mezzanine, uses sqlite, so you should install a client for that type of 
database. I use PostgreSQL as a database and pgAdmin4 as a client. If you 
want to simplify the work, I would recommend that you use the *PostgreSQL 
installer of enterprisedb 
<https://www.enterprisedb.com/downloads/postgres-postgresql-downloads>*, it 
also install pgAdmin4. PostgreSQL and pgAdmin4 will be installed and 
configured very easily, then you will have to change the configuration of 
the database in the file local_settings.py of your project, set ENGINE: 
"django.db.backends.postgresql_psycopg2". Oh, I forgot, ensure that *psycopg2 
<http://initd.org/psycopg/docs/install.html>* is installed in your virtual 
environment or in your system if you are not using a virtual environment.

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` 
> <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<slug>.*)%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.

Reply via email to