Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    vaibhav jain
    @vaibhav-jain
    ok :+1:
    Ramon Moraes
    @vyscond
    Hey fellow friends

    I'm getting a connection refused error while trying to run my tests

    django.db.utils.OperationalError: could not connect to server: Connection refused
        Is the server running on host "127.0.0.1" and accepting
        TCP/IP connections on port 5432?

    The but problem is that my DB settings are not pointing to loop address. My DB is actually running on a separated container (docker-composer) so i reach him with project_api_db_1 address. Which works fine while testing the server manually with run server the problem is at the unit tests. I've never seen this before :/ why Django is ignoring my host address?

    My db settings to default
    "default": {
      "ENGINE": "django.db.backends.postgresql_psycopg2",
      "NAME": "api_db",
      "USER": "postgres",
      "PASSWORD": "postgres",
      "HOST": "project_api_db_1",
      "PORT": "5432",
      "TEST": {
        "HOST": "project_api_db_1"
      }
    },
    Helton Costa
    @heltucosta
    Hey guys, have anyone worked with libxml2, lxslt and xmlsec with python ? I am having a lot of trouble installing them inside my virtualenv. already tryed building the binaries separetely and them installing but i’m still getting some errors
    Kha
    @nlhkh
    @vyscond are you using Docker swarm?
    If you are using docker swarm, then make you the containers are on the same overlay network
    If not, then check if you have linked the image.
    Also, usually you only need to use the container name project_api_db, not the instance of container name.
    @Ferdellans Angular 1?
    Hey guys, I am looking to perform bulk edit in admin.
    For example, if I have a list of questions, then I want them to be in a table (as they already are), and the fields are editable with 1 big Save button for all of them. Is this possible?
    JAFTEM
    @JAFTEM_twitter
    Hey everyone, I'm really unfamiliar with Django and web services in general. I'm looking for a framework that has realtime database support for an app with an emphasis on realtime chat. I know chat really can't be done on a RESTful web service (or can it?) and I might need to look into web sockets. Can this be done with Django and as a general question is there any reason to favor one framework over another for what I want to do? Thanks.
    sankalp yadav
    @say2sankalp
    how to install scrapy in windows
    there is particlular error saying lxml error
    vaibhav jain
    @vaibhav-jain
    @say2sankalp install lxml from this link http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
    @JAFTEM_twitter have a look at this https://djangopackages.org/grids/g/chat/
    Maksym L
    @maksymx
    Hello everyone! Could you please help me and describe me how to configure Django project to use settings from external source?
    I mean smth like os.environ.setdefault("DJANGO_SETTINGS_MODULE", "http://site.com/deploy/settings") in wsgi.py
    vaibhav jain
    @vaibhav-jain
    @yakudzam you want to use environment variable?? You can set DJANGO_SETTINGS_MODULE to your desired module in your post activate script of virtualenv that way it will be loaded automatically and then remove that line from the wsgi.py
    As its not needed anymore
    Maksym L
    @maksymx
    @vaibhav-jain sounds good for local settings. But is it possible to use django without local settings file? I mean fetch already configured settings by python, open it and use it like python file object?
    vaibhav jain
    @vaibhav-jain
    Already configured?? Can you please explain. Without local settings file?? You want to use remote file??? If you can explain requirements in more detail perhaps we can help you out.
    Maksym L
    @maksymx
    yes, correct. I want to use remote file. As my colleagues explained, smth like from django.conf import settings for key, value in web_settings.items(): setattr(settings, key, value)
    Still why you need to read remote settings file??
    agusmakmun
    @agusmakmun

    someone can help me.
    i use multiple site, multiple env, multiple project, multiple database.
    and found this error message if use DATABASE_ROUTER.

    insert or update on table "django_admin_log" violates foreign key constraint "django_admin_log_user_id_c564eba6_fk_auth_user_id"
    DETAIL:  Key (user_id)=(1) is not present in table "auth_user".

    i already tried with this answer: http://stackoverflow.com/a/20094869/6396981 or https://code.djangoproject.com/ticket/23297, but still an error.

    if i do migration with following DATABASE_ROUTER, i found an error django.db.utils.ProgrammingError: relation "auth_user" does not exist. this why we migrated first my second database and then setup the DATABASE_ROUTER after doing migration.

    settings.py : http://pastebin.com/zWjy0z3R
    myproject/routers.py: http://pastebin.com/M9i4KVew

    thnk so much before..

    agusmakmun
    @agusmakmun

    i implemented the model to save the id from user from another db with integer field and not FK.
    models.py : http://pastebin.com/EXtcM85b

    if we try to check my Users, it work well. but not for default:

    >>> from django.contrib.auth.models import User
    >>> User.objects.all()
    [<User: user_a>, <User: user_b>, <User: user_c> ]
    >>>
    >>> User.objects.using('default')
    []
    >>> User.objects.using('auth_db')
    [<User: user_a>, <User: user_b>, <User: user_c> ]
    >>>
    typo: DATABASE_ROUTER mean DATABASE_ROUTERS
    Maksym L
    @maksymx
    @vaibhav-jain CI improvements :worried:
    vaibhav jain
    @vaibhav-jain
    I have never been in a situation like this. I use http://wercker.com/ as CI and Heroku, Dokku and Docker for deployment and I just need to set the env variable that's it . I'm confused why anyone would do that. Ask your problem on SO.
    agusmakmun
    @agusmakmun
    solved: by creating the superuser fist.. thank you so much to god..
    Kha
    @nlhkh
    @JAFTEM_twitter you are better off with a realtime framework such as Firebase (from Google), or Parse (previously from Facebook, so you will have to host it yourself).
    @yakudzam you can have a startup script (in bash?) that fetch the remote config file, and then Django can pick it up.
    Maksym L
    @maksymx
    @nlhkh yep, I just thought in that way
    Saurabh K
    @skulk001
    @
    @Jaftem checkout django-channels
    JAFTEM
    @JAFTEM_twitter
    @nlhkh Thanks for the reply. I rather not rely on Firebase or Parse or another PaaS. Is Django any worse than any other framework for an app that requires an emphasis on real time data? Does it really matter or should I just get to coding?
    vaibhav jain
    @vaibhav-jain
    @JAFTEM_twitter there are several articles about the same. Please have a look they might help you decide. https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=real%20time%20chat%20application%20django
    Philip Eckert
    @pae4557
    Anybody have experience printing a base64 image to a PDF using reportlab? Or even just decoding a base64 image to a PNG?
    Everytime I decode it and try to load the png, it crashes the command prompt and spits out the whole base64 string in the django error page (really long)

    '''
    def decode_base64(data):
    missing_padding = len(data) % 4
    if missing_padding != 0:
    data += b'='* (4 - missing_padding)
    return data.decode('base64')

    def pdf_view(request):
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="densitycurve.pdf"'

    (graph,outputText) = processData(misc.densitycurve)
    outputList = string.split(outputText, "\n")
    p = canvas.Canvas(response)
    
    # Draw things on the PDF. Here's where the PDF generation happens.
    # See the ReportLab documentation for the full list of functionality.
    for i in range(len(outputList)):
        outputList[i] = string.lstrip(outputList[i])
        p.drawString(100, 10*i+100, outputList[i])
    
    #p.drawString(100, 60, "Report created with FSC iCalc")
    
    image = open("image.png", "wb")
    image = ImageReader(decode_base64(graph))
    p.drawImage(image, 100, 350) 
    image.close()
    
    p.showPage()
    p.save()
    return response

    '''

    Kha
    @nlhkh
    @JAFTEM_twitter you can try Django channels, but you will soon find that it is a pain to implement the realtime sync yourself. I have been there done that. Firebase can help you quickly add realtime functionality to your app with no cost of development from you. Other options you can look into includes Socket.io (using a separate NodeJS server), and a fullfledge chat server, such as Openfire, or Ejabberd.

    I have question regarding the User model in Django. My Django app is open for public registration, via email/password, Facebook, Twitter,…

    Django will serve mobile devices and web, so I would be using JWT and web session/cookie for authentication.

    My question is, should I use the default model from Django auth contrib and extends it a little bit, or should I create a totally separated model?

    Simon Frid
    @fridiculous
    Does anyone know of a tagging framework in python that isn't django-taggit? I know it's ironic to ask this room.
    Alex Jerez
    @alex-jerez
    @fridiculous anything you're looking for in particular that django-taggit doesn't provide? implementing a tagging system should be pretty straightforward if you want to make one yourself.
    Simon Frid
    @fridiculous
    yes, one that doesn't require django-orm . e.g. works on flask / sqlalchemy
    i'm already using django-taggit for one project, but i'm trying to make a non-django parallel, and sometimes working outside the django ecosystem is pretty difficult :D
    Miracle Ayodele
    @iammiracle
    hello friends
    I have been trying to link up my registration form to my database, but seems, i am not gettting it
    Miracle Ayodele
    @iammiracle

    views.py

    def bemember(request):

    if request.method == 'POST':
        form = becomemember(request.POST)
        if form.is_valid():
            beamember_obj = form.save(commit=True)
    
            surname = form.cleaned_data['surname']
            firstname = form.cleaned_data['firstname'],
            othername = form.cleaned_data['othername'],
            email = form.cleaned_data['email'],
            phone = form.cleaned_data['phone'],
            password = form.cleaned_data['password'],
            confirmpassowrd = form.cleaned_data['confirmpassword'],
            marital = form.cleaned_data['marital'],
            gender = form.cleaned_data['gender'],
            work = form.cleaned_data['work'],
            address = form.cleaned_data['address'],
            workdetails = form.cleaned_data['workdetails'],
            identity = form.cleaned_data['identity'],
            idno = form.cleaned_data['idno']
    
            return HttpResponseRedirect('/beamember/')
    else:
        form = becomemember()
    
    return render(request, 'beamember/beamember.html', {'form': form})