Re: How to insert recent session Username or UserId in database table in Django?

2015-08-19 Thread Luis Zárate
Did you make migrations ?


$ python manage.py makemigrations
$ python manage.py migrate

El miércoles, 19 de agosto de 2015, Remaze Vs 
escribió:
> operationalError at/
> no such column:products_product.User_id
>
> --
> 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/715027d9-edf3-4d1c-8270-bc51e724f7f3%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyNbLSZguCwxBFCDtuZfM7wZrBuzKEFq%2BtL4oAvs9fdKWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to insert recent session Username or UserId in database table in Django?

2015-08-19 Thread Remaze Vs
operationalError at/
no such column:products_product.User_id 

-- 
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/715027d9-edf3-4d1c-8270-bc51e724f7f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to insert recent session Username or UserId in database table in Django?

2015-08-19 Thread Remaze Vs

>
> OperationalError at /
>>
>> no such column: products_product.User_id
>>
>>

operationalError at/
no such column:products_product.User_id 

-- 
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/040840b3-e8b2-4614-824c-d28e05f7b443%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to insert recent session Username or UserId in database table in Django?

2015-08-19 Thread James Schneider
Use 'from' instead of 'import' for the first word.

-James
On Aug 19, 2015 12:33 AM, "Remaze Vs"  wrote:

> thanks for your time, but I am facing error invalid syntax , on that line
>  import django.contrib.auth.models import User
>
> my model.py
> from django.conf import settings
> from django.core.urlresolvers import reverse
> from django.db import models
> from django.db.models.signals import post_save
> import django.contrib.auth.models import User
>
> class Product(models.Model):
> title = models.CharField(max_length=120)
> description = models.TextField(null=True, blank=True)
> category = models.ManyToManyField(Category, null=True, blank=True)
> price = models.DecimalField(decimal_places=2, max_digits=100,
> default=29.99)
> sale_price = models.DecimalField(decimal_places=2, max_digits=100,\
> null=True, blank=True)
> slug = models.SlugField(unique=True)
> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
> updated = models.DateTimeField(auto_now_add=False, auto_now=True)
> active = models.BooleanField(default=True)
> update_defaults = models.BooleanField(default=False)
> User = models.ForeignKey(User)
>
>
> def __unicode__(self):
> return self.title
>
> class Meta:
> unique_together = ('title', 'slug')
>
> def get_price(self):
> return self.price
>
> def get_absolute_url(self):
> return reverse("single_product", kwargs={"slug": self.slug})
>
> my view.py
>
> class DealsForm(ModelForm):
> class Meta:
> model = Product
> fields =
> ['title','description','category','price','sale_price','slug','active','update_defaults','User']
>
> pls help.
>
> --
> 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/a6da1496-ff2b-42ee-923e-8c3d3a34b017%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXdGMC7i5A_fBa4OWu2y-LGyJgWL3eqhAZpdhg_3AdqCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to insert recent session Username or UserId in database table in Django?

2015-08-19 Thread Remaze Vs
thanks for your time, but I am facing error invalid syntax , on that line  
 import django.contrib.auth.models import User

my model.py 
from django.conf import settings
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models.signals import post_save
import django.contrib.auth.models import User

class Product(models.Model):
title = models.CharField(max_length=120)
description = models.TextField(null=True, blank=True)
category = models.ManyToManyField(Category, null=True, blank=True)
price = models.DecimalField(decimal_places=2, max_digits=100, default=29.99)
sale_price = models.DecimalField(decimal_places=2, max_digits=100,\
null=True, blank=True)
slug = models.SlugField(unique=True)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
updated = models.DateTimeField(auto_now_add=False, auto_now=True)
active = models.BooleanField(default=True)
update_defaults = models.BooleanField(default=False)
User = models.ForeignKey(User)
 

def __unicode__(self):
return self.title

class Meta:
unique_together = ('title', 'slug')

def get_price(self):
return self.price

def get_absolute_url(self):
return reverse("single_product", kwargs={"slug": self.slug})

my view.py

class DealsForm(ModelForm):
class Meta:
model = Product
fields = 
['title','description','category','price','sale_price','slug','active','update_defaults','User']

pls help.

-- 
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/a6da1496-ff2b-42ee-923e-8c3d3a34b017%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to insert recent session Username or UserId in database table in Django?

2015-08-18 Thread Luis Zárate
You need to make a foreignkey to a user.

if you have a custom user look here
https://docs.djangoproject.com/en/1.8/topics/auth/customizing/#referencing-the-user-model

but if it is a simple django authentication use

import django.contrib.auth.models import User
class Product(models.Model):
  user = models.ForeignKey(User)

Remember in the view you can access to the current user with
request.user  and the full user name is accessible calling
request.user.get_full_name()


2015-08-17 23:34 GMT-06:00 Remaze Vs :

> I am new in Django, I am trying to make ecommerce  project. I want to
> Insert recent login username or user Id in database by using formview
> code.so how to insert recent login username in database?
>
> Here is Model.py
>
> class Product(models.Model):
>
>
> title = models.CharField(max_length=120)
> description = models.TextField(null=True, blank=True)
> category = models.ManyToManyField(Category, null=True, blank=True)
> price = models.DecimalField(decimal_places=2, max_digits=100,
> default=29.99)
> sale_price = models.DecimalField(decimal_places=2, max_digits=100,\
> null=True, blank=True)
> slug = models.SlugField(unique=True)
> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
> updated = models.DateTimeField(auto_now_add=False, auto_now=True)
> active = models.BooleanField(default=True)
> update_defaults = models.BooleanField(default=False)
> username = ?
>
>
> Here view.py
>
>  class DealsForm(ModelForm):
>
> class Meta:
> model = Product
> fields =
> ['title','description','category','price','sale_price','slug','active','update_defaults','username']
>
>
> I want to add Last field username insert in database but how ...?
>
>
>
>
>
>
>
>
> --
> 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/76b28224-3259-460d-9e6f-8e830a5c03ad%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyOR6rRTrKpX7HnX6Pz-G94fJN-uJWUcKzaRS8_jOx7_Rg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.