Marko
hi do sobody know how to avoid "\u0406\u043d\u0448\u0435 saving in django models ? {"categories": [{"category": "\u0406\u043d\u0448\u0435", "subcategory": "\u0406\u043d\u0448\u0435"}], "proposals": [{"id": 1, "title": "ffffffffffffffffffffffffffffffffffff", "description": "fffffffffffffff"}]}
Marko
you can use validators. accept only letters or letters+digits. usage is like name = models.Charfield(validators=[MyCostumValidor,])
it returns normal data in queryset but when i try to transform it in json it gives that encoding
Marko
it returns normal data in queryset but when i try to transform it in json it gives that encoding
class ProposalsCategories(models.Model): category = models.CharField(max_length=128, null=True, blank=True, unique=True) subcategory = models.CharField(max_length=128, null=True, blank=True, unique=True) def json(self): return self #json.dumps({ "category":self.category,"subcategory": self.subcategory}, sort_keys=True, indent=2, ensure_ascii=False) # return { "category":self.category,"subcategory": self.subcategory} like that
Muflone
collect static files
Anonymous
collect static files
Anonymous
i changed file actually in css but it does't see
Anonymous
i have found the reason
Muflone
https://www.packtpub.com/free-learning Today free ebook from packtpub is Django 2 by Example
ps
I didn't read it except python version, never use the latest version of Python as it is not compatible with many libraries of djnago instead use 3.6v
Sweetie
I have a model called Readlist with a ManyToManyField to model called Book I want to let user create readlist with multiple books in it. Current situation: - ReadlistForm form shows a list of all books available in Book model and user is able to select multiple books by pressing Ctrl button. But I am looking for some better UI so user does not have to select books by pressing Ctrl button. And additionally he can filter list say by author. So user Select a Author, then select Book from book list, click on it to add. Now he can add more books by clicking on them or change author and add more books from different authors. Finally he can save the form and a Readlist item is created with link to all selected books
Mr
With checkbox the form will become huge as there can be 100's of book.
then display the books for which user searches and also the books that user already checked
Lord Voldemort
Guys any one have simple explanation with coding for creating custom multiple user types in django ?
Mr
as of i heard there are no multiple user types in django ......you have to restrict the user with permissions
Kanchan
Hi. I am facing this error when i deploy project on heroku:: Procfile declares types -> (none)
Kanchan
Can anyone help
Kanchan
Me in that
Anonymous
Guys i have created two models 1.UserProfile Which has user having onetoonefield(User) 2.Reading Which has onetoonefield(UserProfile) When i logged in i need to get Reading model data list which is should authenticated user list how can i get the particular user list
Anonymous
Hey, could you guys tell me how to handle the FileField only for video or pdf files how do i restric the admin to upload only these files in the django-admib
Gil
Hey, could you guys tell me how to handle the FileField only for video or pdf files how do i restric the admin to upload only these files in the django-admib
You can do it via frontend ( with JS, for the user, but not 100% safe) You can do it overwritting save method You can do it modifying modelform. I have never done it, if you can do via modelform I thinks its more cleaner than overwriting save method. https://stackoverflow.com/questions/10055029/django-forms-filefield-validation https://stackoverflow.com/questions/4269605/django-override-save-for-model
utkarsh
Plz help me guys use of this function with examples Product.object.values() Product.object.filter() Where product is my class in models.py
Бауыржан
hi guys, i nedd help. How to implement fast data search from the database, where the table contains more than 20 million records. The task is to organize a filter with graphs on the website page, and when choosing filter parameters, a search should occur (preferably so that it works smoothly) from a database with more than 20 million records. Now the data is in csv format.
cj
Yes
he is dead now ☹️
Ghorz
Hi guys I have a django web app, that i need to host what is the best option apart from Google cloud?
If you app do not require installation any apt-get package, the use namecheap.com, else vps
Ghorz
i think Xampp is for apache based servers and you cant use that for django
You can. Will need few modifications to work. But it's not necessarily. It's better to use Nginx and Supervisor
Ghorz
Please always use pastebin. Before posting : explain briefly what you did before the error occurred.
Ghorz
Please always use pastebin. Before posting : explain briefly what you did before the error occurred.
Besure you apt install python3.8 python3.8-dev python3.8-doc python3.8-venv
Ghorz
This is an open source community
Bati Chokha
Anyone here for google kicksart?
Vorke
Pythonanywhere.com is yhe sinplest way to do it
We might have to implement redis or maybe rabbitmq, so pythonanywhere will not be viable
Shreehari
I have connected using mongodb in django and changes are not reflecting(collections) in mongodb clusters. But migration in successful. Can someone please help me ? Using Djongo as engine
joy
Does anybody know how to make myapp.herokuapp.com to enable ssl
joy
Its showing not secure
Sourav
Guys...please input your suggestions on the below situation: I have 1 table named Person with onetooneField to User(built in model)... Now, a Person can add many new persons. But those new persons are not in User model. So any idea what could be done?
K
Guys.. need one small help.. I'm trying to make one basic CRUD app using rest_framework's viewsets. I want to save the username from request coming when user uses the API. nd then I'll apply custom permission class to restrict the data to related user only. PROBLEM : under views.py in the class view (ModelViewSet) it is not identifying "request"
K
How can I get the name of user from request and save it to the Database, using viewset?
K
You can use request.user.username
I tried, but it is showing "request" unidentified, when I am trying to use it under the class in views.py
....
Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
K
Share the code 😁
https://pastebin.com/LdUe1BH0 Please let me know where I can add the code to save the username to a field. Thanks in advance.
Mirco
https://pastebin.com/LdUe1BH0 Please let me know where I can add the code to save the username to a field. Thanks in advance.
You can use the create method into the serializer and you can access the request via self.context["request"] and get the user's username to save into your Good's username without touching the view
Lucibhish
Error while deploying the project to Heroku: raise ImproperlyConfigured("You're using the staticfiles app " remote: django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path. _______________________________________________________________________________________________________ settings.py # Heroku settings if os.getcwd() == '/app': import dj_database_url DATABASES = { 'default': dj_database_url.config(default='postgres://localhost') } # Honor the 'X-Forwarded-Proto' header for request.is_secure(). SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # Allow all host headers. ALLOWED_HOSTS = ['*'] # Static asset configuration BASE_DIR = os.path.dirname(os.path.abspath(file)) #STATIC_ROOT = 'staticfiles' STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )
George
any suggestion?
you should read the guide of static files
George
Let me 🦆 DuckDuckGo that for you: 🔎 static files django guide
George
any suggestion?
Let me 🦆 DuckDuckGo that for you: 🔎 deploy static files django
Lucibhish
Yeah I checked the Django documentation only: Then Modified the STATIC_ROOT but still facing the error
π
after running 'python manage.py makemigrations' I got this long error; but in short" django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?" I then tried to 'pip install mysqlclient' then this error came Collecting mysqlclient Using cached mysqlclient-1.4.6.tar.gz (85 kB) Building wheels for collected packages: mysqlclient Building wheel for mysqlclient (setup.py) ... error ERROR: Command errored out with exit status 1: command: error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
π
followed the link
Sourav
George
How dis will make a difference
well if a user can have multiple persons, you cant have a one to one
maroong
I'm using git push for cd on pythonanywhere and my changes aren't reflecting on the website. I am also not getting errors. I checked the bare repo and I think my changes should appear 9tm⁴
Pratik
Simple question -------------------------- Can anyone please tell me how can I use existing table in view py...which was before created in models.py?
isa
STATIC_URL = '/static/' #static ve staticfiles klasörlerinin yönetimi için STATIC_ROOT = os.path.join(BASE_DIR,'static') STATICFILES_DIRS = [ os.path.join(BASE_DIR,'staticfiles'), ] #Medya klasörlerinin yönetimi için MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
isa
Above is part of my settings.py file
isa
It has deployed abd nginx and gunicorn is okay
isa
Is there a problem with static adjustments ?
Mirco
What's the issue ?