George
hi what software/library do you recommend for automatic pdf generation (in Django obviously)?
Maz
George
Ok
George
Maz
Lol...the whole package site has nothing on pdfs??
George
NO THING
George
but i found some old packages that i don't need
Maz
Well, that's a first 😅
Although I meant the actual site....not the github repo.
George
R
Not used it, so canβt compare with options I mentioned :)
George
ok, i'll try whatever this afternoon
Maz
MMMMM i also thought of xhtml2pdf.pisa
Recommend that you use something that guys use a lot in their projects...using some obscure package means it will be harder finding help if your app breaks
Maz
@Inchidi can advise
Anders (izzno / gooood) π³π΄
Do you guys build in the main project name or do you make apps for everything and mostly leave the projecname/samename dir alone ?
cj
Mirco
Anders (izzno / gooood) π³π΄
I did, but the thing is the front page, it pulls information from many apps, so I am wondering if I should create a "frontpage" app or Site or what ever to put the "about" "faq" and so on or just throw it in the "main" dir
Mirco
Mmm I don't think that's an app
It's just a template
Anders (izzno / gooood) π³π΄
That needs a view ;)
Anders (izzno / gooood) π³π΄
dilemmas... Ill use the "main" and move it if it becomes more than views ...
Anders (izzno / gooood) π³π΄
Mirco
Ah ok I didn't understand you need data , sorry 😅
Anders (izzno / gooood) π³π΄
haha, thats fine ;) Everything is dynamic hehe.
Anders (izzno / gooood) π³π΄
But as long as I am just gathering data i dont think its messy to ue the "main app".
Mirco
I'd create a specific app if I plan to reuse it etc. etc.
Anders (izzno / gooood) π³π΄
hm, maybe...
Sebastian
Hi guys :) I've got a testing problem. I test with Client() if I want to control my context dictionary, my view creates. (response.context) Here I can not put a User in the request. So no function in the view function can get the user I need to get. (?) // And I test with RequestFactory() if I want to put a User in my "request" which I can put in my view function. Unfortunately with RequestFactory() I can not controle any context dictionary. Does anybody have a good practice how I can put a user in the request as well as control the generated context of my view-function?
inchidi
Sebastian
## View:
def viewName(request, x_ID):
pass
user_ID = request.user.id
context_DIC = {'contextKey': 'contextValue', 'user_ID':user_ID}
return render(request, 'xxx.html', context_DIC)
## Testcase:
@pytest.mark.django_db(transaction=True)
def test_x():
user = User.objects.get_by_natural_key(username='Testuser2@xxx.com')
url = reverse('appName:viewName', kwargs={'x_ID': 1})
request = RequestFactory().post(
path = url,
data=context_DICT,
)
request.user = user
response = viewName(request, x_ID=1)
assert response.context_data['contextKey'] == 'contextValue'
Sebastian
This is my code. And this is the error:
Mirco
Use pastebin pls or dpaste
Sebastian
assert response.context_DIC['xxx_STR'] == 'xxx'
AttributeError: 'HttpResponse' object has no attribute 'context'
Mirco
It's easier to read
Sebastian
Oh ok. I try to do that^^ One moment.
Sebastian
https://pastebin.com/GuCdymmy
inchidi
Sebastian
I tryed to alienate the code a little bit. I'll do it better. I'll send a new pastebin snipped which works.
Sebastian
https://pastebin.com/25Kp8Jfh
Sebastian
I have run the snipped and it raise now exactly the error which is also in the snipped.
Anonymous
i give redirect to home if login success but it redirects to login page can't figure out here is the code
Anonymous
can't login with correct id,pwd
Mr. Rude
Try putting print statements
Mr. Rude
And debug
Mr. Rude
Try to print user
Mr. Rude
Will let you know if it is null
Anonymous
i tried but login is correct or incorrect it won't do any process just refresh the login page
Mr. Rude
Is the user null?
Mr. Rude
What happens when you print user
Anonymous
if user == 'isnull':
print(user)
else:
return redirect('home')
Anonymous
redirect home
George
LOL
https://weasyprint.readthedocs.io/en/latest/install.html#windows
George
I am going to use weasyprint for pdf generation and im reading the docs
"Of course you can decide to install ancient WeasyPrint versions with an erstwhile Python, combine it with outdated GTK+ libraries on any Windows version you like, but if you decide to do that youβre on your own, donβt even try to report an issue, kittens will die because of you."
Milan
Try pip install django to install latest version
β
Milan
Then your python version is 2.7
Milan
Please try to install django with python3
β
β
i can't install the latest version of Python, neither Python3 nor Python2,
please help
Anonymous
Check the active environment
Milan
pip3 install django
Milan
MyNotes/Python.md at master · milankathiriya/MyNotes · GitHub
https://github.com/milankathiriya/MyNotes/blob/master/Python.md
Milan
β
Milan
@m3rrym4n_h4ck3r
Milan
MyNotes/Python.md at master · milankathiriya/MyNotes · GitHub
https://github.com/milankathiriya/MyNotes/blob/master/Python.md
β
Anonymous
You better to install all the setup config inside the environment and save to the file requirements.txt file by using the pip freeze > requirements.txt
Anonymous
Command
George
hi, i am creating a pdf from html but it wont download when i click the button
Milan
George
George
no
Milan
wat
w3schools.com/tags/att_a_download.asp
George
i downloaded a file without that atribute
George
i execute an ajax call
George
you didn't even let me explain xD