Created
September 17, 2013 01:55
-
-
Save manuel14/6589159 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def guardar_noticia(request): | |
if request.method=='POST': | |
titulo = request.POST['titulo'] | |
autor = request.POST['autor'] | |
texto = request.POST['texto'] | |
usuario = request.POST['usuario'] | |
if usuario.isdigit(): | |
return HttpResponseRedirect('/') | |
else: | |
noticia = Noticia(titulo=titulo, autor=autor, texto=texto, usuario=User(usuario)) | |
noticia.save() | |
return HttpResponseRedirect('/noticias') | |
else: | |
return HttpResponseRedirect('/') | |
class Noticia(models.Model): | |
titulo = models.TextField(unique=True) | |
autor = models.TextField(verbose_name='Autor') | |
texto = models.TextField(help_text='Redacta la Noticia') | |
imagen = models.ImageField(upload_to='rrpp', verbose_name='imagen', blank=True) | |
#tiempo_registro = models.DateTimeField(auto_now=True) | |
usuario = models.ForeignKey(User) | |
def __unicode__(self): | |
return self.titulo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment