Re: Adding code when pressing one of admin's save buttons

2017-07-25 Thread Mike Dewhirst

On 25/07/2017 9:29 PM, ron_w_add via Django users wrote:


I am using Django’s admin interface to create new records. A record 
includes (amongst other fields) the date and time that a photo was 
taken. These fields will be filled into the database when either the 
‘Save and add another’, ‘Save and continue editing’ or the ‘Save’ 
buttons are pressed (i.e. these details will be read from the image 
file and entered into the database rather than the administrator doing 
this manually).


How can I added the extra code required to add the date and time when 
I press one of these buttons? Some example code would be appreciated.




class MyModel(models.Model):

...
photodatetime = models.DateTimeField()  
...

def save(self, *args, **kwargs):
photodatetime = self.getphotoinfo()
super(MyModel, self).save(*args, **kwargs)

def getphotoinfo(self):
...






Thanks

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/63559d9c-15c6-4ce1-b477-8e24b030ce0c%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/990bc5c5-a65d-d729-b895-6eaf0293d139%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Adding code when pressing one of admin's save buttons

2017-07-25 Thread Thiago Luiz Parolin
Try using 'def save(self):' on your models.
When you save a new record, this will be executed, so if you hit any
button, you are saving in anyway and the code will be executed.

Just my cents about your question.


2017-07-25 8:29 GMT-03:00 ron_w_add via Django users <
django-users@googlegroups.com>:

> I am using Django’s admin interface to create new records. A record
> includes (amongst other fields) the date and time that a photo was taken.
> These fields will be filled into the database when either the ‘Save and add
> another’, ‘Save and continue editing’ or the ‘Save’ buttons are pressed
> (i.e. these details will be read from the image file and entered into the
> database rather than the administrator doing this manually).
>
>
>
> How can I added the extra code required to add the date and time when I
> press one of these buttons? Some example code would be appreciated.
>
>
>
> Thanks
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/63559d9c-15c6-4ce1-b477-8e24b030ce0c%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACTnJ001etLw57wChAeEKJWVKqTVuQtcjgJoSDGAedjoEzXouQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Adding code when pressing one of admin's save buttons

2017-07-25 Thread ron_w_add via Django users
 

I am using Django’s admin interface to create new records. A record 
includes (amongst other fields) the date and time that a photo was taken. 
These fields will be filled into the database when either the ‘Save and add 
another’, ‘Save and continue editing’ or the ‘Save’ buttons are pressed 
(i.e. these details will be read from the image file and entered into the 
database rather than the administrator doing this manually). 

 

How can I added the extra code required to add the date and time when I 
press one of these buttons? Some example code would be appreciated.

 

Thanks

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/63559d9c-15c6-4ce1-b477-8e24b030ce0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.