These are chat archives for django/django

22nd
Dec 2016
John
@flyboy1565
Dec 22 2016 01:35
@marzsv hahahaha
vaibhav jain
@vaibhav-jain
Dec 22 2016 06:56
@Federico-Comesana Yeah you can have an attribute
Nadir
@nadirollo
Dec 22 2016 11:36
Hello :)
I’m building a django app that it’s not using a DB (mostly) - the data is coming from API’s. I’m trying to build a form where I can have what would be a foreign key, say, having one set of fields that can appear more than once...
With a model based app, would be quite simple, just reference the model with the FK and :boom: , would work
now… as I don’t have models to represent this objects, is there something I haven’t seen on the docs to achieve what I’m looking for? (if it made any sense what I tried to explain)
I’ve seen you can define models which are not represented on the DB ( managed = False on the class Meta)
but still, it will fail if I add FK to those models even when the FK are also managed = False
Nadir
@nadirollo
Dec 22 2016 11:48
FormSets, that’s what I was looking for I think :)
Sudhir Nimavat
@snimavat
Dec 22 2016 13:21
Planning to use django for a simple project (a cms like site)
what is the general memory requirement for django
I come from java background.. and i guess django should need much less memory thn java
What i am expecting is, initially, be able to deploy few client sites on a single 512mb ram instance
how much django may need, for a simple cms type site (i may use django-cms )
John
@flyboy1565
Dec 22 2016 15:30
@snimavat honestly I wouldn't know. I use django on a raspberry pi... It's a little slow.. but not sooo bad..
Miracle Ayodele
@iammiracle
Dec 22 2016 16:02
hi guys
the get_or_create funtion has really being giving me hard times
how do i correctly use it
update = personalInfo.objects.get_or_create(user_id=user)[0]
Miracle Ayodele
@iammiracle
Dec 22 2016 16:08
this will update or create the first record
update or create for the first user
the second user will not be able to update
Slava
@scream4ik
Dec 22 2016 16:12
data = PersonalInfo.objects.filter(user_id=user).first()
if data is None:
    PersonalInfo.objects.create(user_id=user)
Sudhir Nimavat
@snimavat
Dec 22 2016 16:12
@Channel any one has any experiences.. how memory hungry django is.. for not so complex apps
Miracle Ayodele
@iammiracle
Dec 22 2016 16:24
@scream4ik this gives me the same thing
def SavePersonalInfo(request):
context = {}
user = request.user.user_id
print user
data = personalInfo.objects.filter(user_id=user).first()

if data is None:
    update = personalInfo.objects.create(user_id=user)
else:
    update = personalInfo.objects.get(user_id=user)

personalupdate = PersonalInfoForm(data=request.POST, instance=update)
if request.POST:
    print "Yes"
    if personalupdate.is_valid():
        print "Yeske"
        personalupdate.save()
        # return HttpResponseRedirect('/profile/')
        return HttpResponse("Your Account Updated")
else:
    print "No"
    personalupdate = PersonalInfoForm(instance=update)
context.update({'personalInfo': personalupdate})
return render(request, 'profile.html', context)
print "Updated"
Slava
@scream4ik
Dec 22 2016 16:28
@koderNeptune
user = request.user.user_id
data = personalInfo.objects.filter(user_id=user).first()

if data is None:
    update = personalInfo.objects.create(user_id=user)

personalupdate = PersonalInfoForm(request.POST or None, instance=update)
if request.POST:
    if personalupdate.is_valid():
        personalupdate.save()
        return HttpResponse("Your Account Updated")

context.update({'personalInfo': personalupdate})
return render(request, 'profile.html', context)
why you don't create user profile information by signals after registration?
Philip Eckert
@pae4557
Dec 22 2016 16:33
Anyone know of an easy way to list out all the fields of an object instance?
Don't see anything in the docs... :/
Miracle Ayodele
@iammiracle
Dec 22 2016 16:35
@scream4ik i dont know how that works tho, i will check it out
personalupdate = PersonalInfoForm(request.POST or None, instance=update) being outside the condition gives error
local variable 'update' referenced before assignment
Slava
@scream4ik
Dec 22 2016 16:37
data = personalInfo.objects.filter(user_id=user).first()
replace to
update = personalInfo.objects.filter(user_id=user).first()
Miracle Ayodele
@iammiracle
Dec 22 2016 16:40
done but not updating still
i tried debugging
if request.POST:
    print "Yes"
    if personalupdate.is_valid():
        print "Yeske"
it printed Yes
but not Yeske
so seems the personalupdate is still not valid
Slava
@scream4ik
Dec 22 2016 16:42
print personalupdate.errors
Miracle Ayodele
@iammiracle
Dec 22 2016 16:44
nothings was printed
not showing errors
def SavePersonalInfo(request):
context = {}
user = request.user.user_id
print user

update = personalInfo.objects.filter(user_id=user).first()

if update is None:
    update = personalInfo.objects.create(user_id=user)

personalupdate = PersonalInfoForm(data=request.POST, instance=update)

if request.POST:
    print "Yes"
    if personalupdate.is_valid():
        print personalupdate.errors
        print "Yeske"
        personalupdate.save()
        # return HttpResponseRedirect('/profile/')
        return HttpResponse("Your Account Updated")
else:
    print "No"
    personalupdate = PersonalInfoForm(instance=update)
context.update({'personalInfo': personalupdate})
return render(request, 'profile.html', context)
print "Updated"
Slava
@scream4ik
Dec 22 2016 16:45
you need add print personalupdate.errors outside if personalupdate.is_valid()
Miracle Ayodele
@iammiracle
Dec 22 2016 16:46
done the same
printed after print "yes"
Slava
@scream4ik
Dec 22 2016 16:47
great. Now you can see your form errors in console
Miracle Ayodele
@iammiracle
Dec 22 2016 16:48
at all
and it updated the user record
but other users record is not updating
whereas it created the user_id
but will not update the record
@scream4ik hope you get what i am saying now
Miracle Ayodele
@iammiracle
Dec 22 2016 17:04
@scream4ik got the error, and its fixed, thanks