Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Question: How is the default template loaded? #10

Closed
antoinebis opened this issue May 3, 2012 · 4 comments
Closed

Question: How is the default template loaded? #10

antoinebis opened this issue May 3, 2012 · 4 comments

Comments

@antoinebis
Copy link

Hi,

This is not really an issue but more of a question. (I am kind of new to Django...) I can't find anywhere in your code where the template "picture_form.html" is loaded... I don't understand how it does it?!

Also, why do you need super() here?

 super(Picture, self).save(*args, **kwargs)

Thanks a lot,

Antoine

@sigurdga
Copy link
Owner

sigurdga commented May 4, 2012

You can set the template to run with the template_name variable in the class, or it will use the lowercased class name with a "_form" suffix for create and update views. I often make the models first, then the views, and then see what template name Django is missing, as it will always try to load a template.

super is needed to run the save-method on the superclass (models.Model is the superclass, and should be for all Django models).

@antoinebis
Copy link
Author

Cool! And I assume that when you call save, it also calls the save on each of your field (kind of). Therefore, there is a FileField.save() being done somewhere?!

@sigurdga
Copy link
Owner

sigurdga commented May 4, 2012

When you save, you save a record (or row). And all changed fields will be part of the save. All you need to know is how to set the location or choose a storage backend. And the documentation is very good at explaining that. I think https://docs.djangoproject.com/en/dev/topics/files/ is a good starting point.

@sigurdga sigurdga closed this as completed May 4, 2012
@chriscamplin
Copy link

Hi, i am trying to adapt your delete file page to be an external share link page to photos in the gallery, but am also new to Django & was struggling to create a view for this using the same methods you have. if you have a second could explain your template method a little further? Or if i used the generic View what might the default template name be?

Thanks so much for this project, it has been really useful.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants