These are chat archives for django/django

4th
Nov 2016
gargtushar
@gargtushar
Nov 04 2016 04:23
hello friends,
I am a begginner in python, I am start following python 3.4 docs from yesterday, it's looking very big, is there is any simple tutorial to leaarn python or there is any book should follow, please guide
Thgank you for the help
Simon Frid
@fridiculous
Nov 04 2016 04:26
@gargtushar I've been coding with python for 4-5 years and still have plenty to learn, so yes, it may take time. There are plenty of resources to get started, but first I might ask, what do you want to build? It may get easier.
krzysztofzygmunt
@krzysztofzygmunt
Nov 04 2016 07:42

@gargtushar take a look at „Learn Python” app for android, from SoloLearn
https://play.google.com/store/apps/details?id=com.sololearn.python

it’s a nice starter, quite comprehensive though

gargtushar
@gargtushar
Nov 04 2016 08:55
tnx both of you for response
@fridiculous I want to learn web development, so that I can create a new pmt in django, but until i know python it's quit impossible, so I want to learn python for creating web applications
please guide for the way i should follow, as i am following the main docs of python 3.4
MinJae Kwon
@mingrammer
Nov 04 2016 08:57
Follow django official tutorial
Are you first at web development?
gargtushar
@gargtushar
Nov 04 2016 08:57
But I don't know anything about python,
I don't know the abc of python then how can directly start django official tutorial
karry91
@karry91
Nov 04 2016 08:58
@gargtushar send your email i can send you a simple pdf for begginners
gargtushar
@gargtushar
Nov 04 2016 08:59
yup, I am a ROR developer, but I want to go for django on python
thank you for sharing
MinJae Kwon
@mingrammer
Nov 04 2016 09:00
gargtushar
@gargtushar
Nov 04 2016 09:01
Thank you all for help
vaibhav jain
@vaibhav-jain
Nov 04 2016 09:01
There is no perfect way or perfect resource from where you can start learning. You just have to start getting your hands dirty. Sadly there is no easy way.
All the best
MinJae Kwon
@mingrammer
Nov 04 2016 09:02
Learning by doing is best
gargtushar
@gargtushar
Nov 04 2016 09:02
ok, I will do my best
tnx again
karry91
@karry91
Nov 04 2016 09:03
@gargtushar check you mail inbox

Display post list template

In the previous chapter we gave our template a list of posts in the posts variable. Now we will display it in HTML.

To print a variable in Django templates, we use double curly brackets with the variable's name inside, like this:

blog/templates/blog/post_list.html
{{ posts }}
Try this in your blog/templates/blog/post_list.html template. Replace everything from the second <div> to the third </div> with {{ posts }}. Save the file, and refresh the page to see the results:

i need some to explain to me where i actually place{{posts}}
gargtushar
@gargtushar
Nov 04 2016 09:05
yup, i will first follow https://python.swaroopch.com/index.html and then enroll the course mention by vaibhav
karry91
@karry91
Nov 04 2016 09:06
sending my code now
gargtushar
@gargtushar
Nov 04 2016 09:06
@karry91 , ok I will try to look that
But I have only installed python3.4 for on my system, django is not setup on my system
karry91
@karry91
Nov 04 2016 09:08
@gargtushar hey that is que to other people . i hope i solved your problem.
gargtushar
@gargtushar
Nov 04 2016 09:08
thanx @karry91
ok
I got the ebook shared by you
tnx,
karry91
@karry91
Nov 04 2016 09:09
welcome
gargtushar
@gargtushar
Nov 04 2016 09:10
you guys are truly awesome, tnx all for the help..
karry91
@karry91
Nov 04 2016 10:26
<html>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<title>Karry's blog</title>
</head>
<body>
<div>

<h1><a href="">Karry Blog</a></h1>
</div>

<p>published: 13.10.2016, 19:30</p>
<h2><a href="">My first post</a></h2>
<p>It's a blessing for those who are social beings. But it also means a lot of capable people don't reach their full potential just because they aren't good at small talk with colleagues</p>
</div>

<div>
<p>published: 14.10.2016, 19:30,</p>
<h2><a href="">My second post</a></h2>
<p>The little things mean a lot,wether you experience excellent service in a restaurant or a retail worker going the extra mile. Here's to decent ordinary folk everywhere doing an excellent job.</p>
</div>
</body>
</html>

Display post list template

In the previous chapter we gave our template a list of posts in the posts variable. Now we will display it in HTML.

To print a variable in Django templates, we use double curly brackets with the variable's name inside, like this:

blog/templates/blog/post_list.html
{{ posts }}
Try this in your blog/templates/blog/post_list.html template. Replace everything from the second <div> to the third </div> with {{ posts }}. Save the file, and refresh the page to see the results:

which <div > im i supposed to replace with {{posts}}??????
karry91
@karry91
Nov 04 2016 10:34
some one please help
Ramon Moraes
@vyscond
Nov 04 2016 11:15
Good morning mates!
Quick question here: Does the db_constraint option over the Foreign Key field be able to remove a existent constraint rule after applying the migration?
I'm asking because i've introduce the db_constraint=Falseto a FK field which was originally created with the constraint and after applying the migrations i was expecting the constraint to be gone, but Django still complains about it. I didn't find at the docs any explicit note saying that this removal should or shouldn't be handle manually be the user.
Miracle Ayodele
@iammiracle
Nov 04 2016 11:22
sup guys, i need help on custom login
karry91
@karry91
Nov 04 2016 11:23
@plc still its no responding the way its supposed to
im just wondering which <div> im i supposed to place my {{posts}}
Miracle Ayodele
@iammiracle
Nov 04 2016 11:42
var code = "<form class="navbar-form navbar-right" action="" role="form">
                  {% csrf_token %}
                <div class="form-group">
                  <input type="text" placeholder="Email" name="username" class="form-control">
                </div>
                <div class="form-group">
                  <input type="password" placeholder="Password" name="password" class="form-control">
                </div>
                <button type="submit" class="btn btn-success">Sign in</button>

              </form>";
var code = "def user_login(request):
username = request.POST['email']
password = request.POST['password']
user = authenticate(email=username, password=password)
if user is not None:
    if user.is_active:
        login(request, user)
        return HttpResponseRedirect('/home/')
    else:
        return HttpResponseRedirect('/index/')
else:
    return HttpResponseRedirect('/home/')";
Miracle Ayodele
@iammiracle
Nov 04 2016 11:53
any input please?
Filip Figiel
@megapctr
Nov 04 2016 12:19
@koderNeptune it would help if you stated your problem
:eyes:
I see you're using username/email incosnsistently

you use

 <input type="text" placeholder="Email" name="username" class="form-control">

but then

username = request.POST['email']
Miracle Ayodele
@iammiracle
Nov 04 2016 12:20
it is not redirecting to show successful login
Filip Figiel
@megapctr
Nov 04 2016 12:21
btw, for e-mail inputs you can use type="email" instead of type="text"
aha
Filip Figiel
@megapctr
Nov 04 2016 12:21
you need to set the method attribute on form
Miracle Ayodele
@iammiracle
Nov 04 2016 12:21
did nnot see dt
@megapctr method attribute
Filip Figiel
@megapctr
Nov 04 2016 12:22
<form method="post" ...
the default method is get and that's why the data lands in the url
Miracle Ayodele
@iammiracle
Nov 04 2016 12:22
ok
got that
i now have the method has post
nd my email field has email type
Filip Figiel
@megapctr
Nov 04 2016 12:25
but you also need to change the name attribute on that input
the name attribute on input will land in request.POST keys
Miracle Ayodele
@iammiracle
Nov 04 2016 12:26
yea changed to email
Filip Figiel
@megapctr
Nov 04 2016 12:26
:+1:
Miracle Ayodele
@iammiracle
Nov 04 2016 12:30
Not found /post
Miracle Ayodele
@iammiracle
Nov 04 2016 12:36
@megapctr its not redirecting me to the page i want it to redirect me to
its jst reloading dt same page
placed a print to debug
its not showing my prints
guess d function is not yet okay
Miracle Ayodele
@iammiracle
Nov 04 2016 12:56
@megapctr do u know what may be wrong?
pkariz
@pkariz
Nov 04 2016 12:57
i have a rest api which returns json of an object in DB. This object's model has a Charfield with choices=[...]. How can i pass choices along in the json?
karry91
@karry91
Nov 04 2016 13:36
why is that in my site only the title colour "karry blog " has changed but 'my first post ' and 'second post' the colours have not changed at all
someone help out
karry91
@karry91
Nov 04 2016 13:49
anyone who has done django girls tutorial please send me a screenshot of post_html where the actual code is please to erickkariithi91@gmail.com
karry91
@karry91
Nov 04 2016 17:10
File "/home/eric/first_project/mysite/blog/urls.py", line 5, in <module>
url(r'^$', views.post_list, name='post_list'),
AttributeError: 'module' object has no attribute 'post_list'
(projectx) eric@layla:~/first_project/mysite$
what could be wrong with my post list
Filip Figiel
@megapctr
Nov 04 2016 18:10
@karry91 I guess your views don't have a post_list function
karry91
@karry91
Nov 04 2016 18:14

from django.shortcuts import render, get_object_or_404
from django.utils import timezone
from .models import Post

Create your views here.

def post_detail(request, pk):
post = get_object_or_404(Post, pk=pk)
return render(request, 'blog/post_list.html', {'post':post})

my views look like that
Filip Figiel
@megapctr
Nov 04 2016 18:15
@karry91 please wrap your code in the code block
(click the M icon in the bottom right corner for formatting tips)
i see your views have post_detail, but there's no post_list
karry91
@karry91
Nov 04 2016 18:21

from django.shortcuts import render, get_object_or_404
from django.utils import timezone
from .models import Post

@filip so where do i place my post_list

or should i change post_detail that 'detail' to list
Filip Figiel
@megapctr
Nov 04 2016 19:00
you should probably rename this function
it's not that hard - if it displays a list, the name should suggest so
if it displays a single item, the name should suggest so too
karry91
@karry91
Nov 04 2016 20:44
@filip thanks
karry91
@karry91
Nov 04 2016 21:09
@megapctr still im havinAttributeError: 'module' object has no attribute 'post_list'g this :