我正在尝试从object (foto)
删除Album
,我希望views
返回detail view
(当前相册),但我无法设置{{1}当前专辑。我尝试了各种各样的方法,但我无法弄清楚并解决它。
也许我应该为foto的对象添加一些独立的pk
,或者使用一些通常的定义代替泛型foto_pk
?我没有想法。请给我一些线索......谢谢。
网址:
DeleteView
查看:
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^(?P<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'),
url(r'albumadd/$', views.AlbumCreate.as_view(), name='album-add'),
url(r'update/(?P<pk>[0-9]+)/$', views.AlbumUpdate.as_view(), name='albumbum-update'),
url(r'delete/(?P<pk>[0-9]+)/$', views.AlbumDelete.as_view(), name='albumbum-delete'),
url(r'^(?P<pk>[0-9]+)/fotoadd/$', views.FotoCreate.as_view(), name='foto-add'),
url(r'^(?P<pk>[0-9]+)/fotodelete/$', views.FotoDelete.as_view(), name='foto-delete'),
其他尝试观点:
class FotoDelete(LoginRequiredMixin, DeleteView):
model = Foto
def album(request, pk):
album = Album.objects.get(pk=pk)
return reverse_lazy('albumbum:detail', kwargs={'pk': album.pk})
其他尝试观点:
class FotoDelete(LoginRequiredMixin, DeleteView):
model = Foto
success_url = reverse_lazy('albumbum:detail', kwargs={'pk': Album.pk})
我还附加了foto的CreateView(相册中的对象): (也许这里有一些问题)
class FotoDelete(LoginRequiredMixin, DeleteView):
model = Foto
album = get_object_or_404(Album, pk=pk)
success_url = reverse_lazy('albumbum:detail', kwargs={'pk': album.pk})
models.py
class FotoCreate(CreateView):
model = Foto
fields = ['nazwa_foto', 'obraz']
def form_valid(self, form):
f = Album.objects.get(pk=self.kwargs.get('pk'))
form.instance.albumnr = f
return super(FotoCreate, self).form_valid(form)
def get_success_url(self):
return reverse('albumbum:detail', kwargs={'pk': self.kwargs.get('pk')})
答案 0 :(得分:0)
试试这个,它应该有效。
@spselectvalue nvarchar(MAX),
// Select multiple Ids based on multiple items from list box
DECLARE @Dis TABLE (DisID int)
INSERT INTO @Dis
SELECT DId
FROM [table name]
WHERE [COLUMN] IN ('+@spselectvalue +')
EXEC sp_executesql @Dis
// Insert multiple Ids (from above select statement) into different table
INSERT INTO [dbo].[DifferentTable] ([SelectedIds])
VALUES
(
(SELECT DisID from @Dis)
)
答案 1 :(得分:0)
也有效:
=(UNIX + ("1/1/1970"-"1/1/1900"+1)*86400) / 86400