Adding Checkbox in ModelAdmin
Hello, i have a little question which i could'nt answer myself reading the documentation. i'm trying to modify the modelAdmin of my "Picture"-model this is what i'm trying to do: class PictureAdmin(admin.ModelAdmin): def save_model(self, request, obj, form, change): # if mycheckbox = checked: # obj.save_with_xmp() # else: # obj.save() pass So i'm wondering how i can add a checkbox to my ModelAdmin form which i can use. The checkbox should only be a control element but no part of the database model. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/PYhiflt-QvUJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
The problem with storing relative paths
Hello! So this is what i wanna do: I have built a model with an admin interface for letting the user create his own site. it has following fields: name = models.CharField(max_length = 50) formtemplate = FilePathField(path='/path/to/project/myforms/templates/forms', match=".\*.htm[l]") thankyoutemplate = FilePathField(path='/path/to/project/myforms/templates/forms', match=".\*.htm[l]", blank=True) slug = models.CharField(max_length = 50) He should be able to upload his template-files to that folder and afterwards selecting it in the model admin. but the database is storing the absolute path which means, after putting the project to another path or system all paths in the database are useless. id like to avoid that and looked for solutions. I would like the database to store only the relative part and my code should apped it to settings.PROJECT_PATH ... Am i thinking it right or is there a more "django-like" way to do it There already is a implementation of a RelativeFilePathField but several people told me there are better ways to accomplish what i wanna do... Thank you very much for your help. Jonni -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: The problem with storing relative paths
i was there already... but the problem that the system-specific absolute path is saved into database persists... i want to be able to drag the whole system including database to another server... and that would be problematic if i store absolute paths thanks jonni Am Freitag, 15. Februar 2013 21:15:01 UTC+1 schrieb Robin Fordham: > > Hi jonni, > > How about something like; > > FORMTEMPLATE_PATH = os.path.join(settings.PROJECT_PATH, 'templates/forms' > > class Somemodel(models.Model): > formtemplate = FilePathField(path='FORMTEMPLATE_PATH', > match=".\*.htm[l]") > . > . > > > On Friday, February 15, 2013 4:14:44 PM UTC, JZint wrote: >> >> Hello! >> >> So this is what i wanna do: >> >> I have built a model with an admin interface for letting the user create >> his own site. it has following fields: >> >> name = models.CharField(max_length = 50) >> formtemplate = >> FilePathField(path='/path/to/project/myforms/templates/forms', >> match=".\*.htm[l]") >> thankyoutemplate = >> FilePathField(path='/path/to/project/myforms/templates/forms', >> match=".\*.htm[l]", blank=True) >> slug = models.CharField(max_length = 50) >> >> He should be able to upload his template-files to that folder and >> afterwards selecting it in the model admin. but the database is storing the >> absolute path which means, after putting the project to another path or >> system all paths in the database are useless. >> id like to avoid that and looked for solutions. I would like the database >> to store only the relative part and my code should apped it to >> settings.PROJECT_PATH ... Am i thinking it right or is there a more >> "django-like" way to do it >> >> There already is a implementation of a RelativeFilePathField but several >> people told me there are better ways to accomplish what i wanna do... >> >> Thank you very much for your help. >> >> Jonni >> >> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.