Why is my Django mode object not appending my random ID generated tag to my URL?

Right, I am literally about to loose my temper.

I have a Django model, with an object. I have a fucntion which generated a random ID, appends it to the model object and places it on the end of the URL.

Thats the theory anyway, but just like everything else in my life, nothing works. I have a great big neon sign that is only invisible to me which stated “Please piss this guy off as much as you possibly can!”

You have no idea how sick to death I am of this. It’s so silly! It’s so unfair and I am going to fume.

In my urls.py I have:

“from django.urls import path, include
from . import views

urlpatterns =[
path('',views.careers, name="careers"),
path('apply/<str:careers_reference>',views.apply),
]``

In my views.py I have:

`from django.shortcuts import render, redirect, get_object_or_404
from django.core.mail import send_mail, BadHeaderError
from django.http import HttpResponse, HttpResponseRedirect
from django.template import loader
from . models import Careers
import logging
from xxxx import utils

def apply(request, careers_reference):
 career_detail           = get_object_or_404(Careers,careers_reference = careers_reference)
 template                = loader.get_template('careers-details.html')

 context = {
  'career_detail'           :   career_detail,
  }    

 return HttpResponse(template.render(context, request))`

In my models.py, I have

`from django.db import models
from . import utils
# Create your models here.

REGION = {
"US":{
    "Embarcadero, Palo Alto, California":"Palo Alto",
    "Redwood Shores, Redwood City, California":"Redwood City",
    "Dover, Kent County, Delaware" : "Dover, Delaware",
    "Hybrid (US)":"Hybrid",
},
"UK":{
    "Canada Square, Canary Warf, London, UK":"Canary Warf, London",
    "Hybrid (UK)":"Hybrid",
},
"Remote" : "Remote",

}

DEPARTMENT = (
(‘Technical Services’, ‘Technical’),
(‘Financial Services’, ‘Finance’),
(‘Client Services’, ‘Client’),
(‘Operational Services’, ‘Operational’)
)

CONTRACT = (
(‘Permanent – Full Time’,’Permanent – Full Time’),
(‘Permanent – Part Time’,’Permanent – Part Time’),
(‘Contract – Full Time’,’Contract – Full Time’),
(‘Contract – Part Time’,’Contract – Part Time’),
(‘Contract’,’Contract’)
)

CONTACT = (
(‘xxx’,’xxx’),
(‘xxx’,’xxx’),
(‘xxx’,’xxx’),
(‘xxx’,’xxx’),
)

class Careers(models.Model):

careers_reference      =   models.CharField(max_length=100, default=utils.job_reference(12), unique=True,editable=False)
career_job_title       =   models.CharField(max_length=255)
career_job_summary     =   models.CharField(max_length=255)
career_department      =   models.CharField(max_length=255, choices=DEPARTMENT, default="technology")
career_region          =   models.CharField(max_length=255, choices=REGION, default='uk')
career_contact         =   models.CharField(max_length=255, choices=CONTACT, default='Whatever')
career_specification   =   models.TextField(default="", null=True)
career_contract        =   models.CharField(max_length=255, choices=CONTRACT, default='')
#slug                   =   models.SlugField(default="", null=True, unique=True)

class Meta:
    verbose_name_plural = "Careers"

def str(self):
return self.JobTitle`

In my utils.py, I have:

`import random, string

def job_reference(charlength):
post_reference = ”.join(random.choices(string.ascii_uppercase + string.digits, k=charlength)) # Generates a random string
return str(post_reference)`

In my admin.py

`from django.contrib import admin
from . models import Careers
class MemberAdmin(admin.ModelAdmin):
list_display = (“career_job_title”,”careers_reference”)

Register your models here.

admin.site.register(Careers, MemberAdmin)`

This is absolutely stupid, isn’t it? I swear Django has a mind of its own sometimes. Perhaps today it;s just decided “Nah, Im going to piss this bloke off because I feel like it”

Guess what, I’m in bloody charge here, and If I tell Django to do something, it bloody damn well does it.

So tired of this bullshit, day in, day out with this framework

Sold my sanity?Sold my sanity?

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật