Anonymous
Aleksandr
hello! I am looking for a job. Who have any vacancies?
Aleksandr
please do not ban
Aleksandr
i just wanna work
Django Bot
>> Blogs
- DJANGO 2.0 - Django Login/Logout Tutorial
- Nested resources with Django REST Framework
>> Links
- (5) Django + ReactJS - YouTube
Luis
There are many job offers
Aleksandr
Search in this channel?
Aleksandr
=)
Aleksandr
ok thanks =)
Anonymous
/stat@combot
Combot
combot.org/chat/-1001146340312
Anonymous
Please what's the command to create a python virtual environment and inherit the global site packages from python site packages in a system....
Aleksandr
Samuel, you can insatal conda
Aleksandr
and simply use conda create -n New_ENV
Aleksandr
after it : source activate New_ENV
Jimmies San
Anonymous
Thanks @JimmySan
Anonymous
Sorry am kinda new to python, what's conda?
Aleksandr
conda it is for virtual invironments
Aleksandr
https://conda.io/docs/
Aleksandr
conda is simple
Aleksandr
and agile
Anonymous
Anonymous
I started learning django/python few weeks back... Am kinda getting some concepts in it and web development in general... A friend suggested I should use TDD (test driven development) approach for building apps, he's a JS guy... Luckily django encourages Testing for apps but what I don't seem to understand is that, how does one know what to test when building an app.Is there like any module that can suggest some part of our code that should be tested and others that shouldn't
Anonymous
?
inchidi
yeah, @DjangoRSSbot usually post new jobs from https://www.djangojobs.net/jobs/
inchidi
inchidi
Aleksandr
ok. thanks
Django Bot
>> Links
- Django
Someone
Hi, what is the best way to save a model as draft? In UI there will be 2 buttons submit and save. When clicked on save data in model should be in draft state, when clicked on submit.. it should be in completed state and should not allow user to edit the data
Django Bot
>> Links
- S3SQLite - A Serverless Relational Database
mλdcodez
The view blog.views.post_share didn't return an HttpResponse object. It returned None instead.
I'm following the book called django by example.. I'm not getting why this error happened.
mλdcodez
def post_share(request, post_id):
# Retrieve Post by id
post = get_object_or_404(Post, id = post_id, status='published')
sent = False
if request.method == 'POST':
# Form was submitted
form = EmailPostForm(request.POST)
if form.is_valid():
#form fields passed validation
cd = form.cleaned_data
# ...send email
post_url = request.build_absolute_uri(post.get_absolute_url()) # check for uri instead of url.
subject = '{} ({}) recommends you reading "{}"'.format(cd['email'], post.title)
message = 'Read "{}" at {}\n\n{}\'s comments: {}'.format(post.title, post.url, cd['name'], cd['comments'])
send_mail(subject, message, 'admin@myblog.com', [cd['to']]) # ? admin@myblog.com/
sent = True
else:
form = EmailPostForm()
return render(request, 'blog/post/share.html', {'post': post, 'form': form, 'sent': sent})
mλdcodez
this is the method...
mλdcodez
sorry, do i share via paste bin or something?
mλdcodez
https://pastebin.com/iFhBBJSt
Django Bot
>> Links
- Tutorial: Django REST with React (Django 2.0)
- Tracking User Login Activity in Django Rest Framework: JWT Authentication
Code9
def post_share(request, post_id):
# Retrieve Post by id
post = get_object_or_404(Post, id = post_id, status='published')
sent = False
if request.method == 'POST':
# Form was submitted
form = EmailPostForm(request.POST)
if form.is_valid():
#form fields passed validation
cd = form.cleaned_data
# ...send email
post_url = request.build_absolute_uri(post.get_absolute_url()) # check for uri instead of url.
subject = '{} ({}) recommends you reading "{}"'.format(cd['email'], post.title)
message = 'Read "{}" at {}\n\n{}\'s comments: {}'.format(post.title, post.url, cd['name'], cd['comments'])
send_mail(subject, message, 'admin@myblog.com', [cd['to']]) # ? admin@myblog.com/
sent = True
else:
form = EmailPostForm()
return render(request, 'blog/post/share.html', {'post': post, 'form': form, 'sent': sent})
The return line should indent 1 tab less
mλdcodez
Oh. Thanks 😊😊😊😊
Code9
mλdcodez
after removing one tab
local variable 'form' referenced before assignment
mλdcodez
also says, again line 33
inchidi
mλdcodez
oh, i think, an extra tab at line 31 as well,.. removed. and testing.
mλdcodez
it works. :)
mλdcodez
Thanks :)
mλdcodez
tuple index out of range
Line 27
subject = '{} ({}) recommends you reading "{}"'.format(cd['email'], post.title)
inchidi
Language:
python3
Source:
cd= {'email':'foo@bar.com'}
subject = '{} ({}) recommends you reading "{}"'.format(cd['email'], 'username', 'post.title')
print(subject)
Result:
foo@bar.com (username) recommends you reading "post.title"
inchidi
mλdcodez
oh.. what will be the correct format buddy? :)
inchidi
mλdcodez
oh, okay buddy, thanks. :)
Code9
mλdcodez
yep.
Code9
A few course on Codecademy would help
mλdcodez
i worked with java, cpp, c#, etc, but, new with py
mλdcodez
Django Bot
>> Links
- How To Send And Receive Email With Django And Amazon SES - MicroPyramid
Django Bot
>> Links
- DJANGO 2.0 - Django Login/Logout Tutorial
Anonymous
Cannot query "normaluser": Must be "SuperUser" instance.
Hi, i wrote a register forms views and custom model but when i want to register a user i get this error, i have 3 class for my users because of i have 3 type of user SuperUser Developer NormalUser and i want to resgister as normaluser.
i have no idea what should i tell more about it, if you can help tell me to send you my codes
inchidi
inchidi
Anonymous
inchidi
you should replace with User.objects.filter(username=user.username) or something else depends on what you need
inchidi
Anonymous
inchidi
inchidi
*am still guessing tho
Anonymous
😅 thank you very much i need to try it
inchidi
then do that in template (not showing user_type depends on current user_type) then check again on your Form part
inchidi
or, dont use ModelForm i think