Mirco
but it shld work without defining the block ryt?
nope, the inheritance is focused on that blocks
Mirco
usually you define a "skeleton" into base.html to reuse and include pieces of html using blocks into base
Ihor 🐈
Hi there, I have a question: what kind of UML-relationship ussually have 'Article' and 'Tag'? Is it assoсiation? Or aggregation? Implaying model "Article" has M2M field to Tag.
Anders (izzno / gooood) 🇳🇴
Has anyone seen this chrome input "option" bug and know how to tackle it? : https://youtu.be/vZ13DXaYfRQ
Anders (izzno / gooood) 🇳🇴
It was my gtk theme...
Anders (izzno / gooood) 🇳🇴
I've set chrome to use it...
inchidi
Hi there, I have a question: what kind of UML-relationship ussually have 'Article' and 'Tag'? Is it assoсiation? Or aggregation? Implaying model "Article" has M2M field to Tag.
if you use many to many relationship then in uml you'll add junction table between those related model. the junction table will looks like this for this case table name: article_tag fields: -tag fk(Tag) -article fk(Article)
senpos
Hi, Can you share examples of your open-source DRF projects? I am interested in a way you're using routers. I have several apps in my projects. Each app has its own router (as I've seen in many tutorials and guides - it looks similar to this) But how do I gather all the routers from each app? How do use them in my main urls.py? Do I just extend my urlpatterns list with values from each app? But in this case I won't have a root router, which will help to browse my API endpoints easily. :( At the moment here is what I've got. But it feels a bit off.
senpos
I guess, I'll just use a single router, import viewsets I need from each app and register them in one place Yes, it breaks the idea of apps, but 🤷‍♀️
Aadhi
Hello Guys, Does anyone knows why I am getting following error List object has no attribute 'items'
Jatin
hello guys i need to check first character of string inside if statement in template. i write {%if {{product.other_link|make_list|first}}=='T'%} but i got error "could not parse some characters: |{{product.other_link|make_link|first}}=='T'
Jatin
yeah I thought why pass additional dictionary field if i can do that in template. so, it is possible to check that if statement?
Jatin
it's take three keyboard argument in dictionary because i have to check three if statement.so, it's best if it's done on template.
Mirco
yeah I thought why pass additional dictionary field if i can do that in template. so, it is possible to check that if statement?
Because templates should just be used to show data , so try to make as much as u can calculation into your py side
Jatin
Because templates should just be used to show data , so try to make as much as u can calculation into your py side
ok but it's matter how many keyword argument pass in dictionary. does it effect on loading time of page?
Mirco
ok, thanks for your help.
And above all it depends on how many queries you make in that view
Jatin
i didn't know that. i thought bigger the view ,bigger loading time😅😅
Mirco
i didn't know that. i thought bigger the view ,bigger loading time😅😅
So I suggest ya to study better if u wanna make good code and good apps
Jatin
So I suggest ya to study better if u wanna make good code and good apps
I have started learning django from last month from udemy course.so, i didn't read any books for django. if i have any problem then try to find it on Google and try to solve it. if i don't get any solution then write it here.😊😊
Xyz
I always find myself googling the difference between auto_now and auto_now_add, lol
Xyz
Has anyone tried integrating Django with scrapy 🤔
Anonymous
any body who has computer science question bank bible this book
cj
any body who has computer science question bank bible this book
don't cross spam your question in many groups
mark
or is it
Anonymous
Hi friends! need help. i have large QuerySet with Model field date = models.DateTimeField(blank=True, null=True) i am using DRF and serializers.SerializerMethodField(), i want to make short Statistic with custom field, where numbers is month representatinon "statistic" : { "2016" : [ {1 : 200}, {2 : 400}, ........ {12 : 700}], "2017" : [ {1 : 200}, {2 : 400}, ........ {12 : 700}], } can some one help this is my sollution: def last_day_of_month(self, any_day): next_month = any_day.replace(day=28) + datetime.timedelta(days=4) # this will never fail return next_month - datetime.timedelta(days=next_month.day) def get_messages_years(self, obj): qs = obj.envelopemodel_set years = qs.dates("date", "year").distinct() data = dict() for y in years: month_ = dict() for month in range(1, 13): count = qs.filter( date__range=(datetime.datetime(y.year, month, 1, tzinfo=timezone.utc), self.last_day_of_month( datetime.datetime(y.year, month, 1, tzinfo=timezone.utc)))).count() month_[month] = count data[y.year] = month_ return data
Anonymous
https://www.django-rest-framework.org/api-guide/fields/#serializermethodfield
thx, but i know drf docs, need one query sollution i think with annotations etc...
Livan
hi all, how used grphql with django?
cj
hi all, how used grphql with django?
Livan. Here you have a useful link: https://duckduckgo.com/?q=hi+all%2C+how+used+grphql++with+django%3F
#define CLEAR_BUFFER while ( getchar ( ) != ’ \n ’ )
Hi here
#define CLEAR_BUFFER while ( getchar ( ) != ’ \n ’ )
I want to pass a form and the result of a request to the template of this kind when displaying, I get a form with the values ​​from the result of the query. Exactly like when you modify a tuple via the admin page of django. How to do it ? Views.py def modification_ue(request, code): ue_form = UEForms() ue = UE.objects.get(code_ue=code) return render(request, 'felyn/modifier.html', {'ue_form': ue_form, 'ue': ue})
#define CLEAR_BUFFER while ( getchar ( ) != ’ \n ’ )
def modification_ue(request, code): ue_form = UEForms() ue = UE.objects.get(code_ue=code) return render(request, 'felyn/modifier.html', {'ue_form': ue_form, 'ue': ue})
Mirco
Why not ?
Anders (izzno / gooood) 🇳🇴
Why not ?
Theres no advanteges to choose django if ONLY using mongo.
Anders (izzno / gooood) 🇳🇴
He spoke about GraphQL not mongo
I just made a huge mistake...
Anders (izzno / gooood) 🇳🇴
I assumed.
Anders (izzno / gooood) 🇳🇴
made an "ass" out of "u" and "me"
Xyz
Has anyone tried integrating Django with scrapy 🤔
So I was able to get this working.... Used Django to start the crawler via management commands, then made post requests from crawler to update db
Xyz
Webfaction dealt with me though, need to consider using another platform for hosting Django apps
Anonymous
Github: Python3 https://github.com/8140171224
REDDY
Hi... All my friends I need Django book's friends anyone send me... Plz
Anonymous
https://www.pdfdrive.com/mastering-django-core-e27131081.html
Bharat
I start learning django which platform is good udemy, youtube or other
Anonymous
Get a book
Anonymous
The best kind of resource
Bedilbek
Hi... All my friends I need Django book's friends anyone send me... Plz
start from the tutorial given in the django documentation, and make sure to start bigger side project to improve skills gradually
Anonymous
hi all, i want django drf force http to https. i use nginx uwsg. inside nginx i add section: server { listen [::]:80 default_server ipv6only=off; #Redirect all nonssl requests to ssl. server_name _; return 301 https://$host$request_uri; } server { server_name domain.tires www.domain.tires *.domain.tires; listen 443 ssl; charset utf-8; client_max_body_size 75M; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; access_log on; # SSL SECTION ssl_certificate /etc/letsencrypt/live/domain.tires/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/domain.tires/privkey.pem; ssl_protocols TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; # Location SECTION location ^~ /static-root/ { autoindex on; alias /app/static-root/; } location ^~ /media-root/ { autoindex on; alias /app/media-root/; } location ^~ /protected/ { internal; alias /app/storage-root/; } location / { proxy_set_header Host $host; proxy_set_header Accept-Encoding ""; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass_header Server; proxy_redirect off; include uwsgi_params; # uwsgi redirection uwsgi_pass django:8000; uwsgi_read_timeout 60s; uwsgi_send_timeout 60s; uwsgi_connect_timeout 60s; } } also create uwsgi.ini [uwsgi] ; load router_redirect plugin (compiled in by default in monolithic profiles) plugins = router_redirect route-if-not = equal:${HTTPS};on redirect-permanent:https://${HTTP_HOST}${REQUEST_URI} chdir = /app/src/ module = core.wsgi master = true processes = 5 socket = :8000 vacuum = true thunder-lock = true pidfile = /var/run/uwsgi/%n.pid # uid and gid #uid = uwsgi #gid = uwsgi buffer-size = 65535 chmod-socket = 664 also i add in settings.py SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SECURE_SSL_REDIRECT = True SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True but still i can request API with http!! please help how to force it.
Doragonsureiyā
hi all, i want django drf force http to https. i use nginx uwsg. inside nginx i add section: server { listen [::]:80 default_server ipv6only=off; #Redirect all nonssl requests to ssl. server_name _; return 301 https://$host$request_uri; } server { server_name domain.tires www.domain.tires *.domain.tires; listen 443 ssl; charset utf-8; client_max_body_size 75M; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; access_log on; # SSL SECTION ssl_certificate /etc/letsencrypt/live/domain.tires/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/domain.tires/privkey.pem; ssl_protocols TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; # Location SECTION location ^~ /static-root/ { autoindex on; alias /app/static-root/; } location ^~ /media-root/ { autoindex on; alias /app/media-root/; } location ^~ /protected/ { internal; alias /app/storage-root/; } location / { proxy_set_header Host $host; proxy_set_header Accept-Encoding ""; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass_header Server; proxy_redirect off; include uwsgi_params; # uwsgi redirection uwsgi_pass django:8000; uwsgi_read_timeout 60s; uwsgi_send_timeout 60s; uwsgi_connect_timeout 60s; } } also create uwsgi.ini [uwsgi] ; load router_redirect plugin (compiled in by default in monolithic profiles) plugins = router_redirect route-if-not = equal:${HTTPS};on redirect-permanent:https://${HTTP_HOST}${REQUEST_URI} chdir = /app/src/ module = core.wsgi master = true processes = 5 socket = :8000 vacuum = true thunder-lock = true pidfile = /var/run/uwsgi/%n.pid # uid and gid #uid = uwsgi #gid = uwsgi buffer-size = 65535 chmod-socket = 664 also i add in settings.py SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SECURE_SSL_REDIRECT = True SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True but still i can request API with http!! please help how to force it.
It looks like you posted a long piece of code, consider editing it out and putting it on hastebin.com and pasting the link to it instead.
Le Createur
Thanks
S.
Hi all. my inlinefactory_formset save only 1 data when extras=1 if extras=; 3 save 3 data additinional info: https://stackoverflow.com/questions/56099415/inlineformset-factory-save-data-much-as-extras can you help me please :/
Anonymous
Hi guys! I having an issue when run project in Pycharm software. Error is shown as below,👇 ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? Could anyone please help me how to solve this issue and run my project?
Mirco
So you can let pycharm knows where to look for your venv's site-packages
Anonymous
Is it mean to use command venv\Scripts\activate in terminal?
Mirco
Mirco
Is it mean to use command venv\Scripts\activate in terminal?
https://www.jetbrains.com/help/pycharm-edu/creating-virtual-environment.html
Anonymous
I mean into project settings on Pycharm
Can you navigate me clearly what to do?
Mirco
Follow the link of Pycharm docs 😁
Anonymous
Hi
Shreehari
Okay. Let me check it
Suggestion: use some linux based distros & you can create a virtualenv & working with projects in linux based distros is easier