by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    :]
    @elcolie
    ORM question
    Falgun Swami
    @swamifalgun
    Hi i need some help regarding django.
    So i have a database.py file which loads a json file. I want to be able to configure this database file as a database in my django app. I have tried to find ways to do it but failed. Any help will be appreciated. Thanks
    James Komo
    @jameskomo

    Does anyone know how to query another model based on Foreign Key? Say I have a Project model that is a FK in task model and I want to generate all the task_names by querying the Task model and only see tasks applicable to a specific project?

    Tried doing this and it is not working project_tasks=Task.objects.filter(project_id__in=Project.objects.all()).order_by('latest_submission_time')

    Buğra
    @BgR8
    hey, i have question about django admin can someone help me
    how can i export a user to pdf
    matrixbot
    @matrixbot
    Buğra
    @BgR8
    @matrixbot it was not
    how can i export a user to pdf
    is there a solution
    matrixbot
    @matrixbot
    qamarali I think you want to export user data from model to PDF,
    So check it out this link
    https://www.hexascholars.com/code-snippet/export-model-data-into-pdf-in-django/
    Buğra
    @BgR8
    yes in admin panel @matrixbot
    Yorman Aguirre
    @yaguirre
    Hi
    I'm Django developer, new in the community
    Happy to be here :D
    Alejandro Duque Correa
    @aleducode
    Hi @yaguirre from medellin col :)
    dotbrt
    @dotbrt
    Hi everyone! I’m a django beginner (generally a beginner dev)
    I have a question. I’m working through yet another guided project. This time Django Girls. In other projects, everyone simply put the app name into settings.py file, in INSTALLED_APPS. Django Girls did ‘blog.apps.BlogConfig’. What does the .app.BlogConfig part change? I assume it must be created as it’s a custom name, but is there any difference if I just put an app name?
    So in this case ‘blog’ vs. 'blog.apps.BlogConfig'
    matrixbot
    @matrixbot
    qamarali This link will definitely help you out...
    https://docs.djangoproject.com/en/3.0/ref/applications/
    :]
    @elcolie
    @dotbrt What ever your PYTHON_PATH can read
    Reza_XD
    @rezaxd
    @dotbrt hi the "blog.app.BlogConfig" means from app.py in blog folder read the name if the app name.
    matrixbot
    @matrixbot
    thisisshub Can somebody help me with "how to set the STATIC_ROOT in settings.py". I am trying to deploy my app on heroku but I keep getting error Error while running '$ python manage.py collectstatic --noinput'. even though I do have a STATIC_ROOT path in my setttings.py
    SD
    @dubesoftware

    I have a dictionary which contains one item (“current_location”, which is a nested dict) and I would like to access that nested dict. However, I cannot use the key as the code will break if a different key is passed, e.g. “different_location".

    How can I access the first item in a dictionary without using a key? The dict looks like this:

    {'current_location': {'date': '2020-01-27T10:28:24.148Z', 'type_icon': 'partly-cloudy-day', 'description': 'Mostly Cloudy', 'temperature': 68.28, 'wind': {'speed': 10.48, 'bearing': 178, 'gust': 12.47}, 'rain_prob': 0.02, 'latitude': '-33.927407', 'longitude': '18.415747', 'request_id': 31364, 'request_location': 'Current location'}}

    SD
    @dubesoftware
    Got it. I used dict[next(iter(dict))]
    James Komo
    @jameskomo
    Anyone who is familiar with using set.all in django in One-to-many relationship tables?

    I have these two models

    class Project(models.Model):
        project_name = models.CharField(max_length=100, blank=False)
        description = models.TextField(max_length=500, default=None)
        postedOn = models.DateTimeField(auto_now_add=True, blank=True)
        Owner = models.ForeignKey(User, on_delete=models.CASCADE)
        isCompleted = models.BooleanField(default=False)
        deadline = models.DateTimeField(blank=True, null=True)
        task_count = models.IntegerField(default=0)
        attachments=models.FileField(default='Project Attachments', upload_to='tasks_docs', validators=[validate_file_extension])
    
    
        def __str__(self):
            return self.project_name
    
    class Task(models.Model):
        task_name = models.CharField(max_length=50, blank=False)
        addedOn = models.DateTimeField(auto_now_add=True, blank=True)
        project = models.ForeignKey(Project, on_delete=models.CASCADE, default=1)
        rating = models.DecimalField(default=0, max_digits=2, decimal_places=1)
        amount = models.IntegerField(default=0)
        task_description = models.TextField(max_length=1000, default=None)
        task_link = models.URLField(blank=True)
        latest_submission_time = models.DateTimeField(blank=True, null=True)
        isCompleted = models.BooleanField(default=False)
        deadline = models.DateTimeField(blank=True, null=True)
        task_attachments=models.FileField(default='Tasks To Do', upload_to='tasks_docs', validators=[validate_file_extension])
    
    
        def __str__(self):
            return self.task_name

    And I am looking for a way to access tasks based on project. I can select a specific project and view its tasks

    Mihail B
    @mihailb1_gitlab
    @jameskomo try this:
    project = Project.objects.get(id=123).prefetch_related('task_set')
    project.task_set.all()
    you can also specify related_name for project property in Task
    Dipto Karmakar
    @dipto0321
    Hi ,
    Is there anybody who can provide me some good resources for implement social authentication in Django-rest api?
    Thanks :)
    :]
    @elcolie
    Supposed you have new feature that need geoDjango which is rely on postgist
    Will you add extension to existing database and work with it or split it out to be new microservice over REST API?
    AlbertDavid
    @AlbertDavid94

    Hi, I have a quick question.

    Say I have models called "Post" and "Reaction" and I have made a Post, saved it and now I want to react on it with a Reaction.
    Now, when I visit my feed where a list of Posts is, I want to show my reaction if I had one.

    Which means:
    {% if post.my_reaction %}{{ post.my_reaction.contents }}{% endif %}
    Now, obviously I want to load more than just one Post; posts which don't have my reactions on it.

    I know that I used to solve this with SQL in PHP with
    SELECT * FROM Post 
    LEFT JOIN Reaction ON Reaction.Post = Post.id
    How do I do this in Django ORM ??
    Zen
    @master-of-zen
    Hello everyone, i newbie and have some basic sites on django, pls suggest good book about django :)
    AlbertDavid
    @AlbertDavid94
    m8, there's so much material online...
    Did you try following the tutorial that Django provides on their Website?
    Zen
    @master-of-zen
    I think i past that, have more that 2 basic sites, seek for book like 'Fluent Python'. btw don't really bother with it, just asking
    AlbertDavid
    @AlbertDavid94
    Python or Django??
    Zen
    @master-of-zen
    about Django, same level as 'Fluent Python' to python. More like reference book, with in-deep stuff
    AlbertDavid
    @AlbertDavid94
    Hmmm I don't know anything like that.
    sorry
    Zen
    @master-of-zen
    Nwm :)
    mokom
    @mokom
    you should try the book "building django 2.0 web applications"
    it's very detailed and touches on alot of concepts
    Falgun Swami
    @swamifalgun
    i need some help building an api with django
    can anyone help me out
    Falgun Swami
    @swamifalgun
    @mariocesar