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 4613656
In Process

The Archive Base Latest Questions

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

Man am passing these values from the function to the db model as :

  • 0

Man am passing these values from the function to the db model as :

function definition :

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

        nc = NotificationContent.objects.create( link_id = link_id , unique_content = str(unique_content))
        app_obj = MetaAppNames.objects.create(name = which_app)
        nt = NotificationType.objects.create( type = notification_type , app = app_obj) 
        notification = Notification(person = person)
        notification.content = nc
        notification.notification_type = nt
        notification.save()
        nc.save()
        app_obj.save()
        nt.save()

Calling view :

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
            send_as_notification_to('admin' ,crave.id , crave.person , 'icrave' , 'crave' )
            crave.save()
    else:
        form = IcraveForm()
    return render(request, 'icrave/form.html', { 'form' : form})

but it’s giving me error as :

notification_notificationcontent.link_id may not be NULL

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',
 'doj',
 '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
  15.             send_as_notification_to('admin' ,crave.id , crave.person , 'icrave' , 'crave' )
File "/Volumes/Disk2/workspace/ec/ec/notification/api.py" in send_as_notification_to
  6.         nc = NotificationContent.objects.create( link_id = link_id , unique_content = str(unique_content))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py" in create
  138.         return self.get_query_set().create(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py" in create
  360.         obj.save(force_insert=True, using=self.db)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py" in save
  460.         self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py" in save_base
  553.                     result = manager._insert(values, return_id=update_pk, using=using)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py" in _insert
  195.         return insert_query(self.model, values, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py" in insert_query
  1436.     return query.get_compiler(using=using).execute_sql(return_id)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  791.         cursor = super(SQLInsertCompiler, self).execute_sql(None)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  735.         cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/util.py" in execute
  34.             return self.cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
  234.             return Database.Cursor.execute(self, query, params)

Exception Type: IntegrityError at /icrave/create/
Exception Value: notification_notificationcontent.link_id may not be NULL
  • 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:35:01+00:00Added an answer on May 22, 2026 at 1:35 am

    When you call your function, you haven’t committed your object (crave) to the database. If it’s got a database-generated identifier for the id property, this will still be null. And it’s this id property value that it’s trying to use for the link_id that it is complaining about.

    You need to either stop specifying commit=False, or you need to call crave.save, before you call your function.

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

Sidebar

Related Questions

Per man pages, snprintf is returning number of bytes written from glibc version 2.2
From the man page on git-merge, there are a number of merge strategies you
From the XDrawString man page it seems that it aceepts signed 32 bit x
From pthread_join() man page : When a joinable thread terminates, its memory resources (thread
From the man pages: -j [jobs], --jobs[=jobs] Specifies the number of jobs (commands) to
Real simple question. According to my man-page, these two will do the same: time_t
man gitglossary contains this definition of an evil merge : An evil merge is
The man page for xcodebuild reads: Run xcodebuild from the directory containing your project
From the recv(2) man page: MSG_WAITALL This flag requests that the operation block until
Man there are a lot of these questions but so far I have not

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.