by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    stephenprakash
    @stephen5prakash_twitter
    angular 7 and nodejs
    it's useful for web developers
    :]
    @elcolie
    I don't see it related to Django
    Nodejs has its own channel
    stephenprakash
    @stephen5prakash_twitter
    not django
    but its helpful for developers
    Max Pearl
    @maxpearl
    @stephen5prakash_twitter this is the Django channel.
    stephenprakash
    @stephen5prakash_twitter
    okay guys
    sorry
    Srini555
    @Srini555
    Hi all
    :]
    @elcolie
    @Srini555 What's your question?
    I see you greeting in Python channel too. Are you new to Django?
    Chaitanya
    @ChaitanyaM18
    How to render CSV data as drop-down in django
    Juliano Ribeiro
    @supernoi
    Hi
    I had a error in my project, as I am a beginner with dev Django, I went to read the manual. But I remained a little confused. In my case I have the models called Clients and Hosts.
    Every Host belongs to a Client, so I added the id_client field as a foreign key, in the Host table, in the templates when I have to access the client name through the Host table do so for example: {{host.id_client.name}}.
    But when I was learning and trying to implement CRUD + AJAX on my project, when trying to create a new Hosts model record, I had to use id_client_id, for function "create ()" ...
    In the Models documentation, I found the paragraph "Database Representation" that says Django adds "_id", but would you like to understand if this is editable? Or should you rename the column FK?

    My models:
    class Clients(models.Model):
    id_client = models.BigIntegerField(primary_key=True, blank=True)
    ...

    class Hosts(models.Model):
    id_host = models.BigIntegerField(primary_key=True)
    id_client = models.ForeignKey('Clients', models.DO_NOTHING, db_column='id_client', related_name='host_client_id')
    ...

    obj = Hosts.objects.create(
    id_client_id=id_client,
    <others fields>
    )
    ritik
    @chauhan-ritik
    hi ,I am new to django and I am getitn an error ..Exception Type: ValueError
    Exception Value:
    The view accounts.views.register didn't return an HttpResponse object. It returned None instead.
    while creating registeration form
    can someone help
    Mike Simkins
    @msimkins
    @chauhan-ritik Is the last line of your method 'return HttpResponse........' ??
    ritik
    @chauhan-ritik
    i am getting ImportError: cannot import name 'RegistrationForm' from 'django.contrib.auth.forms'( /home/ritik/.local/lib/python3.7/site-packages/django/contrib/auth/forms.py)

    from django import forms
    from django.contrib.auth.models import User
    from django.contrib.auth.forms import UserCreationForm

    class Registrationform(UserCreationForm):
    email = forms.EmailField(required = True)

      class Meta:
            model =User
            fields =(
                  'username',
                  'first_name',
                  'last_name',
                  'email',
                  'password1',
                  'password2'
            )
    
      def save(self,commit=True):
            user=super(RegistrationForm,self).save(commit=False)
            user.first_name=self.cleaned_data['first_name']
            user.last_name=self.cleaned_data['last_name']
            user.email=self.clelaned_data['email']
    
    
            if commit:
                  user.save()
    
            return user
    can anyone help
    @msimkins thanks for the previous error
    Mike Simkins
    @msimkins
    @chauhan-ritik I think your form is called Registrationform not RegistrationForm
    Ahmed Sallam Nassar Awad
    @ahmed-sallam
    Hi, everyone, How can I make query string in django like
    ?
    Filip Lav Maksimovic
    @maximlion
    @ahmed-sallam can you elaborate more on that?
    Ahmed Sallam Nassar Awad
    @ahmed-sallam
    Thanks @maximlion , I mean , I want to make a query string in urls with key=value
    Filip Lav Maksimovic
    @maximlion
    Hello everyone, is there a way I could add an attribute to all query objects using annotate? I basically just need to get a value from an m2m relationship of the object and save it as an attribute of the object.
    Something like this: query.annotate(value_to_be_added=("value_from_m2m"))
    @ahmed-sallam first you need to adapt your urls.py to accept a url parameter, then adapt the views get method to accept parameters and that should be it. This could help: https://stackoverflow.com/questions/150505/capturing-url-parameters-in-request-get
    Ahmed Sallam Nassar Awad
    @ahmed-sallam
    @maximlion Thanks a lot, I will try it.
    Swaraj Pande
    @swarajpande4
    Hey guys, new to django here :)
    SD
    @dubesoftware
    Hey guys. SOS please. How do I write a URL pattern for a URL like this? weather/?current_location=-33.927407,18.415747&booking_location=-32.927407,19.415747
    When I do reverse(‘weather’, kwargs={‘current_location’: some_value, 'booking_ location’: another_value}) I am getting a NoReverseMatch exception.
    :]
    @elcolie
    @swarajpande4 Welcome to the world :0
    @dubesoftware Too short. I need more detail on your question
    I need you see your urls.py and views.py
    :]
    @elcolie
    national_card = models.ImageField(upload_to='./national_cards/', null=True, blank=True)
    How can I add encryption key to encrypt my national_card?
    And frontend will decrypt it by itself
    hardik Gajjar
    @gajjar8055
    Implement your custom storage class for your encryption
    :]
    @elcolie
    Thank you
    Brian Edelman
    @brianedelman

    I am using Django Rest Framework and have a model with a timestamp field that I want to group by. The outcome I would like is to have something like {tournament_count: 2, start_date: datetime object, tournaments: [{...tournaments model representations}]} I currently have a queryset returning the tournament_count and start_date but now I want to drop in the actual tournaments as well.

    queryset.annotate(
                    start_date=Trunc("time_stamp", "day", output_field=DateTimeField())
                )
                .values("start_date")
                .annotate(tournament_count=Count("id")).order_by()

    I can't figure out a solution that will work well and scale well. Any thoughts?

    Hi