These are chat archives for django/django

15th
Oct 2017
Anish Shrestha
@annshress
Oct 15 2017 08:06
@kpagcha I believe they are both same.
"auth" is the app and "User" is the Model. If you look at the Installed_Apps, you probably have included 'django.contrib.auth',
User Model is from the same auth app
@rjusher I used at command for now(available in linux). Will have to switch to django-celery later when I need it extensively.
White Rabbit
@Wahtdb_twitter
Oct 15 2017 09:34
Why changes in jupyter are not visible in the same ipynb file opened for instance in PyCharm?
Costantin
@Cosbgn
Oct 15 2017 19:20
Hello everyonme
is it possible to make request optional?

at the moment I have something like:

def update_via_url(request):
       email = request.user.email

and

def update_via_api(email):
        ...
I'm wondering if I could merge the two
like:
def update(request=None, email=None):
        if email == None:
                do something
Would this be possible? Is it save to do it?
Luke-VideoLibre
@LukeVideo
Oct 15 2017 19:42
yes @Cosbgn thats the point of the view. handle your logic.
Costantin
@Cosbgn
Oct 15 2017 19:56
Yes, I just wasn't sure if I can make request optional, but seems to work
thanks a lot!
Costantin
@Cosbgn
Oct 15 2017 20:14
Hi, can someone help me (again! :D ) with something else?

for example I have this model:

class testModel(models.Model):
    user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
    something = models.TextField()

and this view:

    testModel.objects.create(user=request.user, something='abc')
I would like to pass the user in an easy way, I know the foreign key needs to be a user instance, so I could do:
user= User.objects.get(id=request.user.id)
and then pass:
testModel.objects.create(user=user, something='abc')
but it it possible to do it without the get request?

I tried this:

testModel.objects.create(user=request.user, something='abc')

and this

testModel.objects.create(user=request.user.id, something='abc')

but they don't seem to work

Costantin
@Cosbgn
Oct 15 2017 20:20
ahh!! Nevermind it actually does work! Soo sorry to bother! :D