Django model proxy override save

2015-11-18 Thread drifter
I want to override the save for a model when saved from the proxy I've 
tried commenting out as much as I can but it's still using the model save. 
Here's my code.

class MovieProxy(Movie):
class Meta:
verbose_name = 'movie show'
proxy=True

def save(self, *args, **kwargs):
#super(MovieProxy, self).save(*args, **kwargs)
fily = open('post-{0}'.format(self.id),'w')
fily.write(*args)
fily.write('\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n')
fily.write(**kwargs)
fily.close()

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/da0cdf2f-fab0-4c35-ba7d-1748c4ab48e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django inlineform not adding cinema field info on save

2015-09-29 Thread drifter


I have a inline form which looks like the snapshot above but when I save 
the "Cinema, Movie type and Price" doesn't get added to the additional 
fields (each starts time is another instance of the field). For example the 
second line with 2015-10-02 Cinema2 will only be saved on the instance of 
Show 11:00so it only saves on the first instance.

This is the model Show:

class Show(models.Model):

MOVIE_TYPES = (
('2', '2D'),
('3', '3D'),
)

CINEMAS = (
('C1', 'Cinema 1'),
('C2', 'Cinema 2'),
('C3', 'Cinema 3'),
('C4', 'Cinema 4'),
)

movie = models.ForeignKey('Movie', related_name='shows')
venue = models.ForeignKey(Venue)
old_details = models.TextField(blank=True, editable=False,)
starts = models.DateField(db_index=True,)
starts_time = models.TimeField(db_index=True,)
couple_price = models.IntegerField(blank=True, null=True)
vip = models.IntegerField(blank=True, null=True)
cinema = models.CharField(
max_length=10,
choices=CINEMAS,
blank=True,
null=True
)
comment = models.TextField(blank=True, )
booking_url = models.URLField(blank=True, )
created = models.DateTimeField(editable=False, db_index=True,)
modified = models.DateTimeField(editable=False, db_index=True,)
price = models.IntegerField(blank=True, null=True)
new_price = models.IntegerField(blank=True, null=True)
movie_type = models.CharField(
max_length=1,
choices=MOVIE_TYPES,
blank=True,
null=True
)

class Meta:
ordering = ['starts', 'starts_time',]
verbose_name = 'movie show'

def __unicode__(self):
return u'%s - %s - %s %s' % (self.movie.name, self.venue.name, 
self.starts, self.starts_time)

def save(self):
if not self.id:
self.created = datetime.datetime.now()
self.modified = datetime.datetime.now()
super(Show, self).save()

def movie_type_str(self):
if not self.movie_type:
return '-'
else:
return self.movie_type + 'D'

and the form...

class ShowInlineForm(forms.ModelForm):

def __init__(self, *args, **kwargs):
super(ShowInlineForm, self).__init__(*args, **kwargs)
theatres = Category.objects.get(slug='movie-theatres')
self.fields['venue'].queryset = 
Venue.objects.filter(categories=theatres, visible=True,).order_by('name')

class Meta:
fields = [
'venue',
'price',
'movie_type',
'starts',
'cinema',
'starts_time',
]

in the admin.py

class MovieShowInline(admin.TabularInline):

formfield_overrides = {
models.TimeField: {'widget': AdminTimeWidget(format='%H:%M')},
models.TextField: {'widget': TextInput()},
}
model = Show
extra = 1
template = 'admin/movies/show/inline_edit/tabular.html'
form = ShowInlineForm
exclude = ('comment', 'booking_url',)

def queryset(self, request):
"""Do not show shows older than today """

qs = super(MovieShowInline, self).queryset(request)
return 
qs.filter(starts__gte=datetime.date.today()).order_by('venue__name', 'starts', 
'starts_time')
class MovieShowAdmin(CommonAdmin):
fields = ('name',)
readonly_fields = ('name',)
list_display = [
'name',
'modified_by',
'created_by',
'modified',
'created',
'visible',
]
inlines = [MovieShowInline,]
list_filter = ['modified', 'created', 'visible', 'showing']

and the form admin/movies/show/inline_edit/tabular.html

{% load i18n admin_static admin_modify %}.vTimeField { width:40px 
!important; }
  {{ inline_admin_formset.formset.management_form }}
   {{ inline_admin_formset.opts.verbose_name_plural|capfirst }}
   {{ inline_admin_formset.formset.non_form_errors }}
   
 
 {% for field in inline_admin_formset.fields %}
   {% if not field.widget.is_hidden %}
 {{ field.label|capfirst }}
 {% if field.help_text %}{% endif %}
 
   {% endif %}
 {% endfor %}
 
 {% trans "Copy?" %}
 {% comment %}
 {% if inline_admin_formset.formset.can_delete %}{% trans "Delete?" 
%}{% endif %}
 {% endcomment %}
 

 
 {% for inline_admin_form in inline_admin_formset %}
{% if inline_admin_form.form.non_field_errors %}
{{ 
inline_admin_form.form.non_field_errors }}
{% endif %}


  {% if inline_admin_form.has_auto_field %}{{ 
inline_admin_form.pk_field.field }}{% endif %}
  {{ inline_admin_form.fk_field.field }}
  {% spaceless %}
  {% for fieldset in inline_admin_form %}
{% for line in fieldset %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users"