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
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
i don't understand this question how can i do that
Hanny Goodwin
@hannylicious
The question just wants you to create a diagram (I'm assuming similar to the one they've given you).
@hannylicious
Buğra
@BgR8
is it true anyone else know
vadisinasaisudha
@SaiSudhaV
Hello I am new to open source can anyone help me how to contribute
Harpreet Singh
@Harpreet1999
hey there how's everyone. I'm here to say hi. to the community. Currently working on the polls tutorial, i've gone through the basics and hopefullly i'll complete it in few days. i'm looking forward working with you guys.
Bo
@BoPeng
I am trying to return the "latest version" if there are multiple versions of the same book from a list. It is like Book.objects.values('title').annotate(Max('version'))but I would like to get the original Book objects, not the versions. How can I do that?
Nam Le
@leqnam
@BoPeng have you tried this? https://stackoverflow.com/a/30777133
Bo
@BoPeng
I cannot see how it is related to my question at a first glance. My books have different versions but they are separated and have different permissions, in the sense that a visitor can see the latest published version and an editor can see the latest under-review version, so there is no universal latest for all visitors. Right now I am doing something like Book.objects.filter(... according to visitor) then get the latest allowed versions in Python, and I am wondering if there is a SQL / DRM solution here.
I could compute a bunch of flags such as latest_under_review, latest_published but keeping track of these flags with the addition and removal of books can be a hassle.
On the SQL side https://stackoverflow.com/questions/6841605/get-top-1-row-of-each-group suggests the use of cross apply, which does not seem to be supported by django DRM.
Dr. Muhammad Anjum
@anjumuaf123_twitter
@anjumuaf123_twitter
hi any body Please, how can i update 3.6 to 3.8 python version on window 10
?
Hanny Goodwin
@hannylicious
Download Python3.8, Install it on Windows10 same as you did 3.6 and use both (should you want) or just uninstall 3.6 if 3.8 works for you. You can have multiple versions of Python installed (in my experience it has worked without issue).
Dr. Muhammad Anjum
@anjumuaf123_twitter
@hannylicious Thanks sir, but I want to use only 3.8 , just to update 3.6 to 3.8 , I have already installed 3.6
Hanny Goodwin
@hannylicious

I think you can just download 3.8 and install it, and then uninstall 3.6.

I don't think there is an 'upgrade in place' type option.

Dr. Muhammad Anjum
@anjumuaf123_twitter
@hannylicious Sir, thanks , but in the you tube I saw one video , they have option but not for me