These are chat archives for django/django

5th
Aug 2016
Roel
@roelzkie15
Aug 05 2016 02:18

@antoniocarlosortiz i have an employee table as a parent and requirement table as child, the employee has an auto increment id column and the other one has an auto increment id and an emp_id column which is fk to the employee.id.

Now what i would like to happen is when the employee.id update the requirement.emp_id also automatically updates with it. How can i do that in django model since there is no on_update=CASCADE? Unlike in the mysql? I heard signals can handle these please help.

a-atalla
@a-atalla
Aug 05 2016 04:52
@huyhoang17
phanhoang17
@huyhoang17
Aug 05 2016 06:36
@a-atalla :
Oclay
@Oclay2_twitter
Aug 05 2016 06:45
@huyhoang17 django oscar
phanhoang17
@huyhoang17
Aug 05 2016 06:47
Oh, thank you, everyone =))
Igor Malinov
@malinich
Aug 05 2016 08:32
Hi everyone. guys give me advice: BigIntegerField is a 64 bit integer. but to me need store numbers <= 2**66. on it Django throw exception. Have some proper fields to use? excuse me for my english
Igor Malinov
@malinich
Aug 05 2016 08:52
sadly it constraint by mysql himself. oh
sarath
@sarathhereicme_twitter
Aug 05 2016 10:59
anomaly detection in python ? code ?
mark
@thenewidealism_twitter
Aug 05 2016 12:52
could anyone please tell me why this post form insn’t sending any data on this page? i’ve been struggling with it almost for a week now. http://192.241.153.25:8000
Oleg Serbokryl
@Krokop
Aug 05 2016 12:53
@thenewidealism_twitter hi, can i help?)
mark
@thenewidealism_twitter
Aug 05 2016 12:54
um sure.
so, i get that there is something wrong with the backend
but other than that, im not sure how to fix this...
Oleg Serbokryl
@Krokop
Aug 05 2016 12:55
@Krokop can show code?
which save post
mark
@thenewidealism_twitter
Aug 05 2016 12:57
just a sec.
notice im using django rest frame work.
Oleg Serbokryl
@Krokop
Aug 05 2016 13:04
i need login
mark
@thenewidealism_twitter
Aug 05 2016 13:04
try test and test 1234
mark
@thenewidealism_twitter
Aug 05 2016 13:19
is it the problem with publish then?
that’s for the date
Oleg Serbokryl
@Krokop
Aug 05 2016 13:19
this erors mess "NOT NULL constraint failed: posts_post.publish"
mark
@thenewidealism_twitter
Aug 05 2016 13:20
okay,
i commented it in
still no luck though.,
oh wait.
i have to create a new field then
oh shit
it’s working.
but but
i have few questions though.
Oleg Serbokryl
@Krokop
Aug 05 2016 13:22
:)
mark
@thenewidealism_twitter
Aug 05 2016 13:22
i have to confess i don’t have full knowledge of the workings behind these things.
but
is there anyway i can auto generate that publish date without having to type it in myself?
Oleg Serbokryl
@Krokop
Aug 05 2016 13:23
yes
Igor Malinov
@malinich
Aug 05 2016 13:24
auto_now_add=True
Oleg Serbokryl
@Krokop
Aug 05 2016 13:24
it’s in models.py
Igor Malinov
@malinich
Aug 05 2016 13:24
into field of your model
mark
@thenewidealism_twitter
Aug 05 2016 13:24
hmm….
also, how do i have to modify the serializer if i want to limit the posting function only for the logged in users?
um before that
i have one more problem.
the posting itself is working, but for some reason,
it comes with comments that i didn’t type in
also, the content’s different.
try typing in
Oleg Serbokryl
@Krokop
Aug 05 2016 13:28
too many questions
mark
@thenewidealism_twitter
Aug 05 2016 13:28
and you will see a new post with random comments,
sorry :P
Igor Malinov
@malinich
Aug 05 2016 13:28
in your serializer you can define validate mathod and inside take context, if im not wrong
into context you have request.user
mark
@thenewidealism_twitter
Aug 05 2016 13:30
okay.
im having probelm with the posting system though
mark
@thenewidealism_twitter
Aug 05 2016 13:31
thanks for that @malinich i will take a look at it.
Igor Malinov
@malinich
Aug 05 2016 13:31
class TemplateSerializer(serializers.ModelSerializer):
def validate_parent(self, value):
print(self.context['request'].user)
mark
@thenewidealism_twitter
Aug 05 2016 13:37
do you happen to know why the content for the post is blank?
Igor Malinov
@malinich
Aug 05 2016 13:43
i hope Oleg help you
mark
@thenewidealism_twitter
Aug 05 2016 13:43
… okay
i guess i will have to use stackoverflow then
thanks for the tip.
Igor Malinov
@malinich
Aug 05 2016 13:44
+
Oleg Serbokryl
@Krokop
Aug 05 2016 13:45
here content is not empty http://192.241.153.25:8000/#/post/testing
mark
@thenewidealism_twitter
Aug 05 2016 13:45
if i type in something lengthy, it gets empty
anyways, it’s a mess.
Everett (Mike) Wiley
@poppabear8883
Aug 05 2016 13:46
@thenewidealism_twitter check your model
mark
@thenewidealism_twitter
Aug 05 2016 13:48
what should i check?
the new post comes with 2 pre existing comments
*too
Oleg Serbokryl
@Krokop
Aug 05 2016 13:48
@thenewidealism_twitter http://192.241.153.25:8000/api/posts/test-2-7-8-9-10-22/ content is not empty, you just din’t show it on fronted
«the new post comes with 2 pre existing comments « - this is problem
mark
@thenewidealism_twitter
Aug 05 2016 13:50
but i don’t know why the content’s not showing on the html
:P
This message was deleted
This message was deleted
This message was deleted
This message was deleted
Oleg Serbokryl
@Krokop
Aug 05 2016 13:51
can show code on fronted?
mark
@thenewidealism_twitter
Aug 05 2016 13:52
sec
you know angular js?
Igor Malinov
@malinich
Aug 05 2016 13:52
little
mark
@thenewidealism_twitter
Aug 05 2016 13:52
this is the front end.
Oleg Serbokryl
@Krokop
Aug 05 2016 13:52
little
can show post.html?
mark
@thenewidealism_twitter
Aug 05 2016 13:55
sec
<div class="post_article_container">
    <div class="post_top_navigation"></div>
    <a class="previous_button" href="#/posts">



  <div class="row">
    <div class="col-xs-12">
      <div class="post_container">

        <div class="post_title_bar">
      <div id="ios-arrow-left" title="Go Back"></div></a>
        <h6 class="post_date">{{post.publish}}</h6>
    </div>

<div class="post_content_wrapper">
        <div class="pull-left">
          <h4>{{post.title}}</h4>
        </div>

        <div class="pull-right">

        </div>

        <div class="clearfix"></div>

        <div>
          <div style="overflow-wrap: break-word;">{{post.content}}<br>
                    <img src="{{ post.image }}"></div>

          <div ng-if="post.comments.length">
            <strong>Comments:</strong>
              <blockquote ng-repeat="comment in post.comments">
                {{comment.content}}<br> {{comment.timestamp}}
              </blockquote>
          </div>
        </div>
      </div>
    </div>


    </div>
  </div>
</div>
Igor Malinov
@malinich
Aug 05 2016 13:56
i can't verify but
  1. .then(function(result) {
              $scope.post = result;  // use only result
            });
  2. then you queryPost
    Posts.queryPosts().$promise.then(function(result) {
           $scope.posts = result.results; // result.results may be this the Point 
         });
may be im wrong i cant check
or second reason:
toggleClass( className, addOrRemove );
mark
@thenewidealism_twitter
Aug 05 2016 14:02
can’t find toggleClass anywhere
Igor Malinov
@malinich
Aug 05 2016 14:02
$('#logout_form').toggleClass(show)
oh it not for it
mark
@thenewidealism_twitter
Aug 05 2016 14:02
yea
no
Igor Malinov
@malinich
Aug 05 2016 14:02
im sorry
Oleg Serbokryl
@Krokop
Aug 05 2016 14:03
can you set here some console.log(’result’,result) https://dpaste.de/43WY#L91
mark
@thenewidealism_twitter
Aug 05 2016 14:04
done.
oh
it’s throwing 404 error
weird.
Oleg Serbokryl
@Krokop
Aug 05 2016 14:08
ok
i find
you show post by user
it’s wired
mark
@thenewidealism_twitter
Aug 05 2016 14:10
by user? what do you mean?
any solution?
Oleg Serbokryl
@Krokop
Aug 05 2016 14:10
thats why you have 404 on Thisisatestarticle
because user with name Thisisatestarticle
doesn’t exist
mark
@thenewidealism_twitter
Aug 05 2016 14:11
sec..
i don’t think it’s username
sec
Oleg Serbokryl
@Krokop
Aug 05 2016 14:12
if Thisisatestarticle change on test
mark
@thenewidealism_twitter
Aug 05 2016 14:13
wait
i think i got it.
it’s because it lowercase the title
it should be thisisatestarticle not Thisisatestarticle.
i don’t know how i can fix that though...
Everett (Mike) Wiley
@poppabear8883
Aug 05 2016 14:14
just lowercase it ... lol
mark
@thenewidealism_twitter
Aug 05 2016 14:15
i don’t know how :)
Igor Malinov
@malinich
Aug 05 2016 14:15
=)
Oleg Serbokryl
@Krokop
Aug 05 2016 14:15
sorry my bad
mark
@thenewidealism_twitter
Aug 05 2016 14:15
but but
Oleg Serbokryl
@Krokop
Aug 05 2016 14:15
you show by title
mark
@thenewidealism_twitter
Aug 05 2016 14:15
yeah
Oleg Serbokryl
@Krokop
Aug 05 2016 14:15
thats why you always get same result
title always test, so it just return first which get from db
mark
@thenewidealism_twitter
Aug 05 2016 14:16
another problem im having is tha
t
you notice the article titled This is a test article?
it has to be dashed like this This-is-a-test-article
instead, the angular js renders it as
Everett (Mike) Wiley
@poppabear8883
Aug 05 2016 14:17
you probably should learn some basics before tackling frameworks
mark
@thenewidealism_twitter
Aug 05 2016 14:17
This%20is%20a%20test%20article
@poppabear8883 i try to. plan to learn bit by bit everyday. any recommended materials?
Everett (Mike) Wiley
@poppabear8883
Aug 05 2016 14:18
yea, google ... a lot
mark
@thenewidealism_twitter
Aug 05 2016 14:18
...
fine.
Everett (Mike) Wiley
@poppabear8883
Aug 05 2016 14:20
not trying to be mean, but some of these questions can be answered with a quick search on google, and a normally the first few results
Igor Malinov
@malinich
Aug 05 2016 14:20
mark
@thenewidealism_twitter
Aug 05 2016 22:27
Hey there, im trying to add ‘profile picture’ system to my site, how do i save the profile picture to each every user and display it on the post they have written?
Oclay
@Oclay2_twitter
Aug 05 2016 22:50
you need a Profile model,with user=models.OneToOneField(User) and ImageField(upload_to='place')