Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 14 16:11
    @MadLittleMods banned @Rehmanjeff
Shay Tessler
@shay-te
Hello Django community, I created a new response object based on StreamingHttpResponse for bundling, streaming React, etc.. and more easily
https://github.com/shacoshe/bigpipe-response
I am still thinking of a logo any ideas?
NikiSchlifke
@NikiSchlifke
I want to know something about using the postgres specific ArrayField:
If I have lots of related data that only ever is accessed by that relation would the ArrayField give me better query performance than an extra table?
Let's say I have 1000 rows and each one would have an ArrayField with an average length of 100...
NikiSchlifke
@NikiSchlifke
Something tells me that a 100,000 row long table can't be good, right?
AlbertDavid
@AlbertDavid94
@NikiSchlifke why can't that be good?
databases are made to store large (very f'ing large) amount of data and still perform fast when it comes to reading data from it
DaffyDuck
@DaffyTheDuck
How can I add my custom themes in Django ?
anyone ?
NikiSchlifke
@NikiSchlifke
@AlbertDavid94 AFIK a SQL join is O(n*m) complexity if there's no index on either of them, so no.
And I can't rely on indexes since I will be adding new rows every time the user uses the app.
This kind of performance problem has been occurring sporadically on every project I've worked on.
I have considered using mongodb and I still might migrate to it later but I don't want to pass up on a django admin that "just works" for now.
NikiSchlifke
@NikiSchlifke
Essentially normalized database == slow orm queries every time, so I'm looking to start out with a reasonably denormalized db from the start to save me from refactoring later.
matrixbot
@matrixbot
Ajira what do you mean by custom theme ?
NikiSchlifke
@NikiSchlifke
@IAmAMissingColon Django is not something where themes apply, but there might be higher level application specific frameworks based on django where you can.
For instance django-cms, etc...
In a sense everything is "custom" if you're using just django.
AlbertDavid
@AlbertDavid94
@NikiSchlifke yes, a documentoriented database could be the best solution for this
DaffyDuck
@DaffyTheDuck

@IAmAMissingColon Django is not something where themes apply, but there might be higher level application specific frameworks based on django where you can.
For instance django-cms, etc...
In a sense everything is "custom" if you're using just django.

Oh! Okay :smile:

AlbertDavid
@AlbertDavid94
@IAmAMissingColon Django is just a backend framework for web-applications. If you're familiar with frontend development, you might want to look at bootstrap as a predefined "theme"
There are derived versions of it all over the web (https://bootswatch.com/)
Hedrick Godson
@ShedrackGodson
Welcome
DaffyDuck
@DaffyTheDuck
Sure! Thanks for help :smile: @AlbertDavid94 @NikiSchlifke
Bo
@BoPeng
I need to write some complex forms that for example allow a user to update information on his book, and invite collaborators to reviewer it, so a single "form" with a "submit" button does not seem to cut it. Are there any general advices on such use cases? Right now I am thinking of a webpage with multiple JS functions to update book information, without a big submit button. Then I cannot seem to make use of any form/view features of django.
NikiSchlifke
@NikiSchlifke
@BoPeng Well there's the django-rest-framework way along with a frontend framework like React.
But you could also do it the old fashioned way and just use the rest api where you really need it and oh well jQuery still exists.
If you don't want to do that you can always use multiple forms on one view and make sure existing info is pre-filled properly.
Bo
@BoPeng
Thanks. I have decided early on to use "pure django" and do not venture into areas that I do not know (REST, graphQL, reactJS etc), but I guess it is time to learn something new anyway. My biggest problem is that the rest of the website is already template based with sprinkles of JS+Jquery so the final product would be ugly in terms of use of technologies.
Bo
@BoPeng
BTW, I have not decided on the implementation of "role", "subscription" etc for the ManyToMany relationship between User and Group yet. It seems pretty tricky to extend the GroupManager according to this stack overflow post, but django-organizations is unstable now (2.x alpha) and I do not like the fact that it does not use the built-in Group and Permission facilities. django-groups-manager uses Group but appears to sync its models to User and Group and there are concerns on redundancy and performance. In general I dislike having an unused group field in User and would prefer extending it instead of using a third-party solution...
NikiSchlifke
@NikiSchlifke
I have a question regarding django-rest-framework:
What's the best practice of creating model instances with a foreign key to an existing instance with validation?
I've tried adding it to extra_kwargs in my serializer and passing it to serializer.save(my_foreign_key_id=serializer.validated_data['my_foreign_key']) in the viewset.
If I am at the right track: How do I get it into serializer.validated_data['my_foreign_key']?
If not how do you guys deal with this use case?
NikiSchlifke
@NikiSchlifke
I was sort of expecting that there's a foreign key validator already, but I can't find one so I suspect I'd have to use a custom validator for this.
But then why? I can't think of any concrete rest api that doesn't require some reference to existing data.
NikiSchlifke
@NikiSchlifke
I sort of figured it out, the problem was I was trying to include related data in my ListCreateAPIView which isn't a good idea anyway.
But I do want to include related data in the instance endpoint. So from what I gather I need two serializers for this model or overload something inside the serializer.
NikiSchlifke
@NikiSchlifke
Essentially I want a serializer that uses the foreign key itself overall but use nested data for retrieve.
Gautam
@gautam1858
Made this full stack webscrapper for ML, please star the GitHub repo if you like and give your inputs on the same https://github.com/gautam1858/FullStack-webscraper-for-ML
azarshab-saeed
@azarshab-saeed
How cab I bypass login page in django proxy server??
Mitai
@MitaiGit
Hi everyone I'm a novice noob, sorry for my stupid question, I get json of the form [{"id":1,"name":"Windstorm"}, {"id":2,"name":"Bombasto"}, {"id":3,"name":"Magneta"}, {"id":4,"name":"Tornado"}]
how can I make it generated this way? { "data": [ { "id": "1", "name": "Windstorm" }, { "id": "2", "name": "Bombasto" }, { "id": "3", "name": "Magneta" }, { "id": "4", "name": "Tornado" } ] }
it is need for angulardart tutorial https://angulardart.dev/guide/server-communication
matrixbot
@matrixbot
Ajira myvar = {"data": yourjsondata}
something like this ?
AlbertDavid
@AlbertDavid94
@azarshab-saeed what exactly do you mean with bypassing a login page?
Daniel Nordberg
@dnordberg

Hi, I'm trying to upgrade from Django 1.4.6 to 2.2.9, I use multi-table inheritance in one of my apps and its causing an error, specifically "django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet" the stack trace starting with:

File "/code/media/models.py", line 285, in <module>
class Album(MusicUpload):

I've searched for this error specific to model inheritance to no avail. Has anyone seen something like this? I'm running this through './manage.py check' to identify issues

Daniel Nordberg
@dnordberg
@gautam1858 Could you explain what the project does that a scrapy + some ml doesn't? If a front-end is provided could you provide screenshots and more usage information
Mitai
@MitaiGit
@matrixbot {"data": [{"id": "1", "name": "Windstorm"}, {"id": "2", "name": "Bombasto"}, {"id": "3" , "name": "Magneta"}, {"id": "4", "name": "Tornado"}]} -- like that
Kevin Dahl
@blitzd

Is anyone able to point me at some resources for improving logging/debugging on a 500 server error? The issue seems particularly difficult to search for... I'm seeing something along the lines of this: [13/Feb/2020 11:48:28] "POST /shop_alt/product/membership/ HTTP/1.1" 500 49 and I'd like to see a stacktrace (or even debug) to know why. DEBUG=True, but that one line is all I get. I have tried various logging configs I've found but none have given any more information.

django==1.11.20
mezzanine==4.3.1
cartridge==0.13.0

are the main packages...

Francis Secada
@fsecada01
You would have to check the logs on your server. From experience, Django's 500 error page doesn't reveal anything unless you happen to create a 500 response page to pipe in that info (which would not be advised if you were on a production server)
Hanny Goodwin
@hannylicious
Something that I see glossed over a lot - but is SUPER important (for issues like this) is logging. https://docs.djangoproject.com/en/3.0/topics/logging/
It will tell you exactly what went wrong and all the good stuff. We actually have it log server errors to slack (we remove any sensitive data) so we're alerted to it immediately.
Well, I guess we log to multiple spots - but if you enable logging, that 500 error will show up in the logs with all the appropriate information.
matrixbot
@matrixbot

vladox > Is anyone able to point me at some resources for improving logging/debugging on a 500 server error? The issue seems particularly difficult to search for... I'm seeing something along the lines of this: [13/Feb/2020 11:48:28] "POST /shop_alt/product/membership/ HTTP/1.1" 500 49 and I'd like to see a stacktrace (or even debug) to know why. DEBUG=True, but that one line is all I get. I have tried various logging configs I've found but none have given any more information.

django==1.11.20
mezzanine==4.3.1
cartridge==0.13.0

are the main packages...

Install Sentry if it's remote

vladox Use Pycharm if local
Kevin Dahl
@blitzd
thanks - already using pycharm local, but these 500 errors seem to get caught somewhere along the way in the stack. Other 500 errors DO produce a stack trace to the local console (or our configured logging in our PROD setup), but these ones do not.
Hanny Goodwin
@hannylicious

I would recommend checking your logging settings then. 5xx errors should be getting caught by the django.request logger or the django.server logger I would think (depending where it's happening obviously). Since it's a POST request to a specific URL making the 500 error appear - django.request logging handler will record and give appropriate data on it assuming the logger is configured correctly.

Seems like a logging settings issue to me.

Kevin Dahl
@blitzd

Here's my LOGGING (based on very basic example from docs):

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'file': {
            'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
        },
    },
    'handlers': {
        'file': {
            'formatter': 'file',
            'class': 'logging.FileHandler',
            'filename': f'/tmp/debug.log',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['file'],
            'level': 'DEBUG',
        },
        'django.db': {
            'handlers': ['file'],
            'level': 'ERROR',
        },
    },
}

Still only get this with that though:

2020-02-13 15:19:36,929 django.server ERROR "POST /shop_alt/product/membership/ HTTP/1.1" 500 49

Hanny Goodwin
@hannylicious

Under 'loggers', add another with django.request (copy/paste the one for django.db and replace db with request).

Set the level to INFO and try it again.

Kevin Dahl
@blitzd
done - but same thing...
I think I can carry on fixing this particular problem with some manual breakpoints, but it's very concerning to me we're losing errors somewhere along the way. I suspect it has something to do with Mezzanine
Hanny Goodwin
@hannylicious
Ah! Yeah, you could be correct. I apologize, I was unfamiliar with mezzanine (never seen it or used it); could be something going on there. I would check their docs to see if they have some logging utilities you could utilize. I would imagine they have to have something... otherwise you'd just be guessing at things...
I didn't see mezzanine until I went back and looked at your previous post - sorry about that. Still, I'm surprised the core django logging isn't catching it... mezzanine must abstract some of that away.
Bu─čra
@BgR8
hey i have a question about diagram