Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4615572
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:51:33+00:00 2026-05-22T01:51:33+00:00

I am trying to fill in the DB table Notification through a function as

  • 0

I am trying to fill in the DB table ” Notification ” through a function as follows :

My models :

 class NotificationType(models.Model):
        type = models.CharField(max_length = 100)
        application = models.CharField(max_length = 100)
        description = models.CharField(max_length = 1000 , null = True)

 class NotificationContent(models.Model):
        link_id = models.IntegerField()
        unique_content = models.CharField(max_length = 500)

 class Notification(models.Model):
        person = models.ForeignKey(User)
        content_id = models.ForeignKey(NotificationContent)
        notification_type_id = models.ForeignKey(NotificationType)
        datetime = models.DateTimeField(auto_now_add = True)
        is_active = models.BooleanField(default = 1)
        read_unread = models.BooleanField( default = 0 )

and am using the function send_as_notification_to() in other app view as :

def crave_form(request):
    if request.method == 'POST':
        form = IcraveForm(request.POST)
        if form.is_valid():
            crave = form.save(commit = False)
            crave.person = request.user
            crave.save()
            send_as_notification_to( crave.person  , crave.id , crave.person , 'icrave' , 'crave' )
    else:
        form = IcraveForm()
    return render(request, 'icrave/form.html', { 'form' : form})

function definition :

def send_as_notification_to(person , link_id , unique_content , which_app, notification_type ):

        notification = Notification(person = person)
        notification.content_id.link_id = link_id 
        notification.content_id.unique_content = unique_content
        notification.notification_type_id.type = notification_type
        notification.notification_type_id.application = which_app

Traceback :

Environment:


Request Method: POST
Request URL: http://localhost:8000/icrave/create/

Django Version: 1.3
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.comments',
 'ec.kiosk',
 'ec.chakra',
 'ec.ajax',
 'ec.broadcast',
 'ec.connect',
 'ec.seek',
 'ec.feed',
 'ec.ec_model',
 'ec.info',
 'ec.domains',
 'ec.souk',
 'ec.meta',
 'ec.shastra',
 'ec.chat',
 'ec.log',
 'ec.icrave',
 'ec.notification',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Volumes/Disk2/workspace/ec/ec/icrave/views.py" in crave_form
  16.             send_as_notification_to( crave.person  , crave.id , crave.person , 'icrave' , 'crave' )
File "/Volumes/Disk2/workspace/ec/ec/notification/api.py" in send_as_notification_to
  6.         notification.content_id.link_id = link_id 
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/fields/related.py" in __get__
  301.                 raise self.field.rel.to.DoesNotExist

Exception Type: DoesNotExist at /icrave/create/
Exception Value: 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:51:34+00:00Added an answer on May 22, 2026 at 1:51 am

    In your send_as_notification_to function you need to assign a NotificationContent instance to the content_id value of your Notification instance:

    nc = NotificationContent.objects.create(link_id=link_id, unique_content= unique_content)
    notification = Notification(person = person)
    notification.content_id = nc
    ...
    

    The same will have to be done for NotificationType on Notification.

    One piece of advice I’d like to give you:

    The fields that you’ve named with _id on the end (e.g. content_id, notification_type_id) are not storing the id’s, they are pointers to the actual objects!!! This means that not only will that model have those fields, but django should (I think) also create the following two fields, which actually do point to the id’s of the objects in question: content_id_id, notification_type_id_id.

    Very bad, you should just name it after the Model itself, so: content, notification_type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to fill a table with JSON data. When I run the
I'm trying to add some additional lines to a table in FOP, to fill
I am trying to fill a table view with an array, but I want
I am trying to fill a dataset by OleDbDataAdapter from MS Access DB table.
We are looping through an array to fill a table and it fills fine,
I have a UIViewController that contains a UITableView. I'm trying to fill this table
I'm trying to fill a table with data I have in a structure, elements_table,
I am trying to get a label to fill a table cell whilst having
I am trying to fill a form in a php application from a C#
I'm trying to fill an array of 20 ints with numbers from 1-20 in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.