Auth needed in xblock

Hi,
My block requires user authentication and access to the id of the student, how to check that with xbox and database, Knowing my ex block is coded with django framework.
I need help please

You can get the details of the current user via the user service from the XBlock runtime.

See here for an example usage of user service.

Hi,
Thank for reply but my xblock is based on django framework I have no class for xblock how to do that , because my app is very complex I could not to use an xblock it will has multiple xblock class and I am new on xblocks development

@seni If you’re new to XBlock development I think you should start here: Open edX XBlock Tutorial — Open edX XBlock Tutorial documentation

While you can use Django in XBlocks, I’d recommend against it unless absolutely needed. XBlocks are plugins for Open edX so they need to work in a way that Open edX ecpects.

ok thank you, but realy I should develop an xblock in a short time, so I think that is that very hard, I had developped the app with django framework but it seems to me very hard to convert it to an xblock, because it will contains multiple child xblock.
So what changes can I make , my django app has the views.py and urls.py but in xblock I can’t add a views.py file and urls.py.
I tried to create the xblock but the app is complex, I can’t manage the all xblocks

Actually, you can. It’s just that doing so is an advanced XBlock topic, and you should really understand the basics first, like @xitij2000 suggested above.

Ok, can you just share ith me a link that use views.py and urls.py in xblock, I can’t find any resources

I’m not aware of any. The reason this is not common is simple: while XBlocks are technically Django apps, Open edX does not expect them to render their own views. Instead, the XBlock runtime invokes specific methods to do so on the XBlock’s behalf.