VAIBHAV
objects.bulk_create
Any tutorial or demo to learn?
šяıяαм〘CID〙
AttributeError: can't set attribute 'is_staff' can someone help me out with this
šяıяαм〘CID〙
Not until you explain your difficulties.
self.UserModel._default_manager.db_manager(database).create_superuser( File "D:\voting\authenticate\models.py", line 52, in create_superuser return self._create_user(aadhar,phone,password,**extra_fields) File "D:\voting\authenticate\models.py", line 32, in _create_user user = self.model( File "C:\Users\MY PC\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\base.py", line 554, in init _setattr(self, prop, value) AttributeError: can't set attribute 'is_staff'
Sukhmanjeet
Ana
Hello, please how can I develop a multiuser login based on role with a lecturer logging in with an email and password whiles a student logs in with index number and password
Пейн✙
or create user with indexes, but with different permissions?
Ana
why you can't use same email and password?
No I want to use index number for students and email for lecturers
Ana
What have you tried? Where are you stuck?
Firstly I created two separate login pages for both users but my supervisor asked me to merge the two logins so that if a user enter details the system will be able to know it's a lecturer or student
Ana
So right now I want to have one login page for both of them
Пейн✙
So right now I want to have one login page for both of them
i suggest check firstly if input is email else - student
Adrian
You can set specific role for each user, and show pages depends on the user's role.
Adrian
In other hand, you can use two admin pages for admin the user's, for that you need to use two proxy models
Денис
Did someone use dockerized django with local postgresql (not in docker)?
Денис
I have problems with connection
Adrian
Did someone use dockerized django with local postgresql (not in docker)?
Yes, you need to put the option network whit the value "host" in your docker file, and use Django as local
Adrian
With that, you use docker as a service
Adrian
I have a db container that expose the port 9051, and in the django container I consume that service using the host 127.0.0.1 and the share port of db container
p
hello i need some help ......so i am actually working on this thing where if the user scans the qr code and gives the amount and scans it should redirect to the payment .....i tried using qr init api of phone pe
p
i used this docs reference.....https://developer.phonepe.com/v2/reference/qr-init
Doragonsureiyā
p
https://linkode.org/#nx2qsxocsIR7SfBnfJi6F4
jaxx
How to download csv file asynchronously in django with celery. When i try to do it i get object of type httpresonse is not json serializable
Sinceritate
I have a model administrator and he has reprimands, and there are api, how better to add reprimands PATCH request, or POST request?
Anshuman
Hi everyone i need your help? Can anyone tell me how to send live streaming frame of client webcam through javascript to backend in diango server
Yury
Hello everyone I have a custom tag @register.simple_tag def category_list() -> dict: return { "categories": Category.objects.all(), } I know that i can return just queryset, but i want do it in dictionary and here is my question. How can i get the values in template from this dictionary? p.s. getting values like from views doesn’t work with custom template tags
Anshuman
Sr if you want dictionary key then you have to use keys example Category.keys() or if you want to values then use .values() instead of keys
Bhaumik
I can't see rules when click on "Read the rules"
Anshuman
Cat=category.objects.filter().values('id','name') for i in cat: for k,l in i.items(): Print(k,l) Or you can do like this also
Mojo
I'm making a Django app where I want to upload files and save them into categorical folders: On the models.py I have these lines: book_series = models.Charfield() book_title = models.FileField(upload_to={f"media/{book_series}" I made a pre_save signal that creates the book_series folder before an instance is saved: @receiver(pre_save, sender=Book) def create_folder(sender, instance, **kwargs): os.mkdir(BASE_DIR+ instance.book_series) The signal creates the required folder, however the files are stored in another folder called <django.db.models.fields.CharField> which is the type of the book_series field. How do I make it save in the required folder (ie the book_series' name instead of its type)?
Cesar
https://docs.djangoproject.com/en/4.1/ref/models/fields/#django.db.models.FileField.upload_to
And an example: https://stackoverflow.com/questions/5135556/dynamic-file-path-in-django
Mojo
Thank you both
Mojo
upload_to can get a callable that accepts the instance that is being saved and the filename. so you can easily manage which folder to upload the file
I implemented my function like this: def create_series_folder(instance, filename): if not os.path.exists(f"{BASE_DIR}/media/books/{instance.series}"): os.mkdir(f"{BASE_DIR}/media/books/{instance.series}") return os.path.join(f"{BASE_DIR}/media/books/{instance.series}", filename)
Mojo
But I am getting this error: django.core.exceptions.SuspiciousFileOperation
Mojo
in ur case you return "books/{instance.series}/{filename}"
I changed the function to this: def create_series_folder(instance, filename): return f"/media/lectures/{instance.series}/{filename}" Still getting the same suspicious error
Mojo
Wait my bad, I added a / before media. It works after removing it
Adrian
How to download csv file asynchronously in django with celery. When i try to do it i get object of type httpresonse is not json serializable
Hi, you need to use Django channels, to connect front and back, and after you create the file with celery, send it to the front using the channel.
jaxx
How to accept user input on celery task?
jaxx
How to accept user input on celery task?
1. Create a celery Task called generate_file which accepts the following parameters: a. filename: name of the file to be generated. b. data count: count of the random data to be inserted in the CSV (if provided 10 as the input then the file should contain 10 rows with some random data) How to get user input in celery task? Am completely new to celery. Struggling a bit now
Adrian
How to accept user input on celery task?
You pass the parameters in the function. In your API, you get the user's info and run the task in celery, then process data and create the file with celery. When it finish, you send the data using channels
Adrian
You need to understand that celery is a different server, and is different that you Django server that the user is consume. For that reason, you can't get a direct response from celery and need to use channels
Adrian
For that, you should connect to the websocets in JS, and use a asynchronous server for production environment
asterix
hi have you worked with eventlets in celery, how is the performance compared to normal concurrency
asterix
How to accept user input on celery task?
we have redis as middleware for celery & django
Ana
Please, is it possible to use render() to render two or more HTML files?
Cesar
nope, 1 view -> 1 template
You CAN have a template (one or more) inside another template and load them dinamically
Azizbek Xushnazarov
that's the inheritance ok, but 1 view 1 template
ofc. Multiple templates within a view does not make sense. I think OP is asking for the inheritance.
Azizbek Xushnazarov
Please, is it possible to use render() to render two or more HTML files?
Look for "include" and "extends" template tags
Ritesh
Hi can anybody help me out for how I use in post method json array
Ritesh
In django in view.py
Abdelrahman
Can you show a pic of your urls file
Doragonsureiyā
Can you show a pic of your urls file
Rule 5️⃣: Never post walls of text or screen photos. Use paste bins like https://linkode.org, https://nekobin.com (or your favorite one)
Maxim
Can you show a pic of your urls file
media is not allowed here
Abdelrahman
Never mind, just tried to help
cj
Can you show a pic of your urls file
why pic of something that is text?