Answer the question
In order to leave comments, you need to log in
How to change links to third-party sites in the django admin panel?
Connoisseurs, please tell me how to make it possible to change links to social networks through django admin. networks such as vk insta ... in order not to constantly climb and change in html, but to enter the admin panel and change
the model, I created
class Social(models.Model):
title = models.CharField(max_length=255, verbose_name="Name of the social network ")
slug = models.SlugField(max_length=255, verbose_name="URL", unique=True)
img = models.ImageField(verbose_name='Network Logo', blank=True)
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('social', kwargs={"slug": self.slug})
class Meta:
verbose_name = 'Social. Network'
verbose_name_plural = 'Social
class SocialAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("title",)}
admin.site.register(Social, SocialAdmin)
Only it issues a link that it generates.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question