These are chat archives for django/django

28th
May 2017
1rjun
@1rjun
May 28 2017 08:44 UTC
hello friends
:)
1rjun
@1rjun
May 28 2017 09:35 UTC
from where to learn django ??
give me some suggestion
wbeyda
@wbeyda
May 28 2017 09:36 UTC
@1rjun have you completed the tutorial? https://docs.djangoproject.com/en/1.11/intro/tutorial01/
1rjun
@1rjun
May 28 2017 09:47 UTC
no
i found easy tutorial
i mean i want
easy tutorial
wbeyda
@wbeyda
May 28 2017 09:48 UTC
That's as easy as it get's compadre`
1rjun
@1rjun
May 28 2017 09:49 UTC
:package:
i think djangogirls if good
wbeyda
@wbeyda
May 28 2017 09:53 UTC
I helped them fix their site once. They had broken code.
Shashank Sharma
@shashank-sharma
May 28 2017 09:53 UTC
For starters I believe that django girls is good. But later you will come back to Django docs for more information
1rjun
@1rjun
May 28 2017 09:54 UTC
i learnt flask
now i am switching to django
wbeyda
@wbeyda
May 28 2017 09:55 UTC
Good choice
1rjun
@1rjun
May 28 2017 10:04 UTC
yes
wbeyda
@wbeyda
May 28 2017 10:05 UTC
Flask is too small. Creating RESTful API's in flask is a ton of work compared to Django + RESTframework
1rjun
@1rjun
May 28 2017 12:30 UTC
what is the difference between migrations and makemigrations
i m just not able to understand both of these
wbeyda
@wbeyda
May 28 2017 12:32 UTC
@1rjun so makemigrations is ran when you make a change to your models. It saves a migration file in your apps /migration folder.
1rjun
@1rjun
May 28 2017 12:32 UTC
then what is a migration
n why it save so
wbeyda
@wbeyda
May 28 2017 12:32 UTC
@1rjun migrate takes that file that you just made and runs it against your database. Essentially applying the changes you made
1rjun
@1rjun
May 28 2017 12:33 UTC
okkk it means first we have to create migrations if we change something in our database
then migration file is created
wbeyda
@wbeyda
May 28 2017 12:33 UTC
So when working your models.py file typically you make a change. create migration using makemigrations and then apply them with migrate
1rjun
@1rjun
May 28 2017 12:34 UTC
thanx brother
:D
its very helpful
wbeyda
@wbeyda
May 28 2017 12:34 UTC
NP
we all have to learn somewhere
1rjun
@1rjun
May 28 2017 12:34 UTC
:)
thata what learning
i love when community communicate
and it encourage us to build something
wbeyda
@wbeyda
May 28 2017 12:37 UTC
Sometimes makemigrations will ask you to set a default value if a Field isn't blank or null. Setting that value is up to you. Either by shell or default in the model's Field.
If you are just starting out on an app and get stuck a lot of times it's easier to just delete your sqlite file and start over. I do it all the time rather than fight with migrations. But I rarely have that problem anymore.
1rjun
@1rjun
May 28 2017 12:38 UTC
i dont get your point
wbeyda
@wbeyda
May 28 2017 12:38 UTC
You'll see.
1rjun
@1rjun
May 28 2017 12:39 UTC
hey how to post these the code in gitter
if i stuck somewhere
wbeyda
@wbeyda
May 28 2017 12:40 UTC
use the tilde key and start your code with 3 ticks and end with 3 ticks
1rjun
@1rjun
May 28 2017 12:40 UTC
okk bro
wbeyda
@wbeyda
May 28 2017 12:41 UTC
def some_method(a,b):
    return a+b
1rjun
@1rjun
May 28 2017 12:42 UTC
but how to send
then
its just stuck there
from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello world")

def detail(request, question_id):
o great
:D
wbeyda
@wbeyda
May 28 2017 12:44 UTC
there ya go
1rjun
@1rjun
May 28 2017 12:44 UTC
yes
now i could send my problem easily whenever i stuck there
i have some other question to let me show you
wbeyda
@wbeyda
May 28 2017 12:45 UTC
This is a good place but honestly the IRC on #freenode is better.
1rjun
@1rjun
May 28 2017 12:45 UTC
from django.db import models
import datetime
from django.utils import timezone

# Create your models here.
class Question(models.Model):
    question_text=models.CharField(max_length=30)
    pub_date=models.DateTimeField('data published')

    def __str__(self):
        return self.question_text

    def was_published(self):
        return self.pub_date >=timezone.now() - datetime.timedelta(days=1)


class Choice(models.Model):
    question=models.ForeignKey(Question,on_delete=models.CASCADE)
    choice_text=models.CharField(max_length=200)
    votes=models.IntegerField(default=0)

    def __str__(self):
        return self.choice_text
now what does the str() constructor does here
wbeyda
@wbeyda
May 28 2017 12:46 UTC
so python is kinda retarded about how it returns things because everything is an object
so you override the str method to make it return something understandable instead of Choice Object
__str__
1rjun
@1rjun
May 28 2017 12:47 UTC
what is its purpose in the models.py
wbeyda
@wbeyda
May 28 2017 12:48 UTC
so when you go to shell or return an instance from your database it will say what the choice_text is rather than "Choice Object"
Keep reading the tutorial it will explain it all.
1rjun
@1rjun
May 28 2017 12:50 UTC
ohkk bro
wbeyda
@wbeyda
May 28 2017 12:51 UTC
@1rjun are you new to python?
1rjun
@1rjun
May 28 2017 12:51 UTC
nap
i know python
i can understand the code
but not expert :D
wbeyda
@wbeyda
May 28 2017 12:53 UTC
After the Django Tutorial I recommend the Django-Restframwork tutorial and then maybe read "Obey The Testing Goat" Then you'll know pretty much everything about modern Django development.
1rjun
@1rjun
May 28 2017 12:54 UTC
someone my friend said that django and flask are dying
and not good for web development
???
he said nodejs, java are better
wbeyda
@wbeyda
May 28 2017 12:55 UTC
You can check out Google trends to verify that.
Node.js is full of problems and everyone hates it. Java is popular but I'd say things like Go and Rust are picking up a lot of popularity
1rjun
@1rjun
May 28 2017 12:58 UTC
then django is still better
wbeyda
@wbeyda
May 28 2017 12:58 UTC
Django has been around for about 10 years now and it just keeps growing. And python is becoming the first language a lot of CS students are being taught now. No longer Java.
1rjun
@1rjun
May 28 2017 12:59 UTC
:)
thank god
wbeyda
@wbeyda
May 28 2017 13:00 UTC
Version 2.0 will be huge for Django. I'd stick around and see what happens. There are a lot of great practices in Django. Frameworks come and frameworks go. Django is almost future proof at this point. There is some work being done to bring it to mobile now.
1rjun
@1rjun
May 28 2017 13:01 UTC
:)
instagram is the example
1rjun
@1rjun
May 28 2017 13:06 UTC
bro i am not able to join dajngo irc
Mostafa Moradian
@mostafa
May 28 2017 19:35 UTC
Hey everyone, does anybody know of any OGM (for Neo4j) supporting admin panel generation for django? neomodel and py2neo does not support it by default (as far as I know) and py2neo is old (somehow obsolete). I think Bulbflow does not support it either.