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 2021 16:11
    @MadLittleMods banned @Rehmanjeff
Rens Houben
@rhouben:vac.systemec.nl
[m]
Other than that, I hope for your sake that this wasn't a production system, lest this lesson in why you need a competent sysadmin become fatally expensive rather than painfully embarassing.
The only thing an analytics tool is going to accomplish in your case is to provide you with more data you still won't know what to do with.
Rens Houben
@rhouben:vac.systemec.nl
[m]
To put it into less technical vernacular, what you're asking for is the equivalent to asking to borrow a tow truck from someone because your car is in a ditch, except that your car went into the ditch because you have no idea how to drive. The only thing giving you a tow truck will accomplish is to make your problem worse.
Steven Parker
@ConnectSteven_twitter
E-commerce Web application Using Django, A web application built in Django for purchasing products online. execute command to create migrations and register models in the database. https://github.com/Mindinventory/django_ecommerce_boilerplate
SERP!CO
@serpic0:matrix.org
[m]

You might find this useful if you want to avoid using js framework for your front end.

https://www.django-unicorn.com/

konstantinmds
@konstantinmds
Anyoune had problem with django channels on the heroku ? Mine is working localy, but can't establish the WS connection on the Heroku.
SERP!CO
@serpic0:matrix.org
[m]
yes i had issues with it but i never got it to work. Can't get WSS to work so it's always jsut WS along HTTPS which obviously wouldn't work.
Post back if you found the solution 🙂 so we can all learn something
Abhishek nipane
@Abhi1601
I need help with sql server stat to extract data from website
1 reply
Abhishek nipane
@Abhi1601
Sure
omid zarinmahd
@zarinpy
Hi
I have a question regarding DjangoORM implementation :
you know this ORM supports some database functions that are really handy
but there are many functions in databases that Django ORM doesn't support
is there a reason behind this or do you guys have some plans?
some functions that Django ORM doesn't suppport
cbrt()
div(y numeric, x numeric)
bit_xor()
bool_and()
covar_samp()
stddev_pop()
percentile_cont()
and there are more...
Julian Gonggrijp
@jgonggrijp
@zarinpy I don't know the particular rationale for those omissions, but there is always RawSQL for the more exotic cases.
Abhishek nipane
@Abhi1601
How do I filter data with with servers in pvt IP address
I am kind off in extracting data from website but whenever I do it on SQL it’s shows errors
serpic0
@serpic0:matrix.org
[m]
@Abhi1601: please show your relevant code and show the errors.
dima-dmytruk23
@dima-dmytruk23
hi. can help me with N+1 problem and DRF SerializerMethodField?
https://stackoverflow.com/questions/72737010
Berel Levy
@berellevy
If you call values on the queryset and get the related fields that way you won’t get n+1
Berel Levy
@berellevy
But then you wouldn’t need to use a serializer
dima-dmytruk23
@dima-dmytruk23
@berellevy it's not help me
Berel Levy
@berellevy
I realize. Sorry. You need a field that is a nested list of objects?
Kizito Njoku
@nkizito92
Hi I'm new to Django I already set up the rest framework and got it working with react.
Kizito Njoku
@nkizito92
Does anyone know why I don't get the POST request data for my reducer in react, but the request is still a success for the backEnd?
import { createSlice } from '@reduxjs/toolkit'
export const cardReducer = createSlice({
    name: 'cards',
    initialState: {
        cards: [],
        isLoading: false
    },
    reducers: {
        getCardsFetch: (state) => {
            state.isLoading = true;
        },
        getCardsSuccess: (state, action) => {
            state.cards = action.payload;
            state.isLoading = false
        },
 # This is where the Post request data is added to the state
        newCardPost: (state, action) => {
            return {
                ...state, cards: [...state.cards, action.payload]
            }
        },
        updateCardSuccess: (state, action) => {
            const idx = state.cards.findIndex(card => card.id === Number(action.payload.id))
            const newState = [...state.cards]
            newState.splice(idx, 1, action.payload)
            return {
                ...state, cards: [...newState],
            }
        },
        deleteCardSuccess: (state, action) => {
            return {
                ...state,
                cards: [...state.cards.filter(card => card.id !== Number(action.payload.id))]
            }
        },
        getCardsFailure: (state) => {
            state.isLoading = false;
        }
    }

});
Kizito Njoku
@nkizito92
Python code from views.py
# Create a Word
@api_view(['POST'])
def addWord(request):
    newWord = request.data
    # How to create an object
    word = Word.objects.create(
        name=newWord['word']['name'], definition=newWord['word']['definition']
    )
    serializer = WordSerializer(word, many=False)
    # To debug first import pdb then from desired line type pdb.set_trace()
    return Response(serializer.data)
Kizito Njoku
@nkizito92
RobertDowneyJrFrustratedGIF.gif
So everything is working, but the new object I create is undefined for the state until I refresh the page. I checked the actions payload and everything the user sent is there.
Julian Gonggrijp
@jgonggrijp
@nkizito92 I see nothing problematic in the Python part. The JS part is also more complex, so I suspect the cause of the problem is somewhere in there. However, I don't know enough about React or Redux to identify the problem easily. Perhaps take it to a dedicated React/Redux room.
Kizito Njoku
@nkizito92
I knew nothing was wrong with the Python part. I don't get why the React part doesn't. I will do some more research on this. @jgonggrijp Thanks tho.
Kizito Njoku
@nkizito92
I got it to work
Julian Gonggrijp
@jgonggrijp
@nkizito92 Well done. Please share the answer if you don't mind.
Kizito Njoku
@nkizito92
So it was in my Post request all I added was yield workGetCardsFetch()
to get the data from the backend
here is the full code
function* workGetCardsFetch() {
    // const cards = yield call(() => fetch('http://127.0.0.1:8000/'))
    // const formattedCards = yield cards.json();
    const cards = yield call(() => axios.get('http://127.0.0.1:8000/'))
    yield put(getCardsSuccess(cards.data))
}

function* workCreateCard(action) {
    try {
        const word = action.payload
        const options = {headers: { "content-type": "application/json" }}
        yield call(() => axios.post('http://127.0.0.1:8000/words/new/', { word }, options))
# here is what I added in the Post request    
    yield workGetCardsFetch()
    } catch (error) {
        console.log(error.message)
    }
}
Kizito Njoku
@nkizito92
So the problem was the reducer wouldn't get the new id for the state the backend created for the new object, all I did was make the generate function* workCreateCard call the generate function* workGetCardsFetch to get all the data including the new one to display
Julian Gonggrijp
@jgonggrijp
@nkizito92 Clear! Thx
ghobona
@ghobona

The Open Geospatial Consortium (OGC) invites software developers to the July 2022 OGC API Code Sprint, aka ‘The Vector Data Code Sprint’, to be held virtually from July 12th-14th, 2022. Registration closes July 12.

The Vector Data Code Sprint will focus on the following standards, which are mostly related to vector data and their associated attributes:

Register at https://developer.ogc.org/sprints/17

Note for django developers, some of the participating projects (e.g. pygeoapi) have implemented OGC API Standards using django and other python-based libraries. So the code sprint will be a good opportunity to find out above those projects.

kalaLokia
@kalaLokia
What is the best way to create unique order number for a django ecommerce web application?
using uuid4 is good or bad choice?
SERP!CO
@serpic0:matrix.org
[m]
@kalaLokia: The shortuuid library has been useful to me for many years
https://pypi.org/project/shortuuid/
Ken-tech-max
@Ken-tech-max
Hello @everyone is there any example of Django-react pdf reader in github or any blog?
Rens Houben
@rhouben:vac.systemec.nl
[m]

Hokay, I've got kind of a convoluted setup here that I need to modify.

Core point for this is that I have a class 'Connection' and a class 'NAS', and a lot of both. Now because of orders from On High I need to be able to define, per Connection, which NAS elements are valid for that particular Connection. I think a ManyToManyField may do what I want but I'm not 100% sure.

Ideally, I'd want to represent it in the frontend with one of those dropdown-with-radio elements, because while the number of NAS objects will be limited I can't predict how many there will be.
Rens Houben
@rhouben:vac.systemec.nl
[m]

... Also, while updating my test suite I'm suddenly getting a whole shitload of error messages like this:

RuntimeError: Model class urania.radius.models.Version doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

and I'm not sure what's causing them since I don't see them when I run the tests on my local machine.

Rens Houben
@rhouben:vac.systemec.nl
[m]
:point_up: Edit: Never mind, this was a typo in the rsync command.
Piyush
@piexpie
hi
is there any library that can automatically generate CRUD APIs for django models?
Django rest framework is there but it still requires writing separate serializers and views for each model...
I would prefer an automatic CRUD API from the models
Piyush
@piexpie
@everyone
Chris Maggiulli
@cmaggiulli
Hi everyone. I have a fairly complex design question related to our hierarchical group role access control implementation, built on top of Django Guardian. I essentially need a recommendation on how to implement user object and group object create permissions. We have a very robust implementation of view, delete, edit but add is difficult because there is no object to apply the the permission to. I'm thinkin maybe a pre-save handler that checks if certain conditions are meant and applies the permission? Is there a place I could long form discuss this?
1 reply