These are chat archives for django/django

25th
May 2017
Ghost
@ghost~58e3220cd73408ce4f55e9fb
May 25 2017 07:57
yo!
Anyone here?
I was wondering if anybody is up for a collaborative project using DJango. It'll be great learning from each other.
UKJP
@sam-aldis
May 25 2017 08:09
I could do with a hand on something i’m making.. currently using tornadoweb but i’ll happily convert it over to Django if you want @YiiKuoChong
looking for all the help we can get in any area
@mikeleg can you be more specific?
Ghost
@ghost~58e3220cd73408ce4f55e9fb
May 25 2017 08:17
@sam-aldis Are you sure? I don't want to be bothersome. I have no understanding in Tornadoweb so I can't help you convert it to DJango.
Anish Shrestha
@annshress
May 25 2017 08:18
@YiiKuoChong You can do it. I believe in you.
Sagar
@sagar-sehgal
May 25 2017 08:21
hi everyone!!! I am new to this org.. I know python programming.What else must I learn in order to contribute to this organisation???Plz help me.....I want to contribute to this organisation..
Michele Gatti
@mikeleg
May 25 2017 08:34
@sam-aldis i can use the arrayField with django-filter
UKJP
@sam-aldis
May 25 2017 09:11
@YiiKuoChong yeah i’m sure.. Tornadoweb is really easy to get your head around.. in fact you might even prefer it to Django but i’m looking for all the help I can get and if that means converting it to Django thats not a problem at all :)
UKJP
@sam-aldis
May 25 2017 10:41
So guys.. if anyone has experience with Tornadoweb vs
Django.. can you tell me why i would make the switch to Django over Tornadoweb?
ismail sarenkapic
@ismailnp96_twitter
May 25 2017 11:26

Hi, I'm trying to create a digital marketplace site where users will be able to register and submit their products.
I created the Product model and connected it with User with foreign key.Everything seems to be alright, but when I submit my product i get the following error:

null value in column violates not-null constraint
it looks like relation between product and user is not properly configured(regardless of my mixin that is suppose to handle it)

note that I'm using:
database : postgresql
allauth(for user registration)

models.py

from django.conf import settings
from django.db import models
from django.db.models.signals import pre_save, post_save
from django.core.urlresolvers import reverse
from django.utils.text import slugify
# Create your models here.



class Product(models.Model):
   seller = models.ForeignKey(settings.AUTH_USER_MODEL)
   #user = models.OneToOneField(settings.AUTH_USER_MODEL)
   # user = models.ForeignKey(settings.AUTH_USER_MODEL)
   # managers = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name="managers_products", blank=True)
   title = models.CharField(max_length=30) #owiuerpoajsdlfkjasd;flkiu1p3o4u134123 ewjfa;sd
   slug = models.SlugField(blank=True, unique=True)
   description = models.TextField()
   price = models.DecimalField(max_digits=100, decimal_places=2, default=9.99, null=True,) #100.00


   def __unicode__(self): #def __unicode__(self):
      return self.title

views.py

from django.views import View
from django.views.generic import (
                CreateView,
                )

from .forms import ProductModelForm
from .mixins import FormUserNeededMixin
# Create your views here.


class ProductCreateView(FormUserNeededMixin, CreateView):
    form_class = ProductModelForm
    template_name = 'create_view.html'

forms.py

from django import forms

from django.utils.text import slugify

from .models import Product


class ProductModelForm(forms.ModelForm):
   class Meta:
      model = Product
      fields = [
         "title",
         "description",
         "price",
      ]

mixins.py

from django import forms
from django.forms.utils import ErrorList

class FormUserNeededMixin(object):

     def form_valid(self, form):
        if self.request.user.is_authenticated():
            form.instance.user = self.request.user
            return super(FormUserNeededMixin, self).form_valid(form)
        else:
            form._errors[forms.forms.NON_FIELD_ERRORS] = ErrorList(["User must be logged in to continue."])
            return self.form_invalid(form)
Apophus
@Apophus
May 25 2017 16:01
Hey guys
Getting an OperationalError (1054, "Unknown column 'x' in 'field list'") .
Usually I'd run migartions but now kinda stuck. Any help will be appreciated.