Saturday, 28 September 2013

Get application name in Django model

Get application name in Django model

The following is the model for a Django app. Let the app be called MyApp.
The idea is for every app to have it's folder under the MEDIA_ROOT.
class MyModel(models.Model):
.... #Other fields
datoteka = models.FileField(upload_to = 'MyApp',null = True)
Is there a way to get the name of the app from somewhere and remove the
hardcoded MyApp.
This is a similar question, however I have no access to the request object
in the model.

No comments:

Post a Comment